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

📄 form1.cs

📁 主要是作为GSM短信猫开发的书 AT接口说明 适合初学者
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using  Sindasoft.GsmModem;

namespace SmsSender
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label linkStat;

		private System.Windows.Forms.TextBox cmdBox;
		private System.Windows.Forms.Label label3;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.TextBox backBox;
		private System.Windows.Forms.CheckBox rChk;
		private System.Windows.Forms.CheckBox nChk;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.CheckBox eofChk;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Button button4;
		private System.Windows.Forms.TextBox smsBox;
		private System.Windows.Forms.Button button5;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label cnLab;
		private System.Windows.Forms.Button linkBtn;
		private System.Windows.Forms.TextBox indexBox;
		private System.Windows.Forms.TextBox phoneBox;
		private System.Windows.Forms.Button button6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Button button7;
//		private System.IO.Ports.SerialPort commPort = new SerialPort();

		private GsmModemClass myModem = new GsmModemClass();
		private System.Windows.Forms.NumericUpDown numBox;
		private System.Collections.Hashtable exeCmdList = new Hashtable();

		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
			myModem.OnNewSms +=new GsmModemClass.NewSmsEvent(myModem_OnReceivedSms);
			myModem.OnCommandFinish +=new Sindasoft.GsmModem.GsmModemClass.CommandFinishEvent(myModem_OnCommandFinish);
//			this.LinkCom();
		}

		private void LinkCom()
		{
			int con = myModem.ConnectModem();
			if (con == 0)
			{
				this.linkStat.Text = "已连接";
				this.cnLab.Text = "短信中心号:" + myModem.ServiceCenterNumber;
			}
			else
				this.linkStat.Text = "连接失败";

		}

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

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.cmdBox = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.linkStat = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.backBox = new System.Windows.Forms.TextBox();
			this.rChk = new System.Windows.Forms.CheckBox();
			this.nChk = new System.Windows.Forms.CheckBox();
			this.button2 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.eofChk = new System.Windows.Forms.CheckBox();
			this.label4 = new System.Windows.Forms.Label();
			this.smsBox = new System.Windows.Forms.TextBox();
			this.button4 = new System.Windows.Forms.Button();
			this.button5 = new System.Windows.Forms.Button();
			this.label5 = new System.Windows.Forms.Label();
			this.indexBox = new System.Windows.Forms.TextBox();
			this.label6 = new System.Windows.Forms.Label();
			this.phoneBox = new System.Windows.Forms.TextBox();
			this.cnLab = new System.Windows.Forms.Label();
			this.linkBtn = new System.Windows.Forms.Button();
			this.button6 = new System.Windows.Forms.Button();
			this.label7 = new System.Windows.Forms.Label();
			this.numBox = new System.Windows.Forms.NumericUpDown();
			this.button7 = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.numBox)).BeginInit();
			this.SuspendLayout();
			// 
			// cmdBox
			// 
			this.cmdBox.Location = new System.Drawing.Point(24, 56);
			this.cmdBox.Name = "cmdBox";
			this.cmdBox.Size = new System.Drawing.Size(264, 21);
			this.cmdBox.TabIndex = 0;
			this.cmdBox.Text = "at";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 40);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(100, 16);
			this.label1.TabIndex = 1;
			this.label1.Text = "AT指令:";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(296, 56);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(64, 23);
			this.button1.TabIndex = 2;
			this.button1.Text = "同步执行";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 8);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(80, 16);
			this.label2.TabIndex = 3;
			this.label2.Text = "连接状态:";
			// 
			// linkStat
			// 
			this.linkStat.Location = new System.Drawing.Point(88, 8);
			this.linkStat.Name = "linkStat";
			this.linkStat.Size = new System.Drawing.Size(80, 16);
			this.linkStat.TabIndex = 4;
			this.linkStat.Text = "无连接";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(16, 168);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(56, 16);
			this.label3.TabIndex = 5;
			this.label3.Text = "信息栏:";
			// 
			// backBox
			// 
			this.backBox.Location = new System.Drawing.Point(16, 192);
			this.backBox.Multiline = true;
			this.backBox.Name = "backBox";
			this.backBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.backBox.Size = new System.Drawing.Size(432, 168);
			this.backBox.TabIndex = 7;
			this.backBox.Text = "";
			// 
			// rChk
			// 
			this.rChk.Checked = true;
			this.rChk.CheckState = System.Windows.Forms.CheckState.Checked;
			this.rChk.Location = new System.Drawing.Point(136, 32);
			this.rChk.Name = "rChk";
			this.rChk.Size = new System.Drawing.Size(64, 24);
			this.rChk.TabIndex = 8;
			this.rChk.Text = "回车\\r";
			// 
			// nChk
			// 
			this.nChk.Location = new System.Drawing.Point(200, 32);
			this.nChk.Name = "nChk";
			this.nChk.Size = new System.Drawing.Size(64, 24);
			this.nChk.TabIndex = 9;
			this.nChk.Text = "换行\\n";
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(240, 128);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(56, 23);
			this.button2.TabIndex = 10;
			this.button2.Text = "删除";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(176, 160);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(120, 23);
			this.button3.TabIndex = 11;
			this.button3.Text = "清除信息栏";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// eofChk
			// 
			this.eofChk.Location = new System.Drawing.Point(264, 32);
			this.eofChk.Name = "eofChk";
			this.eofChk.Size = new System.Drawing.Size(80, 24);
			this.eofChk.TabIndex = 12;
			this.eofChk.Text = "ctrl+z";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(136, 80);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(80, 16);
			this.label4.TabIndex = 13;
			this.label4.Text = "短信内容:";
			// 
			// smsBox
			// 
			this.smsBox.Location = new System.Drawing.Point(136, 96);
			this.smsBox.Name = "smsBox";
			this.smsBox.Size = new System.Drawing.Size(152, 21);
			this.smsBox.TabIndex = 14;
			this.smsBox.Text = "这是一条测试短信";
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(296, 96);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(64, 23);
			this.button4.TabIndex = 15;
			this.button4.Text = "同步发送";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// button5
			// 
			this.button5.Location = new System.Drawing.Point(176, 128);
			this.button5.Name = "button5";
			this.button5.Size = new System.Drawing.Size(56, 23);
			this.button5.TabIndex = 16;
			this.button5.Text = "读取";
			this.button5.Click += new System.EventHandler(this.button5_Click);
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(24, 128);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(72, 23);
			this.label5.TabIndex = 17;
			this.label5.Text = "短信序号:";
			// 
			// indexBox
			// 
			this.indexBox.Location = new System.Drawing.Point(96, 128);
			this.indexBox.Name = "indexBox";
			this.indexBox.Size = new System.Drawing.Size(64, 21);
			this.indexBox.TabIndex = 18;
			this.indexBox.Text = "1";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(24, 80);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(96, 16);

⌨️ 快捷键说明

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