private void button1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(textBox1.Text)) { if (!textBox1.Text.Equals(x)) { // text = textBox1.Text; txtbf txt = new txtbf(textBox1.Text); txt.Name = textBox1.Text; //txt.ParentForm = this; txt.MdiParent = this.ParentForm; // txt.Owner = this; //txt.Show(this); txt.Visible = true; this.Hide(); } } else { textBox1.Text = "Please Enter a filename"; this.Show(); button2.Show(); button2.Visible = true; button2.CreateControl(); button2.CreateGraphics(); x = textBox1.Text; } }
private void tokeniseToolStripMenuItem_Click(object sender, EventArgs e) { listView1.Items.Clear(); txtbf current = (txtbf)this.ActiveMdiChild; if (current != null) { if (!string.IsNullOrEmpty(current.store)) { string x = current.store; // MessageBox.Show(x); scan = new scanner(x.ToCharArray()); } for (int i = 0; i < scan.er.Count; i++) { ListViewItem list = new ListViewItem(scan.er[i].ln); list.SubItems.Add(scan.er[i].error); this.listView1.Items.Add(list); this.listView1.GridLines = true; this.listView1.CreateGraphics(); } } else { statusStrip1.Text = "No active file"; ListViewItem list = new ListViewItem("error"); list.SubItems.Add("No active file"); this.listView1.Items.Add(list); this.listView1.GridLines = true; this.listView1.CreateGraphics(); } }
private void execuToolStripMenuItem_Click(object sender, EventArgs e) { // MessageBox.Show(pars.errors.Count.ToString()); if (pars.errors.Count != 0) { MessageBox.Show("Fix Errors First"); } else { txtbf x = (txtbf)this.ActiveMdiChild; if (x != null) //if( { saveFileDialog1.Filter = "Text Files (*.txt|*.txt"; DialogResult result = saveFileDialog1.ShowDialog(); //string filename; saveFileDialog1.CheckFileExists = false; if (result == DialogResult.Cancel) { return; } filename = saveFileDialog1.FileName; //gets the file name object obj = x.store; byte[] b = new byte[100]; output = new FileStream(Path.GetFullPath(filename), FileMode.Create); //gets the path and creates the file output.Close(); MessageBox.Show("Created Successfully"); string[] arr = new string[1]; arr[0] = x.store; //stores the input text in string arr[0] System.IO.File.WriteAllLines(Path.GetFullPath(filename), arr); //writes the text of textbox into notepad // MessageBox.Show("added successfully"); // MessageBox.Show(Path.GetFullPath(filename).ToString()); CodeGen codeGen = new CodeGen(pars.Result, Path.GetFileNameWithoutExtension(filename) + ".exe", pars.counts); // codegen method call } else { listView1.Items.Clear(); statusStrip1.Text = "No active file"; ListViewItem list = new ListViewItem("error"); list.SubItems.Add("No active file"); this.listView1.Items.Add(list); this.listView1.GridLines = true; this.listView1.CreateGraphics(); } } }
private void openToolStripButton_Click(object sender, EventArgs e) { //openFileDialog1.ShowDialog(this); openFileDialog1.Filter = "Text Files|*.txt; *.text; *.doc|All Files|*.*"; openFileDialog1.AddExtension = true; openFileDialog1.InitialDirectory = "C:\\"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { string txtfromfile = openfile(openFileDialog1.FileName); txtbf txt = new txtbf(openFileDialog1.FileName); //txt.Name=openFileDialog1.FileName; txt.store = txtfromfile; txt.MdiParent = this; txt.Visible = true; statusStrip1.Text = "File Opened: " + openFileDialog1.FileName; } else { statusStrip1.Text = "Unable to Open File"; } }
private void savefile() { txtbf txt = (txtbf)this.ActiveMdiChild; if (txt != null) { statusStrip1.Text = "Saving File: " + txt.Text; saveFileDialog1.FileName = txt.Text; saveFileDialog1.InitialDirectory = "C:\\"; saveFileDialog1.Filter = "Text Files|*.txt; *.text; *.doc|All Files|*.*"; saveFileDialog1.AddExtension = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { FileInfo n = new FileInfo(saveFileDialog1.FileName); StreamWriter save = n.CreateText(); save.Write(txt.store); save.Close(); } } else { statusStrip1.Text = "No active file"; } }