📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Sindasoft.GsmModem;
namespace GsmModemDemo
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
delegate void SetTextCallback(string text);
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
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.Button linkBtn;
private System.Windows.Forms.TextBox indexBox;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.NumericUpDown numBox;
// private System.IO.Ports.SerialPort commPort = new SerialPort();
private GsmModemClass myModem = new GsmModemClass();
private System.Windows.Forms.TextBox phoneBox;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel3;
private System.Windows.Forms.StatusBarPanel linkStat;
private System.Windows.Forms.StatusBarPanel centerNo;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button11;
private CheckBox ReportBox;
private System.Collections.Hashtable exeCmdList = new Hashtable();
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
this.comboBox1.SelectedIndex = 0;
myModem.OnNewSms +=new GsmModemClass.NewSmsEvent(myModem_OnReceivedSms);
myModem.OnCommandFinish +=new GsmModemClass.CommandFinishEvent(myModem_OnCommandFinish);
}
/// <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.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.linkBtn = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.numBox = new System.Windows.Forms.NumericUpDown();
this.button9 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.linkStat = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
this.centerNo = new System.Windows.Forms.StatusBarPanel();
this.label2 = new System.Windows.Forms.Label();
this.button11 = new System.Windows.Forms.Button();
this.ReportBox = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.numBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.linkStat)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.centerNo)).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);
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 160);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 23);
this.label3.TabIndex = 5;
this.label3.Text = "信息栏:";
//
// backBox
//
this.backBox.Location = new System.Drawing.Point(16, 184);
this.backBox.Multiline = true;
this.backBox.Name = "backBox";
this.backBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.backBox.Size = new System.Drawing.Size(376, 152);
this.backBox.TabIndex = 7;
//
// 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(272, 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);
this.label6.TabIndex = 19;
this.label6.Text = "接收方号码:";
//
// phoneBox
//
this.phoneBox.Location = new System.Drawing.Point(24, 96);
this.phoneBox.Name = "phoneBox";
this.phoneBox.Size = new System.Drawing.Size(100, 21);
this.phoneBox.TabIndex = 20;
this.phoneBox.Text = "13935993594";
//
// linkBtn
//
this.linkBtn.Location = new System.Drawing.Point(328, 4);
this.linkBtn.Name = "linkBtn";
this.linkBtn.Size = new System.Drawing.Size(64, 23);
this.linkBtn.TabIndex = 22;
this.linkBtn.Text = "连接";
this.linkBtn.Click += new System.EventHandler(this.linkBtn_Click);
//
// button6
//
this.button6.Location = new System.Drawing.Point(312, 160);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(75, 23);
this.button6.TabIndex = 23;
this.button6.Text = "button6";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// button7
//
this.button7.Location = new System.Drawing.Point(368, 56);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(64, 23);
this.button7.TabIndex = 24;
this.button7.Text = "异步执行";
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// button8
//
this.button8.Location = new System.Drawing.Point(368, 96);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(64, 23);
this.button8.TabIndex = 25;
this.button8.Text = "异步发送";
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// label7
//
this.label7.Location = new System.Drawing.Point(352, 32);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(64, 16);
this.label7.TabIndex = 26;
this.label7.Text = "执行次数";
//
// numBox
//
this.numBox.Location = new System.Drawing.Point(416, 32);
this.numBox.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numBox.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numBox.Name = "numBox";
this.numBox.Size = new System.Drawing.Size(40, 21);
this.numBox.TabIndex = 27;
this.numBox.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// button9
//
this.button9.Location = new System.Drawing.Point(304, 128);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(56, 23);
this.button9.TabIndex = 28;
this.button9.Text = "发送";
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// button10
//
this.button10.Location = new System.Drawing.Point(408, 184);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(56, 23);
this.button10.TabIndex = 29;
this.button10.Text = "电话本";
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// comboBox1
//
this.comboBox1.Items.AddRange(new object[] {
"9600",
"19200",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -