Advance Notepad
// Form1.cs //
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
Now Add one MenuStrip from Toolbox and name it as a following.
1-File > Open >Save>Exit
2-Settings > Font Setting > Fore Color > Background Color
3-Zoom in
4-Zoom out
5-Clear
6-About
Now follow these Steps.
// Step 1- Go to Menu Strip1- File > Open and copy the following code//
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
Stream stm;
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if ((stm = ofd.OpenFile()) != null)
{
string str = ofd.FileName;
string ftxt = File.ReadAllText(str);
richTextBox1.Text = ftxt;
}
}
}
// Step 2- // File > Save //
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Text file (*.txt)|*.txt|C# file (*.cs)|*.cs";
sfd.ShowDialog();
File.WriteAllText(sfd.FileName, richTextBox1.Text);
MessageBox.Show("Text File saved");
}
// Step 3-File > Exit //
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
// Step 4- Settings > Font Settings //
private void fontStyleToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog dlg = new FontDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
string fontName;
float fontSize;
fontName = dlg.Font.Name;
fontSize = dlg.Font.Size;
richTextBox1.Font = dlg.Font;
}
}
// Step 5 -Fore color//
//Fore Color > Red//
private void rEDToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Red;
}
// Fore Color > Green//
private void gREENToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Green;
}
//Fore Color > Blue//
private void bLUEToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Blue;
}
//Fore Color > Orange//
private void oRANGEToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Orange;
}
//Fore Color > Aqua//
private void aQUAToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Aqua;
}
//Fore Color > Black//
private void bLACKToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Black;
}
//Fore Color >Yellow//
private void yellowToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Yellow;
}
//Step 6-Background Color//
// Black//
private void blackToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.BackColor = Color.Black;
}
// Blue //
private void blueToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.BackColor = Color.Blue;
}
// White //
private void whiteToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.BackColor = Color.White;
}
// Step 7- Zoom in//
private void viewToolStripMenuItem_Click(object sender, EventArgs e)
{
float currentSize;
currentSize = richTextBox1.Font.Size;
currentSize += 2.0F;
richTextBox1.Font = new Font(richTextBox1.Font.Name, currentSize,
richTextBox1.Font.Style, richTextBox1.Font.Unit);
}
// Step 8- Zoom out//
private void viewToolStripMenuItem_Click(object sender, EventArgs e)
{
float currentSize;
currentSize = richTextBox1.Font.Size;
currentSize -= 2.0F;
richTextBox1.Font = new Font(richTextBox1.Font.Name, currentSize,
richTextBox1.Font.Style, richTextBox1.Font.Unit);
}
// Step 9- Clear //
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
}
// Step 10- About//
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Notepad 1.0_2019 developed by Rohit Tirkey");
}
To create Advance Notepad in c# visual studio
First open > visual studio > File >New > Project > New Project > C#
and then select WindowFormsApp and press ok .
After this go to the Form1.cs and copy the following Yellow highlighted codes.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
Now Add one MenuStrip from Toolbox and name it as a following.
1-File > Open >Save>Exit
2-Settings > Font Setting > Fore Color > Background Color
3-Zoom in
4-Zoom out
5-Clear
6-About
Now follow these Steps.
// Step 1- Go to Menu Strip1- File > Open and copy the following code//
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
Stream stm;
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if ((stm = ofd.OpenFile()) != null)
{
string str = ofd.FileName;
string ftxt = File.ReadAllText(str);
richTextBox1.Text = ftxt;
}
}
}
// Step 2- // File > Save //
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Text file (*.txt)|*.txt|C# file (*.cs)|*.cs";
sfd.ShowDialog();
File.WriteAllText(sfd.FileName, richTextBox1.Text);
MessageBox.Show("Text File saved");
}
// Step 3-File > Exit //
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
// Step 4- Settings > Font Settings //
private void fontStyleToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog dlg = new FontDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
string fontName;
float fontSize;
fontName = dlg.Font.Name;
fontSize = dlg.Font.Size;
richTextBox1.Font = dlg.Font;
}
}
// Step 5 -Fore color//
//Fore Color > Red//
private void rEDToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Red;
}
// Fore Color > Green//
private void gREENToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Green;
}
//Fore Color > Blue//
private void bLUEToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Blue;
}
//Fore Color > Orange//
private void oRANGEToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Orange;
}
//Fore Color > Aqua//
private void aQUAToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Aqua;
}
//Fore Color > Black//
private void bLACKToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Black;
}
//Fore Color >Yellow//
private void yellowToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.ForeColor = Color.Yellow;
}
//Step 6-Background Color//
// Black//
private void blackToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.BackColor = Color.Black;
}
// Blue //
private void blueToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.BackColor = Color.Blue;
}
// White //
private void whiteToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.BackColor = Color.White;
}
// Step 7- Zoom in//
private void viewToolStripMenuItem_Click(object sender, EventArgs e)
{
float currentSize;
currentSize = richTextBox1.Font.Size;
currentSize += 2.0F;
richTextBox1.Font = new Font(richTextBox1.Font.Name, currentSize,
richTextBox1.Font.Style, richTextBox1.Font.Unit);
}
// Step 8- Zoom out//
private void viewToolStripMenuItem_Click(object sender, EventArgs e)
{
float currentSize;
currentSize = richTextBox1.Font.Size;
currentSize -= 2.0F;
richTextBox1.Font = new Font(richTextBox1.Font.Name, currentSize,
richTextBox1.Font.Style, richTextBox1.Font.Unit);
}
// Step 9- Clear //
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
}
// Step 10- About//
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Notepad 1.0_2019 developed by Rohit Tirkey");
}
No comments:
Post a Comment