Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- namespace TextEditor
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void toolStripSeparator1_Click(object sender, EventArgs e)
- {
- }
- private void newToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Clear();
- }
- private void exitToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (MessageBox.Show("Желаете ли изход от приложението?", "Потвърждение за изход!"
- , MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- this.Close();
- else
- MessageBox.Show("Това е текстов редактор, създаден от Любен!");
- }
- private void openToolStripMenuItem_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Text Files(.txt)|*.txt";
- ofd.Title = "Open a file...";
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName);
- richTextBox1.Text = sr.ReadToEnd();
- sr.Close();
- }
- }
- private void saveToolStripMenuItem_Click(object sender, EventArgs e)
- {
- SaveFileDialog svf = new SaveFileDialog();
- svf.Filter = "Text Files(.txt)|*.txt";
- svf.Title = "Save file...";
- if (svf.ShowDialog() == DialogResult.OK)
- {
- System.IO.StreamWriter sw = new System.IO.StreamWriter(svf.FileName);
- sw.Write(richTextBox1.Text);
- sw.Close();
- }
- }
- private void undoToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Undo();
- }
- private void redoToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Redo();
- }
- private void cutToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Cut();
- }
- private void copyToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Copy();
- }
- private void toolStripSeparator4_Click(object sender, EventArgs e)
- {
- }
- private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Paste();
- }
- private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.SelectAll();
- }
- private void openToolStripMenuItem_Click_1(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Text Files(.txt)|*.txt";
- ofd.Title = "Open a file...";
- if (ofd.ShowDialog() == DialogResult.OK)
- {
- System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName);
- richTextBox1.Text = sr.ReadToEnd();
- sr.Close();
- }
- }
- private void fontTypeToolStripMenuItem_Click(object sender, EventArgs e)
- {
- FontDialog dlg = new FontDialog();
- if (dlg.ShowDialog()== DialogResult.OK)
- {
- richTextBox1.Font = dlg.Font;
- }
- }
- private void fontColorToolStripMenuItem_Click(object sender, EventArgs e)
- {
- ColorDialog dlg = new ColorDialog();
- if (dlg.ShowDialog() == DialogResult.OK)
- {
- richTextBox1.ForeColor = dlg.Color;
- }
- }
- private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
- {
- SaveFileDialog svf = new SaveFileDialog();
- svf.Filter = "Text Files(.txt)|*.txt";
- svf.Title = "Save file...";
- if (svf.ShowDialog() == DialogResult.OK)
- {
- System.IO.StreamWriter sw = new System.IO.StreamWriter(svf.FileName);
- sw.Write(richTextBox1.Text);
- sw.Close();
- }
- }
- private void selectAllToolStripMenuItem_Click_1(object sender, EventArgs e)
- {
- richTextBox1.SelectAll();
- }
- private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
- {
- richTextBox1.Text = "";
- MessageBox.Show("Това е текстов редактор, създаден от Любен!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement