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

📄 formj.cs

📁 这是用C#编的一个简单的电子日记本软件
💻 CS
📖 第 1 页 / 共 5 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO ;
using System.Globalization ;
using System.Runtime.Serialization ;
using System.Runtime.Serialization.Formatters.Binary ;





namespace CS_Note1
{
	/// <summary>
	/// FormJ 的摘要说明。
	/// </summary>

	
	public class FormJ : System.Windows.Forms.Form
	{
		#region field

		private System.Windows.Forms.Panel MdiTabOwner;
		private System.Windows.Forms.Panel MdiTabs;
		private System.Windows.Forms.RichTextBox TextEditPane;
		private System.Windows.Forms.TreeView DocTree;
		private System.Windows.Forms.Panel GenericPane;
		private System.Windows.Forms.Panel JChannel;
		private System.Windows.Forms.Panel MdiContainer;
		private System.ComponentModel.IContainer components;
		private System.Timers.Timer TrundleTimer;
		
		private int NewTextDI = 0;
		// Pen
		private Pen FramePen ;
		private Pen BlackPen ;
		// Brush
		private SolidBrush TabBrush ;
		private SolidBrush CurTabBrush ;
		// Font
		private Font TabFont ;
		private Font CurTabFont ;

		// 用于计时器
		private EventHandler ehTimeTab_Tick_L ;
		private EventHandler ehTimeTab_Tick_R ; 
		private EventHandler ehTimeTab_Tick = null ;
		private EventHandler ehTextEditPane_TextChanged;

		// picture 
		private Image ImgX ;
		private Image ImgGongJu ;
		private Image ImgNailFocusIn ;
		private Image ImgNailUnFocusIn ;
		private Image ImgNailFocusOut ;
		private Image ImgNailUnFocusOut ;
		// Mypath
		private string AppPath ;
		// Tab 是否更改 是否要重画 TextPane(richtextbox)
		// 在 MdiTabs_MouseDown 与 MdiTabs_MouseUp 中使用
		private bool TabChange = false ;
		//
		private System.Windows.Forms.Splitter JWndSpliter;

		// this.GenericPane state
		private WndState GenericPaneState = WndState.Outing ;
		private WndMouseState GenericPaneMouseState = WndMouseState.None ;
		private WndMouseState MdiContainerMouseState = WndMouseState.None ;


		private System.Windows.Forms.ImageList TreeVImgList;
		private System.Windows.Forms.MenuItem menuItem6;
		private System.Windows.Forms.MenuItem DTMenuOpen;
		private System.Windows.Forms.MenuItem DTMenuOpenInCurWnd;
		private System.Windows.Forms.MenuItem DTMenuDel;
		private System.Windows.Forms.ContextMenu DocTreeMenu;
		private System.Windows.Forms.MenuItem DTMenuDao;
		private System.Windows.Forms.MenuItem DTMenuDaoFile;
		private System.Windows.Forms.MenuItem DTMenuDaoFolder;
		private System.Windows.Forms.MenuItem menuItem4;
		private System.Windows.Forms.Timer TimeTab;
		private System.Windows.Forms.ContextMenu TabsMenu;
		private System.Windows.Forms.MainMenu JMenu;
		private System.Windows.Forms.MenuItem JMenuFile;
		private System.Windows.Forms.MenuItem JMenuNew;
		private System.Windows.Forms.MenuItem JMenuOpen;
		private System.Windows.Forms.MenuItem JMenuLine1;
		private System.Windows.Forms.MenuItem JMenuSave;
		private System.Windows.Forms.MenuItem JMenuLine2;
		private System.Windows.Forms.MenuItem JMenuExit;
		private System.Windows.Forms.MenuItem TabsMenuSave;
		private System.Windows.Forms.MenuItem TabsMenuClose;
		private System.Windows.Forms.ContextMenu TPaneMenu;
		private System.Windows.Forms.MenuItem TPaneMenuUnDo;
		private System.Windows.Forms.MenuItem TPaneMenuReDo;
		private System.Windows.Forms.MenuItem TPaneMenuLine1;
		private System.Windows.Forms.MenuItem TPaneMenuCut;
		private System.Windows.Forms.MenuItem TPaneMenuCopy;
		private System.Windows.Forms.MenuItem TPaneMenuLine2;
		private System.Windows.Forms.MenuItem TPaneMenuSelectA;
		private System.Windows.Forms.MenuItem TPaneMenuPaste;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem JMenuWrap;
		private System.Windows.Forms.MenuItem JMenuFont;
		private System.Windows.Forms.MenuItem JMenuBColor;
		private System.Windows.Forms.MenuItem JMenuFColor;
		private System.Windows.Forms.MenuItem JMenuSaveAll;
		private System.Windows.Forms.MenuItem DTMenuNew;
		private System.Windows.Forms.MenuItem DTMenuReName;
		private System.Windows.Forms.MenuItem DTMenuNewF;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem JMenuHelpAbout;

		// One and only DocObject as 
		private MdiTextInBox MdiDocManager ;

		#endregion 

		public FormJ()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			FramePen = new Pen (Color.FromArgb (172,168,153), 1) ;
			BlackPen = new Pen (Color.Black, 1) ;
			TabFont = new Font (this.MdiTabs.Font.Name, (float)8.5) ;
			TabBrush = new SolidBrush (Color.FromArgb (129,126,115)) ;
			CurTabFont  = new Font (this.MdiTabs.Font.Name, (float)8.5, FontStyle.Bold) ; 
			CurTabBrush = new SolidBrush (Color.FromArgb (236,233,216)) ;

			
			this.AppPath = Path.GetDirectoryName (Application.ExecutablePath) ;
			// Load Picture 
			try 
			{
				ImgX = Image.FromFile (this.AppPath + @"\Res\X.bmp") ;
				ImgGongJu = Image.FromFile (this.AppPath+ @"\Res\GongJu.bmp") ;
				ImgNailFocusIn = Image.FromFile (this.AppPath + @"\Res\Nail1.bmp") ;
				ImgNailFocusOut = Image.FromFile (this.AppPath + @"\Res\Nail2.bmp") ;
				ImgNailUnFocusIn = Image.FromFile (this.AppPath + @"\Res\Nail3.bmp") ;
				ImgNailUnFocusOut = Image.FromFile (this.AppPath + @"\Res\Nail4.bmp") ;
			}
			catch (Exception e)
			{
				MessageBox.Show (e.Message + "\nPlease inspect the path--..\\Res.") ;
			}

			this.MdiDocManager = new MdiTextInBox () ;
			this.MdiDocManager.FirstTimeOpenFileMsg += new System.EventHandler(
				this.MdiDocManager_FirstTimeOpenFileMsg) ;
			this.MdiDocManager.AllClosedMsg += new System.EventHandler(
				this.MdiDocManager_AllClosedMsg) ;

			//
			ehTimeTab_Tick_L = new EventHandler (this.TimeTab_Tick_L) ;
			ehTimeTab_Tick_R = new EventHandler (this.TimeTab_Tick_R) ;
			// 

		}



		/// <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(FormJ));
			this.TextEditPane = new System.Windows.Forms.RichTextBox();
			this.TPaneMenu = new System.Windows.Forms.ContextMenu();
			this.TPaneMenuUnDo = new System.Windows.Forms.MenuItem();
			this.TPaneMenuReDo = new System.Windows.Forms.MenuItem();
			this.TPaneMenuLine1 = new System.Windows.Forms.MenuItem();
			this.TPaneMenuCut = new System.Windows.Forms.MenuItem();
			this.TPaneMenuCopy = new System.Windows.Forms.MenuItem();
			this.TPaneMenuPaste = new System.Windows.Forms.MenuItem();
			this.TPaneMenuLine2 = new System.Windows.Forms.MenuItem();
			this.TPaneMenuSelectA = new System.Windows.Forms.MenuItem();
			this.MdiTabOwner = new System.Windows.Forms.Panel();
			this.MdiTabs = new System.Windows.Forms.Panel();
			this.TabsMenu = new System.Windows.Forms.ContextMenu();
			this.TabsMenuSave = new System.Windows.Forms.MenuItem();
			this.TabsMenuClose = new System.Windows.Forms.MenuItem();
			this.JMenu = new System.Windows.Forms.MainMenu();
			this.JMenuFile = new System.Windows.Forms.MenuItem();
			this.JMenuNew = new System.Windows.Forms.MenuItem();
			this.JMenuOpen = new System.Windows.Forms.MenuItem();
			this.JMenuLine1 = new System.Windows.Forms.MenuItem();
			this.JMenuSave = new System.Windows.Forms.MenuItem();
			this.JMenuSaveAll = new System.Windows.Forms.MenuItem();
			this.JMenuLine2 = new System.Windows.Forms.MenuItem();
			this.JMenuExit = new System.Windows.Forms.MenuItem();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.JMenuWrap = new System.Windows.Forms.MenuItem();
			this.JMenuFont = new System.Windows.Forms.MenuItem();
			this.JMenuBColor = new System.Windows.Forms.MenuItem();
			this.JMenuFColor = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.JMenuHelpAbout = new System.Windows.Forms.MenuItem();
			this.JChannel = new System.Windows.Forms.Panel();
			this.GenericPane = new System.Windows.Forms.Panel();
			this.DocTree = new System.Windows.Forms.TreeView();
			this.DocTreeMenu = new System.Windows.Forms.ContextMenu();
			this.DTMenuNew = new System.Windows.Forms.MenuItem();
			this.DTMenuNewF = new System.Windows.Forms.MenuItem();
			this.DTMenuOpen = new System.Windows.Forms.MenuItem();
			this.DTMenuOpenInCurWnd = new System.Windows.Forms.MenuItem();
			this.DTMenuReName = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.DTMenuDao = new System.Windows.Forms.MenuItem();
			this.DTMenuDaoFile = new System.Windows.Forms.MenuItem();
			this.DTMenuDaoFolder = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.DTMenuDel = new System.Windows.Forms.MenuItem();
			this.TreeVImgList = new System.Windows.Forms.ImageList(this.components);
			this.MdiContainer = new System.Windows.Forms.Panel();
			this.TrundleTimer = new System.Timers.Timer();
			this.JWndSpliter = new System.Windows.Forms.Splitter();
			this.TimeTab = new System.Windows.Forms.Timer(this.components);
			this.MdiTabOwner.SuspendLayout();
			this.GenericPane.SuspendLayout();
			this.MdiContainer.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.TrundleTimer)).BeginInit();
			this.SuspendLayout();
			// 
			// TextEditPane
			// 
			this.TextEditPane.AcceptsTab = true;
			this.TextEditPane.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.TextEditPane.ContextMenu = this.TPaneMenu;
			this.TextEditPane.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.TextEditPane.Location = new System.Drawing.Point(18, 26);
			this.TextEditPane.Name = "TextEditPane";
			this.TextEditPane.Size = new System.Drawing.Size(240, 112);
			this.TextEditPane.TabIndex = 1;
			this.TextEditPane.Tag = "";
			this.TextEditPane.Text = "";
			this.TextEditPane.WordWrap = false;
			this.TextEditPane.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextEditPane_KeyDown);
			this.TextEditPane.Enter += new System.EventHandler(this.TextEditPane_Enter);
			// 
			// TPaneMenu
			// 
			this.TPaneMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.TPaneMenuUnDo,
																					  this.TPaneMenuReDo,
																					  this.TPaneMenuLine1,
																					  this.TPaneMenuCut,
																					  this.TPaneMenuCopy,
																					  this.TPaneMenuPaste,
																					  this.TPaneMenuLine2,
																					  this.TPaneMenuSelectA});
			this.TPaneMenu.Popup += new System.EventHandler(this.TPaneMenu_Popup);
			// 
			// TPaneMenuUnDo
			// 
			this.TPaneMenuUnDo.Index = 0;
			this.TPaneMenuUnDo.Shortcut = System.Windows.Forms.Shortcut.CtrlU;
			this.TPaneMenuUnDo.Text = "撤消(&U)";
			this.TPaneMenuUnDo.Click += new System.EventHandler(this.TPaneMenuUnDo_Click);
			// 
			// TPaneMenuReDo
			// 
			this.TPaneMenuReDo.Index = 1;
			this.TPaneMenuReDo.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
			this.TPaneMenuReDo.Text = "重复(&R)";
			this.TPaneMenuReDo.Click += new System.EventHandler(this.TPaneMenuReDo_Click);
			// 
			// TPaneMenuLine1
			// 
			this.TPaneMenuLine1.Index = 2;
			this.TPaneMenuLine1.Text = "-";
			// 
			// TPaneMenuCut
			// 
			this.TPaneMenuCut.Index = 3;
			this.TPaneMenuCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
			this.TPaneMenuCut.Text = "剪切(&T)";
			this.TPaneMenuCut.Click += new System.EventHandler(this.TPaneMenuCut_Click);
			// 
			// TPaneMenuCopy
			// 
			this.TPaneMenuCopy.Index = 4;
			this.TPaneMenuCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
			this.TPaneMenuCopy.Text = "复制(&C)";
			this.TPaneMenuCopy.Click += new System.EventHandler(this.TPaneMenuCopy_Click);
			// 
			// TPaneMenuPaste
			// 
			this.TPaneMenuPaste.Index = 5;
			this.TPaneMenuPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
			this.TPaneMenuPaste.Text = "粘贴(&P)";
			this.TPaneMenuPaste.Click += new System.EventHandler(this.TPaneMenuPaste_Click);
			// 
			// TPaneMenuLine2
			// 
			this.TPaneMenuLine2.Index = 6;
			this.TPaneMenuLine2.Text = "-";
			// 
			// TPaneMenuSelectA
			// 
			this.TPaneMenuSelectA.Index = 7;
			this.TPaneMenuSelectA.Shortcut = System.Windows.Forms.Shortcut.CtrlA;
			this.TPaneMenuSelectA.Text = "全选(&S)";
			this.TPaneMenuSelectA.Click += new System.EventHandler(this.TPaneMenuSelectA_Click);
			// 
			// MdiTabOwner
			// 
			this.MdiTabOwner.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(251)), ((System.Byte)(233)));
			this.MdiTabOwner.Controls.Add(this.MdiTabs);
			this.MdiTabOwner.Location = new System.Drawing.Point(4, 1);
			this.MdiTabOwner.Name = "MdiTabOwner";
			this.MdiTabOwner.Size = new System.Drawing.Size(450, 22);
			this.MdiTabOwner.TabIndex = 3;
			this.MdiTabOwner.SizeChanged += new System.EventHandler(this.MdiTabOwner_SizeChanged);
			this.MdiTabOwner.Paint += new System.Windows.Forms.PaintEventHandler(this.MdiTabOwner_Paint);
			// 
			// MdiTabs
			// 
			this.MdiTabs.ContextMenu = this.TabsMenu;
			this.MdiTabs.Font = new System.Drawing.Font("Courier New", 8F);
			this.MdiTabs.Location = new System.Drawing.Point(0, 0);
			this.MdiTabs.Name = "MdiTabs";
			this.MdiTabs.Size = new System.Drawing.Size(22, 22);
			this.MdiTabs.TabIndex = 0;
			this.MdiTabs.SizeChanged += new System.EventHandler(this.MdiTabs_SizeChanged);
			this.MdiTabs.MouseUp += new System.Windows.Forms.MouseEventHandler(this.MdiTabs_MouseUp);
			this.MdiTabs.Paint += new System.Windows.Forms.PaintEventHandler(this.MdiTabs_Paint);
			this.MdiTabs.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MdiTabs_MouseDown);
			// 
			// TabsMenu
			// 
			this.TabsMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.TabsMenuSave,
																					 this.TabsMenuClose});
			// 
			// TabsMenuSave
			// 

⌨️ 快捷键说明

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