📄 form1.cs
字号:
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace WindowsApplication1
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Button hangup;
private System.Windows.Forms.Button Autodial;
private System.Windows.Forms.Button pickup;
private System.Windows.Forms.TextBox phoNum;
private System.Windows.Forms.Label label2;
[DllImport("SHP_A3.dll")]public static extern int SsmStartCti(string lpSsmCfgFileName, string lpIndexCfgFileName);
[DllImport("SHP_A3.dll")]public static extern int SsmAddToFileList(int ch, string pszFileName, int nFormat, int dwStartPos, int dwLen);
[DllImport("SHP_A3.dll")]public static extern string SsmGetLastErrMsgA();
[DllImport("SHP_A3.dll")]public static extern int SsmGetMaxCfgBoard();
[DllImport("SHP_A3.dll")]public static extern int SsmGetMaxUsableBoard();
[DllImport("SHP_A3.dll")]public static extern int SsmGetMaxCh();
[DllImport("SHP_A3.dll")]public static extern int SsmGetChState(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmGetChType(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmPickup(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmHangup(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmAutoDial(int ch, string szPhoNum);
[DllImport("SHP_A3.dll")]public static extern int SsmCheckPlay(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmPlayFileList(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmRecToFile(int ch,string pszFileName, int nFormat, uint dwStartPos, uint dwLen,uint dwTime,int nMask);
[DllImport("SHP_A3.dll")]public static extern int SsmPlayFile(int ch,string pszFileName, int nFormat, int dwStartPos, uint dwLen);
[DllImport("SHP_A3.dll")]public static extern int SsmStopPlay(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmStopPlayFile(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmStopPlayFileList(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmStopPlayIndex(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmStopRecToFile(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmStopRing(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmClearFileList(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmSetDtmfStopPlay(int ch,bool bDsf);
[DllImport("SHP_A3.dll")]public static extern int SsmPlayIndexString(int ch,string pszIdxStr );
[DllImport("SHP_A3.dll")]public static extern int SsmClearRxDtmfBuf(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmGetRxDtmfLen(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmGet1stDtmf(int ch, byte[] pcDtmf);
[DllImport("SHP_A3.dll")]public static extern int SsmGetDtmfStr(int ch, string pcDtmfstr);
[DllImport("SHP_A3.dll")]public static extern int SsmChkRecToFile(int ch);
[DllImport("SHP_A3.dll")]public static extern int SsmGetCallerId(int ch, byte[] szCallerId);
enum TRUNK_STATE
{
TRK_IDLE,
TRK_WAIT_CONNECT,
TRK_PLAY_WELCOM,
TRK_CHECK_PLAY_WELCOM,
TRK_PLAY_SELECT,
TRK_CHECK_PLAY_PASSWORD,
TRK_CHECK_REC_END,
TRK_CHECK_PLAY_BYEBYE,
TRK_CHECK_PLAY_RECORD,
TRK_WAIT_USER_HANGUP,
TRK_WAIT_USER_PICKUP,
TRK_CHECK_PLAY_SELECT,
TRK_CHECK_REC_START,
TRK_NOTRK
};
TRUNK_STATE []mLineState= new TRUNK_STATE[100];
//static extern int add(int a,int b);//
/// <summary>
/// 必需的设计器变量。
[StructLayout(LayoutKind.Sequential)]public struct TRUNK_STRUCT
{
public int statevalue;
public string state;
char mDtmf;
public string CallerId;
}
TRUNK_STRUCT mtrunkState= new TRUNK_STRUCT();
public int m_MaxChNum,Curch;
string PhoNum;
/// <summary>
/// /////////////////////////////////////////////////////////////////////////////////////////////////
/// </summary>
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
ColumnHeader colHead;
colHead = new ColumnHeader();
colHead.Text ="Ch";
this.listView1.Columns.Add(colHead);
colHead = new ColumnHeader();
colHead.Text = "ChType";
this.listView1.Columns.Add(colHead);
colHead = new ColumnHeader();
colHead.Text = "ChState";
this.listView1.Columns.Add(colHead);
colHead = new ColumnHeader();
colHead.Text = "Status";
colHead.Width=100;
this.listView1.Columns.Add(colHead);
colHead = new ColumnHeader();
colHead.Text = "CallerId";
this.listView1.Columns.Add(colHead);
this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
int nIsSsmStartCtiOK = -2;
nIsSsmStartCtiOK = SsmStartCti("ShConfig.ini", "ShIndex.ini");
if(nIsSsmStartCtiOK != 0)
{
string err = SsmGetLastErrMsgA();
MessageBox.Show(err);
this.timer1.Enabled = false;
return;
}
else
{
int nMaUsableBoard = SsmGetMaxUsableBoard();
int nMaxCfgBoard = SsmGetMaxCfgBoard();
m_MaxChNum = SsmGetMaxCh();
this.timer1.Enabled = true;
for(int j=0;j<m_MaxChNum;j++)
{
this.comboBox1.Items.Add(j.ToString());
comboBox1.SelectedIndex = 0;
comboBox1.EndUpdate();
mLineState[j]=TRUNK_STATE.TRK_IDLE;
}
}
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.phoNum = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.Autodial = new System.Windows.Forms.Button();
this.hangup = new System.Windows.Forms.Button();
this.pickup = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.ForeColor = System.Drawing.SystemColors.HotTrack;
this.button1.Location = new System.Drawing.Point(368, 184);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(56, 24);
this.button1.TabIndex = 0;
this.button1.Text = "Exit";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 80);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 2;
this.label1.Text = "被叫号码";
this.label1.Visible = false;
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// phoNum
//
this.phoNum.Location = new System.Drawing.Point(88, 72);
this.phoNum.Multiline = true;
this.phoNum.Name = "phoNum";
this.phoNum.Size = new System.Drawing.Size(72, 21);
this.phoNum.TabIndex = 3;
this.phoNum.Text = "";
this.phoNum.Visible = false;
this.phoNum.TextChanged += new System.EventHandler(this.phoNum_TextChanged);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.comboBox1);
this.groupBox1.Controls.Add(this.Autodial);
this.groupBox1.Controls.Add(this.hangup);
this.groupBox1.Controls.Add(this.pickup);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.phoNum);
this.groupBox1.Location = new System.Drawing.Point(16, 216);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(304, 88);
this.groupBox1.TabIndex = 4;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Option";
this.groupBox1.Visible = false;
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 8;
this.label2.Text = "通 道 号";
this.label2.Visible = false;
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(88, 32);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(72, 20);
this.comboBox1.TabIndex = 7;
this.comboBox1.Text = "comboBox1";
this.comboBox1.Visible = false;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// Autodial
//
this.Autodial.Location = new System.Drawing.Point(208, 24);
this.Autodial.Name = "Autodial";
this.Autodial.Size = new System.Drawing.Size(80, 23);
this.Autodial.TabIndex = 6;
this.Autodial.Text = "SsmAutodial";
this.Autodial.Visible = false;
this.Autodial.Click += new System.EventHandler(this.button4_Click);
//
// hangup
//
this.hangup.Location = new System.Drawing.Point(208, 56);
this.hangup.Name = "hangup";
this.hangup.Size = new System.Drawing.Size(80, 23);
this.hangup.TabIndex = 5;
this.hangup.Text = "SsmHangup";
this.hangup.Visible = false;
this.hangup.Click += new System.EventHandler(this.hangup_Click);
//
// pickup
//
this.pickup.Location = new System.Drawing.Point(208, 88);
this.pickup.Name = "pickup";
this.pickup.Size = new System.Drawing.Size(80, 24);
this.pickup.TabIndex = 4;
this.pickup.Text = "SsmPickup";
this.pickup.Visible = false;
this.pickup.Click += new System.EventHandler(this.button2_Click);
//
// listView1
//
this.listView1.Location = new System.Drawing.Point(8, 8);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(440, 152);
this.listView1.TabIndex = 5;
this.listView1.View = System.Windows.Forms.View.Details;
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.TimerEvent);
//
// timer2
//
this.timer2.Interval = 1000;
this.timer2.Tick += new System.EventHandler(this.TimerEvent_Test);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(464, 218);
this.Controls.Add(this.listView1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Call ";
this.Load += new System.EventHandler(this.Form1_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>g
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Curch = comboBox1.SelectedIndex;
}
private void button1_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void button2_Click(object sender, System.EventArgs e)
{
int nResutlt=SsmPickup(Curch);
if (nResutlt!=0)
MessageBox.Show(SsmGetLastErrMsgA());
}
private void button4_Click(object sender, System.EventArgs e)
{
int nResutlt=SsmAutoDial(Curch,PhoNum);
if (nResutlt!=0)
MessageBox.Show(SsmGetLastErrMsgA());
}
private void label1_Click(object sender, System.EventArgs e)
{
}
private void TimerEvent(object sender, System.EventArgs e)
{
this.listView1.Items.Clear();
ListViewItem lvi;
ListViewItem.ListViewSubItem lvsi;
string nInfo="";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -