namespace NotepadTutorial
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
if (op.ShowDialog() == DialogResult.OK)
richTextBox1.LoadFile(op.FileName, RichTextBoxStreamType.PlainText);
this.Text = op.FileName;
}
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sv = new SaveFileDialog();
sv.Filter = "Text Document(*.txt)|*.txt|All Files(*.*)|*.*";
if (sv.ShowDialog() == DialogResult.OK)
richTextBox1.SaveFile(sv.FileName, RichTextBoxStreamType.PlainText);
this.Text = sv.FileName;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Undo();
}
private void redoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Redo();
}
private void fontToolStripMenuItem1_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
fd.Font = richTextBox1.SelectionFont;
if (fd.ShowDialog() == DialogResult.OK)
richTextBox1.SelectionFont = fd.Font;
}
private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog cr = new ColorDialog();
if (cr.ShowDialog() == DialogResult.OK)
richTextBox1.BackColor = cr.Color;
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Ver 1.0.0\nCreated by Zoloo");
}
}
}
Result:
No comments:
Post a Comment