170 lines
5.2 KiB
C#
170 lines
5.2 KiB
C#
using System;
|
|
using System.IO;
|
|
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 NotePad
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
saveFileDialog1.Filter = "Text Files TXT | *.txt";
|
|
saveFileDialog1.ShowDialog();
|
|
string fName = saveFileDialog1.FileName;
|
|
StreamWriter sw = new StreamWriter(fName);
|
|
sw.Write(richTextBox1.Text);
|
|
sw.Flush();
|
|
sw.Close();
|
|
}
|
|
|
|
private void newToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
richTextBox1.Clear();
|
|
}
|
|
|
|
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog dlg = new OpenFileDialog();
|
|
dlg.Title = "Open";
|
|
dlg.ShowDialog(); // displays dialog box
|
|
string fName = dlg.FileName; // file name reader
|
|
StreamReader sr = new StreamReader(fName); //parses content of given text file
|
|
richTextBox1.Text = sr.ReadToEnd();
|
|
sr.Close();
|
|
}
|
|
|
|
private void fontToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void eXITToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
Application.Exit();
|
|
}
|
|
|
|
private void hTMLToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
saveFileDialog1.Filter = "Hyper Text Markup Language HTML | *.html";
|
|
saveFileDialog1.ShowDialog();
|
|
string fName = saveFileDialog1.FileName;
|
|
StreamWriter sw = new StreamWriter(fName);
|
|
sw.Write(richTextBox1.Text);
|
|
sw.Flush();
|
|
sw.Close();
|
|
}
|
|
|
|
private void cToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
saveFileDialog1.Filter = "C File | *.c";
|
|
saveFileDialog1.ShowDialog();
|
|
string fName = saveFileDialog1.FileName;
|
|
StreamWriter sw = new StreamWriter(fName);
|
|
sw.Write(richTextBox1.Text);
|
|
sw.Flush();
|
|
sw.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 jAVAToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
saveFileDialog1.Filter = "C File | *.c";
|
|
saveFileDialog1.ShowDialog();
|
|
string fName = saveFileDialog1.FileName;
|
|
StreamWriter sw = new StreamWriter(fName);
|
|
sw.Write(richTextBox1.Text);
|
|
sw.Flush();
|
|
sw.Close();
|
|
}
|
|
|
|
private void fontToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
{
|
|
FontDialog fd = new FontDialog();
|
|
fd.Font = richTextBox1.SelectionFont;
|
|
fd.Color = richTextBox1.SelectionColor;
|
|
if (fd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
richTextBox1.SelectionFont = fd.Font;
|
|
richTextBox1.SelectionColor = fd.Color;
|
|
}
|
|
}
|
|
|
|
private void colorToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
ColorDialog fd = new ColorDialog();
|
|
fd.Color = richTextBox1.SelectionColor;
|
|
if (fd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
richTextBox1.SelectionColor = fd.Color;
|
|
}
|
|
}
|
|
|
|
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
richTextBox1.SelectAll();
|
|
}
|
|
|
|
private void printToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
if (printPreviewDialog1.ShowDialog() == DialogResult.OK)
|
|
{
|
|
printDocument1.Print();
|
|
}
|
|
}
|
|
|
|
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
|
|
{
|
|
e.Graphics.DrawString(richTextBox1.Text, new Font("Times New Romans", 14), Brushes.Black, new PointF(100, 100));
|
|
}
|
|
|
|
private void darkModeToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
richTextBox1.BackColor = Color.Black;
|
|
richTextBox1.ForeColor = Color.White;
|
|
}
|
|
|
|
private void wordWrapToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
richTextBox1.WordWrap = true;
|
|
}
|
|
|
|
|
|
}
|
|
}
|