⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text.cs

📁 C#做的一个文本编辑器
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;

namespace myTest
{
	/// <summary>
	/// Text 的摘要说明。
	/// </summary>
	public class myText : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem fileMenu;
		private System.Windows.Forms.MenuItem newMenuItem;
		private System.Windows.Forms.MenuItem openMenueItem;
		private System.Windows.Forms.MenuItem saveMenuItem;
		private System.Windows.Forms.MenuItem saveAsMenuItem;
		private System.Windows.Forms.MenuItem printMenuItem;
		private System.Windows.Forms.MenuItem exitMenuItem;
		private System.Windows.Forms.MenuItem editMenu;
		private System.Windows.Forms.MenuItem copyMenuItem;
		private System.Windows.Forms.MenuItem cutMenuItem;
		private System.Windows.Forms.MenuItem pasteMenuItem;
		private System.Windows.Forms.MenuItem findMenuItem;
		private System.Windows.Forms.MenuItem replaseMenuItem;
		private System.Windows.Forms.MenuItem findMenu;
		private System.Windows.Forms.MenuItem toolBarMenu;
		private System.Windows.Forms.MenuItem FontMenu;
		private System.Windows.Forms.MenuItem colorMenuItem;
		private System.Windows.Forms.MenuItem fontMenuItem;
		private System.Windows.Forms.MenuItem helpMenu;
		private System.Windows.Forms.TextBox content;
		private System.Windows.Forms.StatusBar mystatusBar;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.NotifyIcon notifyIcon1;
		private System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.TabControl tabControl1;
		private System.Windows.Forms.TabPage tabPage1;
		private System.Windows.Forms.RichTextBox richTextBox1;
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.ImageList imageList1;
		private System.Windows.Forms.ToolBarButton NewFileButton;
		private System.Windows.Forms.ToolBarButton OpenFileButton;
		private System.Windows.Forms.ToolBarButton SaveFileButton;
		private System.Windows.Forms.ToolBarButton PrintButton;
		private System.Windows.Forms.ToolBarButton CloseFileButton;
		private System.Drawing.Printing.PrintDocument printDocument1;
		private System.Windows.Forms.PageSetupDialog pageSetupDialog1;
		private System.Windows.Forms.PrintPreviewDialog printPreviewDialog1;
		private System.Windows.Forms.PrintDialog printDialog1;
		int FindPostion=0;//查找操作开始位置
		Font printFont;
		private System.Windows.Forms.MenuItem previewItem;//打印使用的字体的变量
		StringReader streamToPrint;//打印的文本
		private string contentLine;
		private System.Windows.Forms.StatusBarPanel statusBarPanel1;
		private System.Windows.Forms.StatusBarPanel statusBarPanel2;
		private System.Windows.Forms.StatusBarPanel statusBarPanel3;
		private System.Windows.Forms.StatusBarPanel statusBarPanel4;
		private System.Windows.Forms.Timer timer1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3; 
		private ArrayList line;

		public myText()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(myText));
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.fileMenu = new System.Windows.Forms.MenuItem();
			this.newMenuItem = new System.Windows.Forms.MenuItem();
			this.openMenueItem = new System.Windows.Forms.MenuItem();
			this.saveMenuItem = new System.Windows.Forms.MenuItem();
			this.saveAsMenuItem = new System.Windows.Forms.MenuItem();
			this.previewItem = new System.Windows.Forms.MenuItem();
			this.printMenuItem = new System.Windows.Forms.MenuItem();
			this.exitMenuItem = new System.Windows.Forms.MenuItem();
			this.editMenu = new System.Windows.Forms.MenuItem();
			this.copyMenuItem = new System.Windows.Forms.MenuItem();
			this.cutMenuItem = new System.Windows.Forms.MenuItem();
			this.pasteMenuItem = new System.Windows.Forms.MenuItem();
			this.findMenuItem = new System.Windows.Forms.MenuItem();
			this.replaseMenuItem = new System.Windows.Forms.MenuItem();
			this.findMenu = new System.Windows.Forms.MenuItem();
			this.toolBarMenu = new System.Windows.Forms.MenuItem();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.FontMenu = new System.Windows.Forms.MenuItem();
			this.colorMenuItem = new System.Windows.Forms.MenuItem();
			this.fontMenuItem = new System.Windows.Forms.MenuItem();
			this.helpMenu = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.content = new System.Windows.Forms.TextBox();
			this.mystatusBar = new System.Windows.Forms.StatusBar();
			this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
			this.statusBarPanel4 = new System.Windows.Forms.StatusBarPanel();
			this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.NewFileButton = new System.Windows.Forms.ToolBarButton();
			this.OpenFileButton = new System.Windows.Forms.ToolBarButton();
			this.SaveFileButton = new System.Windows.Forms.ToolBarButton();
			this.PrintButton = new System.Windows.Forms.ToolBarButton();
			this.CloseFileButton = new System.Windows.Forms.ToolBarButton();
			this.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.tabControl1 = new System.Windows.Forms.TabControl();
			this.tabPage1 = new System.Windows.Forms.TabPage();
			this.richTextBox1 = new System.Windows.Forms.RichTextBox();
			this.printDocument1 = new System.Drawing.Printing.PrintDocument();
			this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();
			this.printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
			this.printDialog1 = new System.Windows.Forms.PrintDialog();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).BeginInit();
			this.SuspendLayout();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.fileMenu,
																					  this.editMenu,
																					  this.findMenu,
																					  this.FontMenu,
																					  this.helpMenu});
			// 
			// fileMenu
			// 
			this.fileMenu.Index = 0;
			this.fileMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.newMenuItem,
																					 this.openMenueItem,
																					 this.saveMenuItem,
																					 this.saveAsMenuItem,
																					 this.previewItem,
																					 this.printMenuItem,
																					 this.exitMenuItem});
			this.fileMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlF;
			this.fileMenu.Text = "文件";
			// 
			// newMenuItem
			// 
			this.newMenuItem.Index = 0;
			this.newMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
			this.newMenuItem.Text = "新建";
			this.newMenuItem.Click += new System.EventHandler(this.newMenuItem_Click);
			// 
			// openMenueItem
			// 
			this.openMenueItem.Index = 1;
			this.openMenueItem.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
			this.openMenueItem.Text = "打开";
			this.openMenueItem.Click += new System.EventHandler(this.openMenueItem_Click);
			// 
			// saveMenuItem
			// 
			this.saveMenuItem.Enabled = false;
			this.saveMenuItem.Index = 2;
			this.saveMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
			this.saveMenuItem.Text = "保存";
			this.saveMenuItem.Click += new System.EventHandler(this.saveMenuItem_Click);
			// 
			// saveAsMenuItem
			// 
			this.saveAsMenuItem.Enabled = false;
			this.saveAsMenuItem.Index = 3;
			this.saveAsMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlA;
			this.saveAsMenuItem.Text = "另存为";
			this.saveAsMenuItem.Click += new System.EventHandler(this.saveAsMenuItem_Click);
			// 
			// previewItem
			// 
			this.previewItem.Enabled = false;
			this.previewItem.Index = 4;
			this.previewItem.Shortcut = System.Windows.Forms.Shortcut.CtrlI;
			this.previewItem.Text = "打印预览";
			this.previewItem.Click += new System.EventHandler(this.previewItem_Click);
			// 
			// printMenuItem
			// 
			this.printMenuItem.Enabled = false;
			this.printMenuItem.Index = 5;
			this.printMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
			this.printMenuItem.Text = "打印";
			this.printMenuItem.Click += new System.EventHandler(this.printMenuItem_Click);
			// 
			// exitMenuItem
			// 
			this.exitMenuItem.Index = 6;
			this.exitMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftX;
			this.exitMenuItem.Text = "退出";
			this.exitMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click);
			// 
			// editMenu
			// 
			this.editMenu.Index = 1;
			this.editMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.copyMenuItem,
																					 this.cutMenuItem,
																					 this.pasteMenuItem,
																					 this.findMenuItem,
																					 this.replaseMenuItem});
			this.editMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlE;
			this.editMenu.Text = "编辑";
			// 
			// copyMenuItem
			// 
			this.copyMenuItem.Enabled = false;
			this.copyMenuItem.Index = 0;
			this.copyMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
			this.copyMenuItem.Text = "复制";
			this.copyMenuItem.Click += new System.EventHandler(this.copyMenuItem_Click);
			// 
			// cutMenuItem
			// 
			this.cutMenuItem.Enabled = false;
			this.cutMenuItem.Index = 1;
			this.cutMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
			this.cutMenuItem.Text = "剪切";
			this.cutMenuItem.Click += new System.EventHandler(this.cutMenuItem_Click);
			// 
			// pasteMenuItem
			// 
			this.pasteMenuItem.Enabled = false;
			this.pasteMenuItem.Index = 2;
			this.pasteMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
			this.pasteMenuItem.Text = "粘贴";
			this.pasteMenuItem.Click += new System.EventHandler(this.pasteMenuItem_Click);
			// 
			// findMenuItem
			// 
			this.findMenuItem.Enabled = false;
			this.findMenuItem.Index = 3;
			this.findMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlF;
			this.findMenuItem.Text = "查找";
			this.findMenuItem.Click += new System.EventHandler(this.findMenuItem_Click);
			// 
			// replaseMenuItem
			// 
			this.replaseMenuItem.Enabled = false;
			this.replaseMenuItem.Index = 4;
			this.replaseMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
			this.replaseMenuItem.Text = "替换";
			this.replaseMenuItem.Click += new System.EventHandler(this.replaseMenuItem_Click);
			// 
			// findMenu
			// 
			this.findMenu.Index = 2;
			this.findMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.toolBarMenu,
																					 this.menuItem1});
			this.findMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
			this.findMenu.Text = "查看";
			// 
			// toolBarMenu
			// 
			this.toolBarMenu.Index = 0;
			this.toolBarMenu.Text = "工具栏                *";
			this.toolBarMenu.Click += new System.EventHandler(this.toolBarMenu_Click);
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 1;
			this.menuItem1.Text = "状态栏                *";
			this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
			// 
			// FontMenu
			// 
			this.FontMenu.Index = 3;
			this.FontMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.colorMenuItem,
																					 this.fontMenuItem});
			this.FontMenu.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
			this.FontMenu.Text = "颜色与字体";
			// 
			// colorMenuItem
			// 
			this.colorMenuItem.Enabled = false;
			this.colorMenuItem.Index = 0;
			this.colorMenuItem.Shortcut = System.Windows.Forms.Shortcut.Alt1;
			this.colorMenuItem.Text = "颜色";
			this.colorMenuItem.Click += new System.EventHandler(this.colorMenuItem_Click);
			// 
			// fontMenuItem
			// 
			this.fontMenuItem.Enabled = false;
			this.fontMenuItem.Index = 1;
			this.fontMenuItem.Shortcut = System.Windows.Forms.Shortcut.Alt2;
			this.fontMenuItem.Text = "字体";
			this.fontMenuItem.Click += new System.EventHandler(this.fontMenuItem_Click);
			// 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -