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

📄 comport.cs

📁 C sharp - Serial comm port using MSCOMM control
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
//using b0002b_Rs232_class_for_MScomm;
using CSMA_EmuMaster;

namespace KYLai_MScomm
{
	/// <summary>
	/// Summary description for ComPort.
	/// </summary>
	/// 

	public class ComPort : System.Windows.Forms.Form
	{	
		// my function
		

		private AxMSCommLib.AxMSComm obj_MyMSComm;
		private AxMSCommLib.AxMSComm obj_BaseMSCommTemp;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.ComboBox cb_dataBits;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.NumericUpDown nlist_inputLen;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.ComboBox cb_inputMode;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.ComboBox cb_stopBits;
		private System.Windows.Forms.ComboBox cb_parity;
		private System.Windows.Forms.ComboBox cb_baud;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.NumericUpDown nlist_port;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.NumericUpDown nlist_RTh;
		private System.Windows.Forms.CheckBox cb_DTRenable;
		private System.Windows.Forms.CheckBox cb_NullDiscard;
		private System.Windows.Forms.ComboBox cb_handshaking;
		private System.Windows.Forms.Button btCancel;
		private System.Windows.Forms.Button btOK;
		private System.Windows.Forms.Button btDefault;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ComPort(AxMSCommLib.AxMSComm obj_BaseComm)
		{

			obj_MyMSComm = obj_BaseComm;
			obj_BaseMSCommTemp = obj_MyMSComm;
			
			//
			// 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.groupBox1 = new System.Windows.Forms.GroupBox();
			this.btOK = new System.Windows.Forms.Button();
			this.btCancel = new System.Windows.Forms.Button();
			this.cb_dataBits = new System.Windows.Forms.ComboBox();
			this.label11 = new System.Windows.Forms.Label();
			this.nlist_inputLen = new System.Windows.Forms.NumericUpDown();
			this.label6 = new System.Windows.Forms.Label();
			this.cb_inputMode = new System.Windows.Forms.ComboBox();
			this.label5 = new System.Windows.Forms.Label();
			this.cb_stopBits = new System.Windows.Forms.ComboBox();
			this.cb_parity = new System.Windows.Forms.ComboBox();
			this.cb_baud = new System.Windows.Forms.ComboBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.nlist_port = new System.Windows.Forms.NumericUpDown();
			this.cb_NullDiscard = new System.Windows.Forms.CheckBox();
			this.label9 = new System.Windows.Forms.Label();
			this.nlist_RTh = new System.Windows.Forms.NumericUpDown();
			this.label7 = new System.Windows.Forms.Label();
			this.cb_handshaking = new System.Windows.Forms.ComboBox();
			this.cb_DTRenable = new System.Windows.Forms.CheckBox();
			this.btDefault = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.nlist_inputLen)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.nlist_port)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.nlist_RTh)).BeginInit();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.btOK);
			this.groupBox1.Controls.Add(this.btCancel);
			this.groupBox1.Controls.Add(this.cb_dataBits);
			this.groupBox1.Controls.Add(this.label11);
			this.groupBox1.Controls.Add(this.nlist_inputLen);
			this.groupBox1.Controls.Add(this.label6);
			this.groupBox1.Controls.Add(this.cb_inputMode);
			this.groupBox1.Controls.Add(this.label5);
			this.groupBox1.Controls.Add(this.cb_stopBits);
			this.groupBox1.Controls.Add(this.cb_parity);
			this.groupBox1.Controls.Add(this.cb_baud);
			this.groupBox1.Controls.Add(this.label4);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.nlist_port);
			this.groupBox1.Controls.Add(this.cb_NullDiscard);
			this.groupBox1.Controls.Add(this.label9);
			this.groupBox1.Controls.Add(this.nlist_RTh);
			this.groupBox1.Controls.Add(this.label7);
			this.groupBox1.Controls.Add(this.cb_handshaking);
			this.groupBox1.Controls.Add(this.cb_DTRenable);
			this.groupBox1.Controls.Add(this.btDefault);
			this.groupBox1.Location = new System.Drawing.Point(24, 16);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(320, 240);
			this.groupBox1.TabIndex = 2;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Port";
			// 
			// btOK
			// 
			this.btOK.Location = new System.Drawing.Point(240, 208);
			this.btOK.Name = "btOK";
			this.btOK.Size = new System.Drawing.Size(64, 23);
			this.btOK.TabIndex = 29;
			this.btOK.Text = "OK";
			this.btOK.Click += new System.EventHandler(this.btOK_Click);
			// 
			// btCancel
			// 
			this.btCancel.Location = new System.Drawing.Point(240, 184);
			this.btCancel.Name = "btCancel";
			this.btCancel.Size = new System.Drawing.Size(64, 23);
			this.btCancel.TabIndex = 28;
			this.btCancel.Text = "Cancel";
			this.btCancel.Click += new System.EventHandler(this.btCancel_Click);
			// 
			// cb_dataBits
			// 
			this.cb_dataBits.Items.AddRange(new object[] {
															 "4",
															 "5",
															 "6",
															 "7",
															 "8"});
			this.cb_dataBits.Location = new System.Drawing.Point(88, 104);
			this.cb_dataBits.Name = "cb_dataBits";
			this.cb_dataBits.Size = new System.Drawing.Size(72, 21);
			this.cb_dataBits.TabIndex = 27;
			this.cb_dataBits.Text = "8";
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(24, 104);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(56, 16);
			this.label11.TabIndex = 26;
			this.label11.Text = "Data Bits";
			// 
			// nlist_inputLen
			// 
			this.nlist_inputLen.Location = new System.Drawing.Point(88, 160);
			this.nlist_inputLen.Name = "nlist_inputLen";
			this.nlist_inputLen.Size = new System.Drawing.Size(72, 20);
			this.nlist_inputLen.TabIndex = 25;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(24, 160);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(56, 16);
			this.label6.TabIndex = 24;
			this.label6.Text = "Input Len:";
			// 
			// cb_inputMode
			// 
			this.cb_inputMode.Items.AddRange(new object[] {
															  "Binary",
															  "Text"});
			this.cb_inputMode.Location = new System.Drawing.Point(88, 184);
			this.cb_inputMode.Name = "cb_inputMode";
			this.cb_inputMode.Size = new System.Drawing.Size(72, 21);
			this.cb_inputMode.TabIndex = 23;
			this.cb_inputMode.Text = "Binary";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(24, 184);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(64, 16);
			this.label5.TabIndex = 22;
			this.label5.Text = "Input Mode:";
			// 
			// cb_stopBits
			// 
			this.cb_stopBits.Items.AddRange(new object[] {
															 "1",
															 "1.5",
															 "2"});
			this.cb_stopBits.Location = new System.Drawing.Point(88, 128);
			this.cb_stopBits.Name = "cb_stopBits";
			this.cb_stopBits.Size = new System.Drawing.Size(72, 21);
			this.cb_stopBits.TabIndex = 21;
			this.cb_stopBits.Text = "1";
			// 
			// cb_parity
			// 
			this.cb_parity.Items.AddRange(new object[] {
														   "None",
														   "Odd",
														   "Even",
														   "Mark",
														   "Space"});
			this.cb_parity.Location = new System.Drawing.Point(88, 80);
			this.cb_parity.Name = "cb_parity";
			this.cb_parity.Size = new System.Drawing.Size(72, 21);
			this.cb_parity.TabIndex = 20;
			this.cb_parity.Text = "None";
			// 
			// cb_baud
			// 
			this.cb_baud.Items.AddRange(new object[] {
														 "2400",
														 "4800",
														 "7200",
														 "9600",
														 "14400",
														 "19200",
														 "38400",
														 "57600",
														 "115200",
														 "128000"});
			this.cb_baud.Location = new System.Drawing.Point(88, 56);
			this.cb_baud.Name = "cb_baud";
			this.cb_baud.Size = new System.Drawing.Size(72, 21);
			this.cb_baud.TabIndex = 19;
			this.cb_baud.Text = "115200";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(24, 128);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(56, 16);
			this.label4.TabIndex = 18;
			this.label4.Text = "Stop Bits:";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 32);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(32, 16);
			this.label1.TabIndex = 14;
			this.label1.Text = "Port:";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(24, 80);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(48, 16);
			this.label3.TabIndex = 17;
			this.label3.Text = "Parity:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 56);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(32, 16);
			this.label2.TabIndex = 16;
			this.label2.Text = "Baud:";
			// 
			// nlist_port
			// 
			this.nlist_port.Location = new System.Drawing.Point(88, 32);
			this.nlist_port.Name = "nlist_port";
			this.nlist_port.Size = new System.Drawing.Size(72, 20);
			this.nlist_port.TabIndex = 15;
			this.nlist_port.Value = new System.Decimal(new int[] {
																	 2,
																	 0,
																	 0,
																	 0});
			// 
			// cb_NullDiscard
			// 
			this.cb_NullDiscard.Location = new System.Drawing.Point(184, 160);
			this.cb_NullDiscard.Name = "cb_NullDiscard";
			this.cb_NullDiscard.Size = new System.Drawing.Size(128, 16);
			this.cb_NullDiscard.TabIndex = 22;
			this.cb_NullDiscard.Text = "Null Discard Enable";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(184, 80);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(72, 16);
			this.label9.TabIndex = 18;
			this.label9.Text = "Handshaking:";
			// 
			// nlist_RTh
			// 
			this.nlist_RTh.Location = new System.Drawing.Point(184, 56);

⌨️ 快捷键说明

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