The complete source code of the WorkPad project is provided here.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Notpad
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
//MessageBox.Show("open the file");
OpenFileDialog chetan = new OpenFileDialog();
chetan.Title = "Open";
chetan.Filter = "Text Document(*.txt)|*.txt|All Files(*.*)|*.*";
if (chetan.ShowDialog() == DialogResult.OK)
richTextBox1.LoadFile(chetan.FileName, RichTextBoxStreamType.PlainText);
this.Text = chetan.FileName;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
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 selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectAll();
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("This is a simple notdpad");
}
private void toolStripMenuItem3_Click(object sender, EventArgs e)
{
SaveFileDialog chetan = new SaveFileDialog();
chetan.Title = "Save";
chetan.Filter = "Text Document(*.txt)|*.txt|All Files(*.*)|*.*";
if (chetan.ShowDialog() == DialogResult.OK)
richTextBox1.SaveFile(chetan.FileName, RichTextBoxStreamType.PlainText);
this.Text = chetan.FileName;
}
private void fileToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void colorToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog fnt = new ColorDialog();
if (fnt.ShowDialog() == DialogResult.OK)
richTextBox1.ForeColor = fnt.Color;
}
private void textToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog fnt = new FontDialog();
if (fnt.ShowDialog() == DialogResult.OK)
richTextBox1.Font = fnt.Font;
}
}
}