Advertisement
TermSpar

phOS IDE

Mar 5th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 10.80 KB | None | 0 0
  1. Imports System.IO
  2. Public Class frmIDE
  3.     Dim openedFile As String = ""
  4.     Dim currentForm As Form
  5.     Dim createdButton As New Button
  6.     Public history As String
  7.     Public works As Boolean = True
  8.     Private Sub RunToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RunToolStripMenuItem.Click
  9.      
  10.     End Sub
  11.  
  12.     Sub createdButton_Click()
  13.         For u = 0 To txtCode.Items.Count - 1
  14.             Dim userCode As String = txtCode.Items.Item(u)
  15.             Dim input() As String = Split(userCode)
  16.             Dim newLabel As New Label
  17.             If input(0) = "labelOutput:" Then
  18.                 Dim x As Integer
  19.                 For Each a As String In txtInput.Text
  20.                     If txtInput.Text.Contains(" ") Then
  21.                         x += 1
  22.                     End If
  23.                     Try
  24.                         currentForm.Controls.Add(newLabel)
  25.                         newLabel.Text = newLabel.Text & " " & input(x)
  26.                         newLabel.AutoSize = False
  27.                         newLabel.Size = New Size(260, 243)
  28.                     Catch ex As Exception
  29.  
  30.                     End Try
  31.                 Next
  32.                 x = 0
  33.             End If
  34.         Next
  35.     End Sub
  36.  
  37.     Private Sub frmIDE_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  38.         If works = True Then
  39.             My.Settings.Works = True
  40.         Else
  41.             My.Settings.Works = False
  42.         End If
  43.         My.Settings.History = txtInput.Text
  44.         My.Settings.Code = txtInput.Text
  45.     End Sub
  46.     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  47.         Dim ofd As New OpenFileDialog
  48.         ofd.Title = "Select File To Run"
  49.         ofd.Filter = "(*.phOS)|*.phOS"
  50.         Dim fl As String
  51.         ofd.ShowDialog()
  52.         fl = ofd.FileName
  53.         If fl <> Nothing Then
  54.             Dim sr As New StreamReader(fl)
  55.             txtInput.Text = sr.ReadToEnd
  56.             sr.Close()
  57.             openedFile = fl
  58.         End If
  59.         Timer1.Start()
  60.         Dim newForm As New Form
  61.         Dim newLabel As New Label
  62.         Dim createdForm As New Form
  63.         txtCode.Items.Clear()
  64.         txtCode.Items.AddRange(txtInput.Lines)
  65.         My.Settings.History = txtInput.Text
  66.         For u = 0 To txtCode.Items.Count - 1
  67.             Dim userCode As String = txtCode.Items.Item(u)
  68.             Dim input() As String = Split(userCode)
  69.             Dim newSize1 As Integer
  70.             Dim newSize2 As Integer
  71.             If input(0) = "m->" Then
  72.                 newForm.MaximizeBox = False
  73.                 newForm.StartPosition = FormStartPosition.CenterScreen
  74.                 newForm.Text = input(1) & "*" & input(2)
  75.                 newForm.Show()
  76.                 newForm.Controls.Add(newLabel)
  77.                 newLabel.AutoSize = False
  78.                 newLabel.Size = New Size(260, 243)
  79.                 With newLabel
  80.                     .Font = New Font("Consolas", 11)
  81.                 End With
  82.                 Convert.ToDouble(input(1))
  83.                 Convert.ToDouble(input(2))
  84.                 Dim i As Integer = input(1) * input(2)
  85.                 newLabel.Text = input(1) & " * " & input(2) & " = " & i
  86.                 works = True
  87.                 My.Settings.Works = True
  88.             ElseIf input(0) = "newForm.button.add" Then
  89.                 currentForm.Controls.Add(createdButton)
  90.                 Dim buttonX As Integer = input(1)
  91.                 Dim buttonY As Integer = input(2)
  92.                 Dim locationX As Integer = input(3)
  93.                 Dim locationY As Integer = input(4)
  94.                 createdButton.Location = New Point(locationX, locationY)
  95.                 createdButton.Size = New Size(buttonX, buttonY)
  96.                 createdButton.Size = New Size(100, 100)
  97.             ElseIf input(0) = "newForm.startPos.center" Then
  98.                 currentForm.StartPosition = FormStartPosition.CenterScreen
  99.             ElseIf input(0) = "newForm.startPos.manual" Then
  100.                 currentForm.StartPosition = FormStartPosition.Manual
  101.             ElseIf input(0) = "newForm.startPos.centerParent" Then
  102.                 currentForm.StartPosition = FormStartPosition.CenterParent
  103.             ElseIf input(0) = "newForm.startPos.defaultBou" Then
  104.                 currentForm.StartPosition = FormStartPosition.WindowsDefaultBounds
  105.             ElseIf input(0) = "newForm.startPos.defaultLoc" Then
  106.                 currentForm.StartPosition = FormStartPosition.WindowsDefaultLocation
  107.             ElseIf input(0) = "output:" Then
  108.                 Dim x As Integer
  109.                 For Each a As String In txtInput.Text
  110.                     If txtInput.Text.Contains(" ") Then
  111.                         x += 1
  112.                     End If
  113.                     Try
  114.                         currentForm.Controls.Add(newLabel)
  115.                         newLabel.Text = newLabel.Text & " " & input(x)
  116.                         newLabel.AutoSize = False
  117.                         newLabel.Size = New Size(260, 243)
  118.                     Catch ex As Exception
  119.  
  120.                     End Try
  121.                 Next
  122.                 x = 0
  123.                 works = True
  124.                 My.Settings.Works = True
  125.             ElseIf input(0) = "newForm.create" Then
  126.                 currentForm = createdForm
  127.                 works = True
  128.                 My.Settings.Works = True
  129.             ElseIf input(0) = "newForm.size" Then
  130.                 newSize1 = input(1)
  131.                 newSize2 = input(2)
  132.                 works = True
  133.                 My.Settings.Works = True
  134.                 currentForm.Size = New Size(newSize1, newSize2)
  135.             ElseIf input(0) = "newForm.show" Then
  136.                 currentForm = createdForm
  137.                 currentForm.Show()
  138.                 newSize1 = 0
  139.                 newSize2 = 0
  140.                 works = True
  141.                 AddHandler currentForm.FormClosed, AddressOf currentForm_Closing
  142.                 Me.Hide()
  143.                 My.Settings.Works = True
  144.             ElseIf input(0) = "newForm.button.text" Then
  145.                 Dim x As Integer
  146.                 For Each a As String In txtInput.Text
  147.                     If txtInput.Text.Contains(" ") Then
  148.                         x += 1
  149.                     End If
  150.                     Try
  151.                         createdButton.Text = input(x)
  152.                     Catch ex As Exception
  153.  
  154.                     End Try
  155.                 Next
  156.                 works = True
  157.                 My.Settings.Works = True
  158.             ElseIf input(0) = "button_clickEvent" Then
  159.                 AddHandler createdButton.Click, AddressOf createdButton_Click
  160.                 works = True
  161.                 My.Settings.Works = True
  162.             Else
  163.                 If input(0) <> "labelOutput:" Then
  164.                     txtCode.Items.Add("!Error somewhere in yor program!")
  165.                     txtCode.Items.Add(" ")
  166.                     txtCode.Items.Add(" ")
  167.                     txtCode.Items.Add(" ")
  168.                     txtCode.Items.Remove("!Error somewhere in yor program!")
  169.                     txtCode.Items.Remove(" ")
  170.                     txtCode.Items.Remove(" ")
  171.                     txtCode.Items.Remove(" ")
  172.                     works = False
  173.                     My.Settings.Works = False
  174.                 End If
  175.             End If
  176.         Next
  177.         If works = True Then
  178.             Label2.Text = "No Errors Found"
  179.             Label2.BackColor = Color.Lime
  180.         Else
  181.             Label2.Text = "!Errors Have Been Found!"
  182.             Label2.BackColor = Color.Red
  183.         End If
  184.         If works = True Then
  185.             Label2.Text = "No Errors Found"
  186.             Label2.BackColor = Color.Lime
  187.         Else
  188.             Label2.Text = "!Errors Have Been Found!"
  189.             Label2.BackColor = Color.Red
  190.         End If
  191.         If My.Settings.Works = True Then
  192.             works = True
  193.         Else
  194.             works = False
  195.         End If
  196.     End Sub
  197.  
  198.     Private Sub txtInput_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles txtInput.KeyDown
  199.         If e.KeyCode = Keys.F5 Then
  200.             RunToolStripMenuItem.PerformClick()
  201.         ElseIf e.KeyCode = Keys.F6 Then
  202.             SaveToolStripMenuItem.PerformClick()
  203.         ElseIf e.KeyCode = Keys.F7 Then
  204.             OpenToolStripMenuItem.PerformClick()
  205.         End If
  206.     End Sub
  207.  
  208.     Private Sub SaveToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SaveToolStripMenuItem.Click
  209.         Dim SFD As New SaveFileDialog
  210.         SFD.Title = "phOS Save .txt File"
  211.         Dim SV As String
  212.         SFD.Filter = "(*.phOS)|*.phOS"
  213.         If openedFile <> Nothing Then
  214.             SFD.FileName = openedFile
  215.         End If
  216.         SFD.ShowDialog()
  217.         SV = SFD.FileName
  218.         If txtInput.Text <> Nothing And SV <> Nothing Then
  219.             Dim sw As New StreamWriter(SV)
  220.             sw.Write(txtInput.Text)
  221.             sw.Close()
  222.             openedFile = SV
  223.             MsgBox("File saved to " & SV, MsgBoxStyle.Information, "Success")
  224.         End If
  225.         Application.Restart()
  226.     End Sub
  227.  
  228.     Private Sub OpenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles OpenToolStripMenuItem.Click
  229.         Dim ofd As New OpenFileDialog
  230.         ofd.Title = "Select File To Run"
  231.         ofd.Filter = "(*.phOS)|*.phOS"
  232.         Dim fl As String
  233.         ofd.ShowDialog()
  234.         fl = ofd.FileName
  235.         If fl <> Nothing Then
  236.             Dim sr As New StreamReader(fl)
  237.             txtInput.Text = sr.ReadToEnd
  238.             sr.Close()
  239.             openedFile = fl
  240.         End If
  241.     End Sub
  242.  
  243.     Private Sub txtInput_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtInput.TextChanged
  244.         For Each s As String In txtInput.Text
  245.             If s = "create" Then
  246.  
  247.             End If
  248.         Next
  249.     End Sub
  250.  
  251.     Sub currentForm_Closing()
  252.         Application.Exit()
  253.     End Sub
  254.  
  255.     Private Sub HistoryToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles HistoryToolStripMenuItem.Click
  256.         frmHistory.Show()
  257.     End Sub
  258.  
  259.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  260.         Me.Hide()
  261.     End Sub
  262.  
  263.     Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
  264.         Timer2.Start()
  265.     End Sub
  266.  
  267.     Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
  268.         Timer1.Stop()
  269.         Me.Hide()
  270.     End Sub
  271.  
  272.     Private Sub Timer3_Tick(sender As System.Object, e As System.EventArgs) Handles Timer3.Tick
  273.         Timer4.Start()
  274.     End Sub
  275.  
  276.     Private Sub Timer4_Tick(sender As System.Object, e As System.EventArgs) Handles Timer4.Tick
  277.         Timer3.Stop()
  278.         currentForm.Select()
  279.     End Sub
  280. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement