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

📄 form1.cs

📁 c#通过串口通信发送AT指令控制手机或短信猫收发短信
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.Text;
using JustinIO;
using SMS;
using System.IO;


namespace smsForCsharp
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		static  JustinIO.CommPort ss_port = new JustinIO.CommPort();
		PDUdecoding sms = new SMS.PDUdecoding();
		private string CenterNumber="";
		private string sign="";
		private System.Threading.Thread th;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.TextBox targetNumber;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label ConnectState;
		private System.Windows.Forms.GroupBox groupBox3;
		private System.Windows.Forms.Button btnSend;
		private System.Windows.Forms.Button btnConnect;
		private System.Windows.Forms.Button btnExit;
		private System.Windows.Forms.TextBox smsState;
		private System.Windows.Forms.TextBox smsContent;
		private System.Windows.Forms.ComboBox ConnectPort;
		private System.Windows.Forms.ComboBox ConnectBaudRate;
		private System.Windows.Forms.OpenFileDialog openFile;
		private System.Windows.Forms.Button btnLoad;
		private System.Windows.Forms.Button button1;
		
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

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

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

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
            this.label1 = new System.Windows.Forms.Label();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.smsState = new System.Windows.Forms.TextBox();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.smsContent = new System.Windows.Forms.TextBox();
            this.targetNumber = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.ConnectState = new System.Windows.Forms.Label();
            this.groupBox3 = new System.Windows.Forms.GroupBox();
            this.ConnectBaudRate = new System.Windows.Forms.ComboBox();
            this.ConnectPort = new System.Windows.Forms.ComboBox();
            this.btnSend = new System.Windows.Forms.Button();
            this.btnConnect = new System.Windows.Forms.Button();
            this.btnExit = new System.Windows.Forms.Button();
            this.btnLoad = new System.Windows.Forms.Button();
            this.openFile = new System.Windows.Forms.OpenFileDialog();
            this.button1 = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.groupBox3.SuspendLayout();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(12, 8);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(72, 40);
            this.label1.TabIndex = 0;
            this.label1.Text = "对方手机号:(以*隔开)";
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.smsState);
            this.groupBox1.Location = new System.Drawing.Point(4, 116);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(496, 136);
            this.groupBox1.TabIndex = 3;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "短信发送状态";
            // 
            // smsState
            // 
            this.smsState.Location = new System.Drawing.Point(8, 16);
            this.smsState.Multiline = true;
            this.smsState.Name = "smsState";
            this.smsState.ReadOnly = true;
            this.smsState.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
            this.smsState.Size = new System.Drawing.Size(480, 112);
            this.smsState.TabIndex = 0;
            // 
            // groupBox2
            // 
            this.groupBox2.Controls.Add(this.smsContent);
            this.groupBox2.Location = new System.Drawing.Point(4, 260);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(248, 172);
            this.groupBox2.TabIndex = 4;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "短信内容";
            // 
            // smsContent
            // 
            this.smsContent.Location = new System.Drawing.Point(8, 17);
            this.smsContent.Multiline = true;
            this.smsContent.Name = "smsContent";
            this.smsContent.Size = new System.Drawing.Size(229, 127);
            this.smsContent.TabIndex = 0;
            // 
            // targetNumber
            // 
            this.targetNumber.Location = new System.Drawing.Point(92, 4);
            this.targetNumber.Multiline = true;
            this.targetNumber.Name = "targetNumber";
            this.targetNumber.Size = new System.Drawing.Size(404, 108);
            this.targetNumber.TabIndex = 5;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(24, 24);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(65, 12);
            this.label3.TabIndex = 7;
            this.label3.Text = "通信端口:";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(24, 56);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(65, 12);
            this.label4.TabIndex = 8;
            this.label4.Text = "波 特 率:";
            // 
            // ConnectState
            // 
            this.ConnectState.BackColor = System.Drawing.SystemColors.Control;
            this.ConnectState.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.ConnectState.ForeColor = System.Drawing.Color.Red;
            this.ConnectState.Location = new System.Drawing.Point(8, 80);
            this.ConnectState.Name = "ConnectState";
            this.ConnectState.Size = new System.Drawing.Size(224, 48);
            this.ConnectState.TabIndex = 10;
            this.ConnectState.Text = "尚未与任何设备连接";
            // 
            // groupBox3
            // 
            this.groupBox3.Controls.Add(this.ConnectBaudRate);
            this.groupBox3.Controls.Add(this.ConnectPort);
            this.groupBox3.Controls.Add(this.ConnectState);
            this.groupBox3.Controls.Add(this.label3);
            this.groupBox3.Controls.Add(this.label4);
            this.groupBox3.Location = new System.Drawing.Point(252, 260);
            this.groupBox3.Name = "groupBox3";
            this.groupBox3.Size = new System.Drawing.Size(244, 140);
            this.groupBox3.TabIndex = 0;
            this.groupBox3.TabStop = false;
            this.groupBox3.Text = "端口设置";
            // 
            // ConnectBaudRate
            // 
            this.ConnectBaudRate.Items.AddRange(new object[] {
            "115200",
            "9600",
            "14400",
            "19200",
            "57600"});
            this.ConnectBaudRate.Location = new System.Drawing.Point(120, 56);
            this.ConnectBaudRate.Name = "ConnectBaudRate";
            this.ConnectBaudRate.Size = new System.Drawing.Size(80, 20);
            this.ConnectBaudRate.TabIndex = 12;
            this.ConnectBaudRate.Text = "115200";
            this.ConnectBaudRate.SelectedIndexChanged += new System.EventHandler(this.ConnectBaudRate_SelectedIndexChanged);
            // 
            // ConnectPort
            // 
            this.ConnectPort.Items.AddRange(new object[] {
            "COM1",
            "COM2",
            "COM3",
            "COM4"});
            this.ConnectPort.Location = new System.Drawing.Point(120, 24);
            this.ConnectPort.Name = "ConnectPort";
            this.ConnectPort.Size = new System.Drawing.Size(80, 20);
            this.ConnectPort.TabIndex = 11;
            this.ConnectPort.Text = "COM1";
            // 
            // btnSend
            // 
            this.btnSend.Enabled = false;
            this.btnSend.Location = new System.Drawing.Point(328, 400);
            this.btnSend.Name = "btnSend";
            this.btnSend.Size = new System.Drawing.Size(64, 32);
            this.btnSend.TabIndex = 0;
            this.btnSend.Text = "发送";
            this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
            // 
            // btnConnect
            // 
            this.btnConnect.Location = new System.Drawing.Point(264, 400);
            this.btnConnect.Name = "btnConnect";
            this.btnConnect.Size = new System.Drawing.Size(64, 32);
            this.btnConnect.TabIndex = 1;
            this.btnConnect.Text = "连接";
            this.btnConnect.Click += new System.EventHandler(this.btnConnect_Click);
            // 
            // btnExit
            // 
            this.btnExit.Location = new System.Drawing.Point(456, 400);
            this.btnExit.Name = "btnExit";
            this.btnExit.Size = new System.Drawing.Size(64, 32);
            this.btnExit.TabIndex = 3;
            this.btnExit.Text = "退出";
            this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
            // 
            // btnLoad
            // 
            this.btnLoad.Location = new System.Drawing.Point(4, 64);
            this.btnLoad.Name = "btnLoad";
            this.btnLoad.Size = new System.Drawing.Size(75, 24);
            this.btnLoad.TabIndex = 6;
            this.btnLoad.Text = "载入列表";
            this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click);
            // 
            // openFile
            // 
            this.openFile.Filter = "文本(*.txt)|*.txt";
            this.openFile.Title = "载入列表";
            // 
            // button1
            // 
            this.button1.Enabled = false;
            this.button1.Location = new System.Drawing.Point(392, 400);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(64, 32);
            this.button1.TabIndex = 7;
            this.button1.Text = "停止";
            this.button1.Click += new System.EventHandler(this.button1_Click);

⌨️ 快捷键说明

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