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

📄 terminal.cs

📁 SerialPort 串口通讯用
💻 CS
字号:
// ==++==
// 
//   Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// ==--==
/*============================================================
**
** Class:  Terminal
**
** Purpose: In CSTerm application, Terminal is simply the Mdi parent
**        : of potentially multiple TerminalWindow forms.  An
**        : arbitrary number of these may exist, provided that 
**        : no two attempt to open to the same serial handle 
**        : (e.g. same COM port).
**		  
** Date:  August 2002
**
===========================================================*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace System.IO.Ports
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class TerminalParent : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.StatusBar statusBar1;
		private System.Windows.Forms.MenuItem miFile;
		private System.Windows.Forms.MenuItem miFileAdd;
		private System.Windows.Forms.MenuItem miFileExit;
		private System.Windows.Forms.MenuItem miWindow;
		private System.Windows.Forms.MenuItem miWindowCascade;
		private System.Windows.Forms.MenuItem miiWindowHoriz;
		private System.Windows.Forms.MenuItem miWindowVert;

		private int windowCount = 0;

		public TerminalParent()
		{
			//
			// 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.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.miFile = new System.Windows.Forms.MenuItem();
			this.miFileAdd = new System.Windows.Forms.MenuItem();
			this.miFileExit = new System.Windows.Forms.MenuItem();
			this.miWindow = new System.Windows.Forms.MenuItem();
			this.miWindowCascade = new System.Windows.Forms.MenuItem();
			this.miiWindowHoriz = new System.Windows.Forms.MenuItem();
			this.miWindowVert = new System.Windows.Forms.MenuItem();
			this.statusBar1 = new System.Windows.Forms.StatusBar();
			this.SuspendLayout();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.miFile,
																					  this.miWindow});
			// 
			// miFile
			// 
			this.miFile.Index = 0;
			this.miFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.miFileAdd,
																				   this.miFileExit});
			this.miFile.Text = "&File";
			// 
			// miFileAdd
			// 
			this.miFileAdd.Index = 0;
			this.miFileAdd.Text = "&Add";
			this.miFileAdd.Click += new System.EventHandler(this.menuItem6_Click);
			// 
			// miFileExit
			// 
			this.miFileExit.Index = 1;
			this.miFileExit.Text = "&Exit";
			this.miFileExit.Click += new System.EventHandler(this.menuItem7_Click);
			// 
			// miWindow
			// 
			this.miWindow.Index = 1;
			this.miWindow.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.miWindowCascade,
																					 this.miiWindowHoriz,
																					 this.miWindowVert});
			this.miWindow.Text = "&Window";
			// 
			// miWindowCascade
			// 
			this.miWindowCascade.Index = 0;
			this.miWindowCascade.Text = "&Cascade";
			this.miWindowCascade.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// miiWindowHoriz
			// 
			this.miiWindowHoriz.Index = 1;
			this.miiWindowHoriz.Text = "Tile &Horizontally";
			this.miiWindowHoriz.Click += new System.EventHandler(this.menuItem4_Click);
			// 
			// miWindowVert
			// 
			this.miWindowVert.Index = 2;
			this.miWindowVert.Text = "Tile &Vertically";
			this.miWindowVert.Click += new System.EventHandler(this.menuItem5_Click);
			// 
			// statusBar1
			// 
			this.statusBar1.Location = new System.Drawing.Point(0, 323);
			this.statusBar1.Name = "statusBar1";
			this.statusBar1.Size = new System.Drawing.Size(688, 22);
			this.statusBar1.TabIndex = 1;
			this.statusBar1.Text = "statusBar1";
			// 
			// TerminalParent
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(688, 345);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.statusBar1});
			this.IsMdiContainer = true;
			this.Menu = this.mainMenu1;
			this.Name = "TerminalParent";
			this.Text = "Terminal";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new TerminalParent());
		}


		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.Cascade);
		}

		private void menuItem4_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.TileHorizontal);
		}

		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.TileVertical);
		}

		private void menuItem6_Click(object sender, System.EventArgs e)
		{
			AddTerminalWindow();
		}

		private void menuItem7_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void AddTerminalWindow() 
		{
			windowCount++;
			TerminalWindow tw = new TerminalWindow(windowCount);
			tw.MdiParent = this;
			tw.Show();
		}
	}
}

⌨️ 快捷键说明

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