using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; // Custom added using System.Text.RegularExpressions; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); commonbox.Items.Add(""); commonbox.Items.Add(""); } public Regex keyWords = new Regex(""); private void Form1_Load(object sender, EventArgs e) { Form2 form2 = new Form2(); form2.Show(); } // Menu - File private void newToolStripMenuItem_Click(object sender, EventArgs e) { richTextBox1.Text = ""; } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { saveFileDialog1.InitialDirectory = "C:"; saveFileDialog1.FileName = ""; saveFileDialog1.Title = "Save an HTML file..."; saveFileDialog1.Filter = ".html|HTML File"; string savedfile = ""; if (saveFileDialog1.ShowDialog() != DialogResult.Cancel) { savedfile = saveFileDialog1.FileName; richTextBox1.SaveFile(savedfile + ".html", RichTextBoxStreamType.PlainText); StatusLabel.Text = "File saved as " + savedfile; } } private void loadToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = "C:"; openFileDialog1.FileName = ""; openFileDialog1.Title = "Open an HTML file..."; string openedfile = ""; if (openFileDialog1.ShowDialog() != DialogResult.Cancel) { openedfile = openFileDialog1.FileName; richTextBox1.LoadFile(openedfile, RichTextBoxStreamType.PlainText); StatusLabel.Text = "File opened: " + openedfile; } } // Menu - Edit private void cutToolStripMenuItem_Click(object sender, EventArgs e) { richTextBox1.Cut(); StatusLabel.Text = "Cut"; } private void copyToolStripMenuItem_Click(object sender, EventArgs e) { richTextBox1.Copy(); StatusLabel.Text = "Copied"; } private void pasteToolStripMenuItem_Click_1(object sender, EventArgs e) { richTextBox1.Paste(); StatusLabel.Text = "Pasted"; } // Menu - Insert private void hTMLToolStripMenuItem_Click(object sender, EventArgs e) { richTextBox1.SelectedText = ""; richTextBox1.SelectedText = System.Environment.NewLine; richTextBox1.SelectedText = ""; StatusLabel.Text = "Adding HTML tags.."; } private void bodyToolStripMenuItem_Click(object sender, EventArgs e) { richTextBox1.SelectedText = ""; richTextBox1.SelectedText = System.Environment.NewLine; richTextBox1.SelectedText = ""; StatusLabel.Text = "Adding body tags.."; } // Menu - Help private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("HTML Artist 2 - © James Plant 2011" + System.Environment.NewLine + "Uses Tango icon set"); } // Toolbar private void newbutton_Click(object sender, EventArgs e) { richTextBox1.Text = ""; } private void savebutton_Click(object sender, EventArgs e) { saveFileDialog1.InitialDirectory = "C:"; saveFileDialog1.FileName = ""; saveFileDialog1.Title = "Save an HTML file..."; saveFileDialog1.Filter = ".html|HTML File"; string savedfile = ""; if (saveFileDialog1.ShowDialog() != DialogResult.Cancel) { savedfile = saveFileDialog1.FileName; richTextBox1.SaveFile(savedfile + ".html", RichTextBoxStreamType.PlainText); StatusLabel.Text = "File saved as " + savedfile; } } private void loadbutton_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = "C:"; openFileDialog1.FileName = ""; openFileDialog1.Title = "Open an HTML file..."; string openedfile = ""; if (openFileDialog1.ShowDialog() != DialogResult.Cancel) { openedfile = openFileDialog1.FileName; richTextBox1.LoadFile(openedfile, RichTextBoxStreamType.PlainText); StatusLabel.Text = "File opened: " + openedfile; } } private void copybarbutton_Click(object sender, EventArgs e) { richTextBox1.Copy(); StatusLabel.Text = "Copied"; } private void cutbarbutton_Click(object sender, EventArgs e) { richTextBox1.Cut(); StatusLabel.Text = "Cut"; } private void pastebarbutton_Click(object sender, EventArgs e) { richTextBox1.Paste(); StatusLabel.Text = "Pasted"; } private void addbutton_Click(object sender, EventArgs e) { // HTML if (commonbox.SelectedIndex == 0) { richTextBox1.SelectedText = ""; richTextBox1.SelectedText = System.Environment.NewLine; richTextBox1.SelectedText = ""; StatusLabel.Text = "Adding HTML tags.."; } // Body if (commonbox.SelectedIndex == 1) { richTextBox1.SelectedText = ""; richTextBox1.SelectedText = System.Environment.NewLine; richTextBox1.SelectedText = ""; StatusLabel.Text = "Adding Body tags.."; } } // Timer ticks private void timer1_Tick(object sender, EventArgs e) { } private void richTextBox1_TextChanged(object sender, EventArgs e) { } } }