📄 mainform.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Threading;
using System.Diagnostics;
using Microsoft.VisualBasic;
namespace Editor
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem mnuFile;
private System.Windows.Forms.MenuItem mnuEdit;
private System.Windows.Forms.MenuItem mnuView;
private System.Windows.Forms.MenuItem mnuFileOpen;
private System.Windows.Forms.MenuItem mnuFileSave;
private System.Windows.Forms.MenuItem mnuFileSaveAs;
private System.Windows.Forms.MenuItem mnuFileNew;
private System.Windows.Forms.MenuItem mnuFileExit;
private System.Windows.Forms.MenuItem mnuEditCut;
private System.Windows.Forms.MenuItem mnuEditCopy;
private System.Windows.Forms.MenuItem mnuEditPaste;
private System.Windows.Forms.MenuItem mnuViewStatusBar;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.MenuItem mnuViewToolbar;
private System.Windows.Forms.ToolBarButton tbFileNew;
private System.Windows.Forms.ToolBarButton tbFileOpen;
private System.Windows.Forms.ToolBarButton tbFileSave;
private System.Windows.Forms.ToolBarButton tbAbout;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem cmnuFileOpen;
private System.Windows.Forms.MenuItem cmnuFileSave;
private System.Windows.Forms.MenuItem cmnuEditCut;
private System.Windows.Forms.MenuItem cmnuEditCopy;
private System.Windows.Forms.MenuItem cmnuEditPaste;
private System.Windows.Forms.MenuItem dmnuFileNew;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.ColorDialog colorDialog1;
private System.Windows.Forms.FontDialog fontDialog1;
private System.Windows.Forms.MenuItem mnuFormatSetFont;
private System.Windows.Forms.MenuItem mnuFormatSetTextColor;
private System.Windows.Forms.MenuItem mnuFormatSetBackgroundColor;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1;
private System.Drawing.Printing.PrintDocument printDocument1;
private System.Drawing.Printing.PrintDocument printDocument2;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.ToolBarButton tbDir;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.mnuFile = new System.Windows.Forms.MenuItem();
this.mnuFileNew = new System.Windows.Forms.MenuItem();
this.mnuFileOpen = new System.Windows.Forms.MenuItem();
this.mnuFileSave = new System.Windows.Forms.MenuItem();
this.mnuFileSaveAs = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.mnuFileExit = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.tbFileNew = new System.Windows.Forms.ToolBarButton();
this.mnuEditCopy = new System.Windows.Forms.MenuItem();
this.cmnuEditPaste = new System.Windows.Forms.MenuItem();
this.mnuFormatSetTextColor = new System.Windows.Forms.MenuItem();
this.mnuViewStatusBar = new System.Windows.Forms.MenuItem();
this.fontDialog1 = new System.Windows.Forms.FontDialog();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.cmnuFileOpen = new System.Windows.Forms.MenuItem();
this.mnuFormatSetBackgroundColor = new System.Windows.Forms.MenuItem();
this.dmnuFileNew = new System.Windows.Forms.MenuItem();
this.mnuEditCut = new System.Windows.Forms.MenuItem();
this.mnuEditPaste = new System.Windows.Forms.MenuItem();
this.mnuEdit = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.mnuViewToolbar = new System.Windows.Forms.MenuItem();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.tbFileOpen = new System.Windows.Forms.ToolBarButton();
this.tbFileSave = new System.Windows.Forms.ToolBarButton();
this.tbAbout = new System.Windows.Forms.ToolBarButton();
this.textBox1 = new System.Windows.Forms.TextBox();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.cmnuFileSave = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.cmnuEditCut = new System.Windows.Forms.MenuItem();
this.cmnuEditCopy = new System.Windows.Forms.MenuItem();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.mnuView = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.mnuFormatSetFont = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
this.printDocument1 = new System.Drawing.Printing.PrintDocument();
this.printDocument2 = new System.Drawing.Printing.PrintDocument();
this.tbDir = new System.Windows.Forms.ToolBarButton();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.SuspendLayout();
//
// mnuFile
//
this.mnuFile.Index = 0;
this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFileNew,
this.mnuFileOpen,
this.mnuFileSave,
this.mnuFileSaveAs,
this.menuItem1,
this.mnuFileExit,
this.menuItem6,
this.menuItem7,
this.menuItem8,
this.menuItem10});
this.mnuFile.Text = "&File";
//
// mnuFileNew
//
this.mnuFileNew.Index = 0;
this.mnuFileNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
this.mnuFileNew.Text = "New";
this.mnuFileNew.Click += new System.EventHandler(this.mnuFileNew_Click);
//
// mnuFileOpen
//
this.mnuFileOpen.Index = 1;
this.mnuFileOpen.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
this.mnuFileOpen.Text = "Open";
this.mnuFileOpen.Click += new System.EventHandler(this.mnuFileOpen_Click);
//
// mnuFileSave
//
this.mnuFileSave.Index = 2;
this.mnuFileSave.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
this.mnuFileSave.Text = "Save";
this.mnuFileSave.Click += new System.EventHandler(this.mnuFileSave_Click);
//
// mnuFileSaveAs
//
this.mnuFileSaveAs.Index = 3;
this.mnuFileSaveAs.Text = "Save As";
this.mnuFileSaveAs.Click += new System.EventHandler(this.mnuFileSaveAs_Click);
//
// menuItem1
//
this.menuItem1.Index = 4;
this.menuItem1.Text = "-";
//
// mnuFileExit
//
this.mnuFileExit.Index = 5;
this.mnuFileExit.Text = "Exit";
this.mnuFileExit.Click += new System.EventHandler(this.mnuFileExit_Click);
//
// menuItem6
//
this.menuItem6.Index = 6;
this.menuItem6.Text = "print view";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 7;
this.menuItem7.Text = "print";
//
// menuItem8
//
this.menuItem8.Index = 8;
this.menuItem8.Text = "note";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// tbFileNew
//
this.tbFileNew.ImageIndex = 0;
this.tbFileNew.Text = "New";
this.tbFileNew.ToolTipText = "Create a new text file";
//
// mnuEditCopy
//
this.mnuEditCopy.Index = 1;
this.mnuEditCopy.Text = "Copy";
this.mnuEditCopy.Click += new System.EventHandler(this.mnuEditCopy_Click);
//
// cmnuEditPaste
//
this.cmnuEditPaste.Index = 6;
this.cmnuEditPaste.Text = "Paste";
this.cmnuEditPaste.Click += new System.EventHandler(this.mnuEditPaste_Click);
//
// mnuFormatSetTextColor
//
this.mnuFormatSetTextColor.Index = 0;
this.mnuFormatSetTextColor.Text = "Set Text Color";
this.mnuFormatSetTextColor.Click += new System.EventHandler(this.mnuFormatSetTextColor_Click);
//
// mnuViewStatusBar
//
this.mnuViewStatusBar.Checked = true;
this.mnuViewStatusBar.Index = 0;
this.mnuViewStatusBar.Text = "Status Bar";
this.mnuViewStatusBar.Click += new System.EventHandler(this.mnuViewStatusBar_Click);
//
// fontDialog1
//
this.fontDialog1.FontMustExist = true;
this.fontDialog1.ScriptsOnly = true;
this.fontDialog1.ShowApply = true;
this.fontDialog1.ShowColor = true;
this.fontDialog1.Apply += new System.EventHandler(this.fontDialog1_OnApply);
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 411);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(776, 22);
this.statusBar1.TabIndex = 2;
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// cmnuFileOpen
//
this.cmnuFileOpen.Index = 1;
this.cmnuFileOpen.Text = "Open";
this.cmnuFileOpen.Click += new System.EventHandler(this.mnuFileOpen_Click);
//
// mnuFormatSetBackgroundColor
//
this.mnuFormatSetBackgroundColor.Index = 1;
this.mnuFormatSetBackgroundColor.Text = "Set Background Color";
this.mnuFormatSetBackgroundColor.Click += new System.EventHandler(this.mnuFormatSetBackgroundColor_Click);
//
// dmnuFileNew
//
this.dmnuFileNew.Index = 0;
this.dmnuFileNew.Text = "New";
//
// mnuEditCut
//
this.mnuEditCut.Index = 0;
this.mnuEditCut.Text = "Cut";
this.mnuEditCut.Click += new System.EventHandler(this.mnuEditCut_Click);
//
// mnuEditPaste
//
this.mnuEditPaste.Index = 2;
this.mnuEditPaste.Text = "Paste";
this.mnuEditPaste.Click += new System.EventHandler(this.mnuEditPaste_Click);
//
// mnuEdit
//
this.mnuEdit.Index = 1;
this.mnuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuEditCut,
this.mnuEditCopy,
this.mnuEditPaste,
this.menuItem3,
this.menuItem4});
this.mnuEdit.Text = "&Edit";
//
// menuItem3
//
this.menuItem3.Index = 3;
this.menuItem3.Text = "select All";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Index = 4;
this.menuItem4.Text = "undo";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// mnuViewToolbar
//
this.mnuViewToolbar.Checked = true;
this.mnuViewToolbar.Index = 1;
this.mnuViewToolbar.Text = "Toolbar";
this.mnuViewToolbar.Click += new System.EventHandler(this.mnuViewToolbar_Click);
//
// toolBar1
//
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.tbFileNew,
this.tbFileOpen,
this.tbFileSave,
this.tbAbout,
this.tbDir});
this.toolBar1.ButtonSize = new System.Drawing.Size(60, 36);
this.toolBar1.DropDownArrows = true;
this.toolBar1.ImageList = this.imageList1;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(776, 42);
this.toolBar1.TabIndex = 2;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// tbFileOpen
//
this.tbFileOpen.ImageIndex = 1;
this.tbFileOpen.Text = "Open";
this.tbFileOpen.ToolTipText = "Open an existing text file";
//
// tbFileSave
//
this.tbFileSave.ImageIndex = 2;
this.tbFileSave.Text = "Save";
this.tbFileSave.ToolTipText = "Save the contents in a text file";
//
// tbAbout
//
this.tbAbout.ImageIndex = 3;
this.tbAbout.Text = "About";
this.tbAbout.ToolTipText = "Information on the text editor";
//
// textBox1
//
this.textBox1.ContextMenu = this.contextMenu1;
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.textBox1.Location = new System.Drawing.Point(0, 42);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBox1.Size = new System.Drawing.Size(776, 369);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// contextMenu1
//
this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.dmnuFileNew,
this.cmnuFileOpen,
this.cmnuFileSave,
this.menuItem5,
this.cmnuEditCut,
this.cmnuEditCopy,
this.cmnuEditPaste});
//
// cmnuFileSave
//
this.cmnuFileSave.Index = 2;
this.cmnuFileSave.Text = "Save";
this.cmnuFileSave.Click += new System.EventHandler(this.mnuFileSave_Click);
//
// menuItem5
//
this.menuItem5.Index = 3;
this.menuItem5.Text = "-";
//
// cmnuEditCut
//
this.cmnuEditCut.Index = 4;
this.cmnuEditCut.Text = "Cut";
this.cmnuEditCut.Click += new System.EventHandler(this.mnuEditCut_Click);
//
// cmnuEditCopy
//
this.cmnuEditCopy.Index = 5;
this.cmnuEditCopy.Text = "Copy";
this.cmnuEditCopy.Click += new System.EventHandler(this.mnuEditCopy_Click);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFile,
this.mnuEdit,
this.mnuView,
this.menuItem2,
this.menuItem9});
//
// mnuView
//
this.mnuView.Index = 2;
this.mnuView.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuViewStatusBar,
this.mnuViewToolbar});
this.mnuView.RadioCheck = true;
this.mnuView.Text = "&View";
//
// menuItem2
//
this.menuItem2.Index = 3;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFormatSetTextColor,
this.mnuFormatSetBackgroundColor,
this.mnuFormatSetFont});
this.menuItem2.Text = "Format";
//
// mnuFormatSetFont
//
this.mnuFormatSetFont.Index = 2;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -