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

📄 frmdemo.cs

📁 a sample code for send sms using GPRS Modem.
💻 CS
📖 第 1 页 / 共 4 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

using PduConverter;
using GsmCommunication;

namespace GSMCommDemo
{
	/// <summary>
	/// The main form for the GSMComm demo.
	/// </summary>
	public class frmDemo : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox txtOutput;
		private System.Windows.Forms.Button btnIdentify;
		private System.Windows.Forms.Button btnSendMessage;
		private System.Windows.Forms.TextBox txtMessage;
		private System.Windows.Forms.Button btnReadMessages;
		private System.Windows.Forms.Button btnDumpPhonebook;
		private System.Windows.Forms.Button btnDelMessage;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button btnMsgStorages;
		private System.Windows.Forms.Button btnDelAllMsgs;
		private System.Windows.Forms.Button btnCopyMessages;
		private System.Windows.Forms.Button btnExportMessages;
		private System.Windows.Forms.Button btnImportMessages;
		private System.Windows.Forms.Button btnExportPhonebook;
		private System.Windows.Forms.Button btnImportPhonebook;
		private System.Windows.Forms.Button btnDeletePhonebookEntry;
		private System.Windows.Forms.Button btnDeletePhonebook;
		private System.Windows.Forms.Button btnMsgNotification;
		private System.Windows.Forms.Button btnMsgNotificationOff;
		private System.Windows.Forms.Button btnMsgRoutingOff;
		private System.Windows.Forms.Button btnMsgRoutingOn;
		private System.Windows.Forms.TextBox txtNumber;
		private System.Windows.Forms.CheckBox chkDebugTrace;
		private System.Windows.Forms.Button btnReset;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Label label3;

		private GsmComm comm;
		private System.Windows.Forms.Button btnIsConnected;
		private System.Windows.Forms.TabControl tabControl;
		private System.Windows.Forms.TabPage tabSMS;
		private System.Windows.Forms.TabPage tabPhonebook;
		private System.Windows.Forms.TabPage tabGeneral;
		private System.Windows.Forms.Button txtClearOutput;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.RadioButton rbMessageSIM;
		private System.Windows.Forms.RadioButton rbMessagePhone;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.RadioButton rbPhonebookPhone;
		private System.Windows.Forms.RadioButton rbPhonebookSIM;
		private System.Windows.Forms.Button btnCreatePbEntry;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.TextBox txtPbName;
		private System.Windows.Forms.TextBox txtPbNumber;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.TextBox txtDelMsgIndex;
		private System.Windows.Forms.TextBox txtDelPbIndex;
		private System.Windows.Forms.Button btnPbStorages;
		private System.Windows.Forms.Label lblNotConnected;
		private System.Windows.Forms.Button btnMsgMemStatus;
		private System.Windows.Forms.Button btnPbMemStatus;
		private bool registerMessageReceived;

		public frmDemo()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			comm = null;
			registerMessageReceived = false;
		}

		/// <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.txtOutput = new System.Windows.Forms.TextBox();
			this.btnIdentify = new System.Windows.Forms.Button();
			this.btnSendMessage = new System.Windows.Forms.Button();
			this.txtMessage = new System.Windows.Forms.TextBox();
			this.txtNumber = new System.Windows.Forms.TextBox();
			this.btnReadMessages = new System.Windows.Forms.Button();
			this.btnDumpPhonebook = new System.Windows.Forms.Button();
			this.btnDelMessage = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.btnMsgStorages = new System.Windows.Forms.Button();
			this.btnDelAllMsgs = new System.Windows.Forms.Button();
			this.btnCopyMessages = new System.Windows.Forms.Button();
			this.btnExportMessages = new System.Windows.Forms.Button();
			this.btnImportMessages = new System.Windows.Forms.Button();
			this.btnExportPhonebook = new System.Windows.Forms.Button();
			this.btnImportPhonebook = new System.Windows.Forms.Button();
			this.btnDeletePhonebookEntry = new System.Windows.Forms.Button();
			this.btnDeletePhonebook = new System.Windows.Forms.Button();
			this.btnMsgRoutingOff = new System.Windows.Forms.Button();
			this.btnMsgRoutingOn = new System.Windows.Forms.Button();
			this.btnMsgNotificationOff = new System.Windows.Forms.Button();
			this.btnMsgNotification = new System.Windows.Forms.Button();
			this.btnReset = new System.Windows.Forms.Button();
			this.chkDebugTrace = new System.Windows.Forms.CheckBox();
			this.label3 = new System.Windows.Forms.Label();
			this.btnIsConnected = new System.Windows.Forms.Button();
			this.tabControl = new System.Windows.Forms.TabControl();
			this.tabSMS = new System.Windows.Forms.TabPage();
			this.btnMsgMemStatus = new System.Windows.Forms.Button();
			this.label8 = new System.Windows.Forms.Label();
			this.txtDelMsgIndex = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.rbMessagePhone = new System.Windows.Forms.RadioButton();
			this.rbMessageSIM = new System.Windows.Forms.RadioButton();
			this.tabPhonebook = new System.Windows.Forms.TabPage();
			this.btnPbMemStatus = new System.Windows.Forms.Button();
			this.btnPbStorages = new System.Windows.Forms.Button();
			this.label9 = new System.Windows.Forms.Label();
			this.txtDelPbIndex = new System.Windows.Forms.TextBox();
			this.label7 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.txtPbNumber = new System.Windows.Forms.TextBox();
			this.txtPbName = new System.Windows.Forms.TextBox();
			this.btnCreatePbEntry = new System.Windows.Forms.Button();
			this.label5 = new System.Windows.Forms.Label();
			this.rbPhonebookPhone = new System.Windows.Forms.RadioButton();
			this.rbPhonebookSIM = new System.Windows.Forms.RadioButton();
			this.tabGeneral = new System.Windows.Forms.TabPage();
			this.txtClearOutput = new System.Windows.Forms.Button();
			this.lblNotConnected = new System.Windows.Forms.Label();
			this.tabControl.SuspendLayout();
			this.tabSMS.SuspendLayout();
			this.tabPhonebook.SuspendLayout();
			this.tabGeneral.SuspendLayout();
			this.SuspendLayout();
			// 
			// txtOutput
			// 
			this.txtOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.txtOutput.Location = new System.Drawing.Point(8, 280);
			this.txtOutput.MaxLength = 0;
			this.txtOutput.Multiline = true;
			this.txtOutput.Name = "txtOutput";
			this.txtOutput.ReadOnly = true;
			this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.txtOutput.Size = new System.Drawing.Size(512, 184);
			this.txtOutput.TabIndex = 1;
			this.txtOutput.Text = "";
			// 
			// btnIdentify
			// 
			this.btnIdentify.Location = new System.Drawing.Point(8, 48);
			this.btnIdentify.Name = "btnIdentify";
			this.btnIdentify.Size = new System.Drawing.Size(128, 32);
			this.btnIdentify.TabIndex = 1;
			this.btnIdentify.Text = "Identify phone";
			this.btnIdentify.Click += new System.EventHandler(this.btnIdentify_Click);
			// 
			// btnSendMessage
			// 
			this.btnSendMessage.Location = new System.Drawing.Point(8, 176);
			this.btnSendMessage.Name = "btnSendMessage";
			this.btnSendMessage.Size = new System.Drawing.Size(128, 32);
			this.btnSendMessage.TabIndex = 6;
			this.btnSendMessage.Text = "Send Message";
			this.btnSendMessage.Click += new System.EventHandler(this.btnSendMessage_Click);
			// 
			// txtMessage
			// 
			this.txtMessage.Location = new System.Drawing.Point(208, 168);
			this.txtMessage.MaxLength = 160;
			this.txtMessage.Name = "txtMessage";
			this.txtMessage.Size = new System.Drawing.Size(128, 20);
			this.txtMessage.TabIndex = 8;
			this.txtMessage.Text = "This is a test!";
			// 
			// txtNumber
			// 
			this.txtNumber.Location = new System.Drawing.Point(208, 192);
			this.txtNumber.MaxLength = 30;
			this.txtNumber.Name = "txtNumber";
			this.txtNumber.Size = new System.Drawing.Size(128, 20);
			this.txtNumber.TabIndex = 10;
			this.txtNumber.Text = "+483341234567";
			// 
			// btnReadMessages
			// 
			this.btnReadMessages.Location = new System.Drawing.Point(8, 8);
			this.btnReadMessages.Name = "btnReadMessages";
			this.btnReadMessages.Size = new System.Drawing.Size(128, 32);
			this.btnReadMessages.TabIndex = 0;
			this.btnReadMessages.Text = "Read all messages";
			this.btnReadMessages.Click += new System.EventHandler(this.btnReadMessages_Click);
			// 
			// btnDumpPhonebook
			// 
			this.btnDumpPhonebook.Location = new System.Drawing.Point(8, 8);
			this.btnDumpPhonebook.Name = "btnDumpPhonebook";
			this.btnDumpPhonebook.Size = new System.Drawing.Size(128, 32);
			this.btnDumpPhonebook.TabIndex = 0;
			this.btnDumpPhonebook.Text = "Read phonebook";
			this.btnDumpPhonebook.Click += new System.EventHandler(this.btnDumpPhonebook_Click);
			// 
			// btnDelMessage
			// 
			this.btnDelMessage.Location = new System.Drawing.Point(8, 48);
			this.btnDelMessage.Name = "btnDelMessage";
			this.btnDelMessage.Size = new System.Drawing.Size(64, 32);
			this.btnDelMessage.TabIndex = 1;
			this.btnDelMessage.Text = "Delete Message";
			this.btnDelMessage.Click += new System.EventHandler(this.btnDelMessage_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(144, 168);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 24);
			this.label1.TabIndex = 7;
			this.label1.Text = "Message:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(144, 192);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(56, 23);
			this.label2.TabIndex = 9;
			this.label2.Text = "Number:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// btnMsgStorages
			// 
			this.btnMsgStorages.Location = new System.Drawing.Point(8, 136);
			this.btnMsgStorages.Name = "btnMsgStorages";
			this.btnMsgStorages.Size = new System.Drawing.Size(128, 32);
			this.btnMsgStorages.TabIndex = 5;
			this.btnMsgStorages.Text = "Get supported message storages";
			this.btnMsgStorages.Click += new System.EventHandler(this.btnMsgStorages_Click);
			// 
			// btnDelAllMsgs
			// 
			this.btnDelAllMsgs.Location = new System.Drawing.Point(8, 96);
			this.btnDelAllMsgs.Name = "btnDelAllMsgs";
			this.btnDelAllMsgs.Size = new System.Drawing.Size(128, 32);
			this.btnDelAllMsgs.TabIndex = 4;
			this.btnDelAllMsgs.Text = "Delete all messages";
			this.btnDelAllMsgs.Click += new System.EventHandler(this.btnDelAllMsgs_Click);
			// 
			// btnCopyMessages
			// 
			this.btnCopyMessages.Location = new System.Drawing.Point(296, 8);
			this.btnCopyMessages.Name = "btnCopyMessages";
			this.btnCopyMessages.Size = new System.Drawing.Size(128, 32);
			this.btnCopyMessages.TabIndex = 15;
			this.btnCopyMessages.Text = "Copy all messages from SIM to phone";
			this.btnCopyMessages.Click += new System.EventHandler(this.btnCopyMessages_Click);
			// 
			// btnExportMessages
			// 
			this.btnExportMessages.Location = new System.Drawing.Point(296, 48);
			this.btnExportMessages.Name = "btnExportMessages";
			this.btnExportMessages.Size = new System.Drawing.Size(128, 32);
			this.btnExportMessages.TabIndex = 16;
			this.btnExportMessages.Text = "Export all messages";
			this.btnExportMessages.Click += new System.EventHandler(this.btnExportMessages_Click);
			// 
			// btnImportMessages
			// 
			this.btnImportMessages.Location = new System.Drawing.Point(296, 88);
			this.btnImportMessages.Name = "btnImportMessages";
			this.btnImportMessages.Size = new System.Drawing.Size(128, 32);
			this.btnImportMessages.TabIndex = 17;
			this.btnImportMessages.Text = "Import messages";
			this.btnImportMessages.Click += new System.EventHandler(this.btnImportMessages_Click);
			// 
			// btnExportPhonebook
			// 
			this.btnExportPhonebook.Location = new System.Drawing.Point(152, 48);
			this.btnExportPhonebook.Name = "btnExportPhonebook";
			this.btnExportPhonebook.Size = new System.Drawing.Size(128, 32);
			this.btnExportPhonebook.TabIndex = 11;
			this.btnExportPhonebook.Text = "Export phonebook";
			this.btnExportPhonebook.Click += new System.EventHandler(this.btnExportPhonebook_Click);
			// 
			// btnImportPhonebook
			// 
			this.btnImportPhonebook.Location = new System.Drawing.Point(152, 88);
			this.btnImportPhonebook.Name = "btnImportPhonebook";
			this.btnImportPhonebook.Size = new System.Drawing.Size(128, 32);
			this.btnImportPhonebook.TabIndex = 12;
			this.btnImportPhonebook.Text = "Import phonebook";
			this.btnImportPhonebook.Click += new System.EventHandler(this.btnImportPhonebook_Click);
			// 
			// btnDeletePhonebookEntry
			// 
			this.btnDeletePhonebookEntry.Location = new System.Drawing.Point(8, 48);
			this.btnDeletePhonebookEntry.Name = "btnDeletePhonebookEntry";
			this.btnDeletePhonebookEntry.Size = new System.Drawing.Size(64, 32);
			this.btnDeletePhonebookEntry.TabIndex = 1;
			this.btnDeletePhonebookEntry.Text = "Delete entry";
			this.btnDeletePhonebookEntry.Click += new System.EventHandler(this.btnDeletePhonebookEntry_Click);
			// 
			// btnDeletePhonebook
			// 
			this.btnDeletePhonebook.Location = new System.Drawing.Point(8, 96);
			this.btnDeletePhonebook.Name = "btnDeletePhonebook";
			this.btnDeletePhonebook.Size = new System.Drawing.Size(128, 32);
			this.btnDeletePhonebook.TabIndex = 4;
			this.btnDeletePhonebook.Text = "Delete all entries";
			this.btnDeletePhonebook.Click += new System.EventHandler(this.btnDeletePhonebook_Click);
			// 
			// btnMsgRoutingOff
			// 
			this.btnMsgRoutingOff.Location = new System.Drawing.Point(224, 8);
			this.btnMsgRoutingOff.Name = "btnMsgRoutingOff";
			this.btnMsgRoutingOff.Size = new System.Drawing.Size(56, 48);
			this.btnMsgRoutingOff.TabIndex = 12;
			this.btnMsgRoutingOff.Text = "Disable";
			this.btnMsgRoutingOff.Click += new System.EventHandler(this.btnMsgRoutingOff_Click);
			// 
			// btnMsgRoutingOn
			// 
			this.btnMsgRoutingOn.Location = new System.Drawing.Point(152, 8);
			this.btnMsgRoutingOn.Name = "btnMsgRoutingOn";
			this.btnMsgRoutingOn.Size = new System.Drawing.Size(72, 48);
			this.btnMsgRoutingOn.TabIndex = 11;
			this.btnMsgRoutingOn.Text = "Enable message routing";
			this.btnMsgRoutingOn.Click += new System.EventHandler(this.btnMsgRoutingOn_Click);
			// 
			// btnMsgNotificationOff
			// 
			this.btnMsgNotificationOff.Location = new System.Drawing.Point(224, 64);
			this.btnMsgNotificationOff.Name = "btnMsgNotificationOff";
			this.btnMsgNotificationOff.Size = new System.Drawing.Size(56, 48);
			this.btnMsgNotificationOff.TabIndex = 14;
			this.btnMsgNotificationOff.Text = "Disable";
			this.btnMsgNotificationOff.Click += new System.EventHandler(this.btnMsgNotificationOff_Click);
			// 
			// btnMsgNotification
			// 
			this.btnMsgNotification.Location = new System.Drawing.Point(152, 64);
			this.btnMsgNotification.Name = "btnMsgNotification";
			this.btnMsgNotification.Size = new System.Drawing.Size(72, 48);
			this.btnMsgNotification.TabIndex = 13;
			this.btnMsgNotification.Text = "Enable message notifications";
			this.btnMsgNotification.Click += new System.EventHandler(this.btnMsgNotification_Click);
			// 
			// btnReset
			// 
			this.btnReset.Location = new System.Drawing.Point(8, 88);
			this.btnReset.Name = "btnReset";
			this.btnReset.Size = new System.Drawing.Size(128, 32);
			this.btnReset.TabIndex = 2;
			this.btnReset.Text = "Reset to default config";
			this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
			// 
			// chkDebugTrace
			// 
			this.chkDebugTrace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
			this.chkDebugTrace.Location = new System.Drawing.Point(8, 472);
			this.chkDebugTrace.Name = "chkDebugTrace";
			this.chkDebugTrace.Size = new System.Drawing.Size(112, 24);
			this.chkDebugTrace.TabIndex = 2;
			this.chkDebugTrace.Text = "Debug trace on";
			this.chkDebugTrace.CheckedChanged += new System.EventHandler(this.chkDebugTrace_CheckedChanged);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 8);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(512, 16);

⌨️ 快捷键说明

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