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

📄 form1.cs

📁 三汇CTI示例程序源码
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.radioButton4.Text = "Record only outgoing channels";
			this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
			// 
			// radioButton5
			// 
			this.radioButton5.Location = new System.Drawing.Point(120, 64);
			this.radioButton5.Name = "radioButton5";
			this.radioButton5.Size = new System.Drawing.Size(208, 32);
			this.radioButton5.TabIndex = 6;
			this.radioButton5.Text = "Mix the recording of incoming and outgoing channels";
			this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.radioButton1);
			this.groupBox1.Controls.Add(this.radioButton2);
			this.groupBox1.Location = new System.Drawing.Point(16, 336);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(264, 104);
			this.groupBox1.TabIndex = 7;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Function For Recording Mode";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.label1);
			this.groupBox2.Controls.Add(this.comboBox1);
			this.groupBox2.Controls.Add(this.radioButton3);
			this.groupBox2.Controls.Add(this.radioButton4);
			this.groupBox2.Controls.Add(this.radioButton5);
			this.groupBox2.Location = new System.Drawing.Point(296, 336);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(336, 104);
			this.groupBox2.TabIndex = 8;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "Record Mode Setting";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 40);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(24, 16);
			this.label1.TabIndex = 7;
			this.label1.Text = "Cic";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(648, 454);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.listView1);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Form1";
			this.Text = "DTPRecorder";
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
		protected override void WndProc(ref Message m) 
		{
			int nCic;
			int		nCh;		//channel ID
			int		nNewState;  //new state
			char cNewDtmf;
			string szTemp;
			byte[]  szCallerId = new byte[20]; 
			// Listen for operating system messages.
			int nMsg = m.Msg - WM_USER;
			if(nMsg > 0 )
			{
				switch (nMsg)
				{
					case E_CHG_SpyState:	

						nCic = (int)m.WParam;
	 					nNewState = (int)((int)m.LParam & 0xFFFF);
						if(nCic >= 0 && nCic < MAX_CIC)
						{
							switch(nNewState)
							{
							//Idle state
							case S_SPY_STANDBY:
								{
									if(CicState[nCic].nCicState == (int)CIRCUIT_STATE.CIRCUIT_TALKING)
									{	
										//Call the function with circuit number as its parameter
										if(m_nCallFnMode == 0)				
										{
											//stop recording
											if(SpyStopRecToFile(nCic) == -1)
												MessageBox.Show("Fail to call SpyStopRecToFile");
										}
										//Call the function with channel number as its parameter
										else
										{
											if(CicState[nCic].wRecDirection == (int)RECORD_DIRECTION.CALL_IN_RECORD)
											{
												if(SsmStopRecToFile(CicState[nCic].nCallInCh) == -1)
													MessageBox.Show("Fail to call SsmStopRecToFile");
											}
											else if(CicState[nCic].wRecDirection == (int)RECORD_DIRECTION.CALL_OUT_RECORD)
											{
												if(SsmStopRecToFile(CicState[nCic].nCallOutCh) == -1)
													MessageBox.Show("Fail to call SsmStopRecToFile");
											}
											else
											{
												if(SsmSetRecMixer(CicState[nCic].nCallInCh, false, 0) == -1)//Turn off the record mixer
													MessageBox.Show("Fail to call SsmSetRecMixer");
												if(SsmStopLinkFrom(CicState[nCic].nCallOutCh, CicState[nCic].nCallInCh) == -1)//Cut off the bus connect from outgoing channel to incoming channel
													MessageBox.Show("Fail to call SsmStopLinkFrom");
												if(SsmStopRecToFile(CicState[nCic].nCallInCh) == -1)		//Stop recording
													MessageBox.Show("Fail to call SsmStopRecToFile");
											}
										}
									}
									CicState[nCic].nCicState = (int)CIRCUIT_STATE.CIRCUIT_IDLE;
									CicState[nCic].nCallInIndex = 0;
									CicState[nCic].nCallOutIndex = 0;
									CicState[nCic].szCallInDtmf = new char[100];
									CicState[nCic].szCallOutDtmf = new char[100];
								//	CicState[nCic].szCallInDtmf[0] = '\0';
								//	CicState[nCic].szCallOutDtmf[0] ='\0';
									CicState[nCic].szCalleeId = "";
									CicState[nCic].szCallerId = "";
									CicState[nCic].nCallInCh = -1;
									CicState[nCic].nCallOutCh = -1;
								}
								break;
							//Receiving phone number
							case S_SPY_RCVPHONUM:
								{
									if(CicState[nCic].nCicState == (int)CIRCUIT_STATE.CIRCUIT_IDLE)
									{
										CicState[nCic].nCicState = (int)CIRCUIT_STATE.CIRCUIT_RCV_PHONUM;
									}
								}
								break;			
							//Ringing
							case S_SPY_RINGING:
								{
									CicState[nCic].nCicState = (int)CIRCUIT_STATE.CIRCUIT_RINGING;
									CicState[nCic].szCallerId = "";
									CicState[nCic].szCalleeId = "";
									if(SpyGetCallerId(nCic, szCallerId) == -1)//Get calling party number
										MessageBox.Show("Fail to call SpyGetCallerId");
									CicState[nCic].szCallerId += '\0';
									CicState[nCic].szCallerId = System.Text.Encoding.ASCII.GetString(szCallerId);	

									if(SpyGetCalleeId(nCic, szCallerId) == -1)//Get called party number
										MessageBox.Show("Fail to call SpyGetCalleeId");
									CicState[nCic].szCalleeId += '\0';
									CicState[nCic].szCalleeId = System.Text.Encoding.ASCII.GetString(szCallerId);	
								}
								break;			
							//Talking
							case S_SPY_TALKING:
								{
									if(CicState[nCic].nCicState == (int)CIRCUIT_STATE.CIRCUIT_RCV_PHONUM)
									{
										CicState[nCic].szCallerId= "";
										CicState[nCic].szCalleeId = "";
										if(SpyGetCallerId(nCic, szCallerId) == -1)//Get calling party number
											MessageBox.Show("Fail to call SpyGetCallerId");
										CicState[nCic].szCallerId += '\0';
										CicState[nCic].szCallerId = System.Text.Encoding.ASCII.GetString(szCallerId);	

										if(SpyGetCalleeId(nCic, szCallerId) == -1)//Get called party number
											MessageBox.Show("Fail to call SpyGetCalleeId");
										CicState[nCic].szCalleeId += '\0';
										CicState[nCic].szCalleeId = System.Text.Encoding.ASCII.GetString(szCallerId);	
									}
									if((CicState[nCic].nCallInCh = SpyGetCallInCh(nCic)) == -1)	//Get the number of incoming channel
										MessageBox.Show("Fail to call SpyGetCallInCh");
									if((CicState[nCic].nCallOutCh = SpyGetCallOutCh(nCic)) == -1)//Get the number of outgoing channel
										MessageBox.Show("Fail to call SpyGetCallOutCh");
									CicState[nCic].nCicState = (int)CIRCUIT_STATE.CIRCUIT_TALKING;

									
									//recording file name + channel Id + time
									szTemp = "Test" + nCic.ToString() + "." + System.DateTime.Now.Hour.ToString() + "="
										+ System.DateTime.Now.Minute.ToString() + "=" + System.DateTime.Now.Second.ToString()
										+ ".wav";
									if(m_nCallFnMode == 0)	//Call the function with circuit number as its parameter
									{
										if(SpyRecToFile(nCic, CicState[nCic].wRecDirection, szTemp, -1, 0, -1, -1, 0) == -1)
											MessageBox.Show("Fail to call SpyRecToFile");
									}
									else		//Call the function with channel number as its parameter
									{
										if(CicState[nCic].wRecDirection == (int)RECORD_DIRECTION.CALL_IN_RECORD)
										{
											if(SsmRecToFile(CicState[nCic].nCallInCh, szTemp, -1, 0, -1, -1, 0) == -1)
												MessageBox.Show("Fail to call SsmRecToFile");
										}
										else if(CicState[nCic].wRecDirection == (int)RECORD_DIRECTION.CALL_OUT_RECORD)
										{
											if(SsmRecToFile(CicState[nCic].nCallOutCh, szTemp, -1, 0, -1, -1, 0) == -1)
												MessageBox.Show("Fail to call SsmRecToFile");
										}
										else
										{
											if(SsmLinkFrom(CicState[nCic].nCallOutCh, CicState[nCic].nCallInCh) == -1)  //Connect the bus from outgoing channel to incoming channel
												MessageBox.Show("Fail to call SsmLinkFrom");
											if(SsmSetRecMixer(CicState[nCic].nCallInCh, true, 0) == -1)		//Turn on the record mixer
												MessageBox.Show("Fail to call SsmSetRecMixer");
											if(SsmRecToFile(CicState[nCic].nCallInCh, szTemp, -1, 0, -1, -1, 0) == -1)//Recording
												MessageBox.Show("Fail to call SsmRecToFile");
										}
									}
								}
								break;
							default:
								break;
							}
						}		
						break;
					
					//Event generated by the driver when DTMF is received
					case E_CHG_RcvDTMF:
					
						nCh = (int)m.WParam;
						//Switching from channel number to circuit number
 						if((nCic = SpyChToCic(nCh)) == -1)
						{
							MessageBox.Show("Fail to call SpyChToCic");
						}

						if(nCic != -1)
						{
							if(CicState[nCic].nCicState == (int)CIRCUIT_STATE.CIRCUIT_TALKING)
							{
								cNewDtmf = (char)(0xFFFF & (int)m.LParam);	//Newly received DTMF
								if(nCh == CicState[nCic].nCallInCh)
								{
									CicState[nCic].szCallInDtmf[CicState[nCic].nCallInIndex] = cNewDtmf;
									CicState[nCic].nCallInIndex++;
								}
								else if(nCh == CicState[nCic].nCallOutCh)
								{
									CicState[nCic].szCallOutDtmf[CicState[nCic].nCallOutIndex] = cNewDtmf;
									CicState[nCic].nCallOutIndex++; 
								}
							}
						}
						break;
				}
				UpdateCircuitListCtrl();
			}

			base.WndProc(ref m);
		}
		private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
		{
			if(radioButton1.Checked == true)
			{
				m_nCallFnMode = 0;
			}
		}

		private void radioButton4_CheckedChanged(object sender, System.EventArgs e)
		{
			if(radioButton4.Checked == true)
			{
				if(comboBox1.Text != "")
				{
					CicState[int.Parse(comboBox1.Text)].wRecDirection  = (int)RECORD_DIRECTION.CALL_OUT_RECORD;
				}			
			}			
		}

		private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
		{
			if(radioButton2.Checked == true)
			{
				m_nCallFnMode = 1;
			}		
		}

		private void radioButton3_CheckedChanged(object sender, System.EventArgs e)
		{
			if(radioButton3.Checked == true)
			{
				if(comboBox1.Text != "")
				{
					CicState[int.Parse(comboBox1.Text)].wRecDirection  = (int)RECORD_DIRECTION.CALL_IN_RECORD;
				}			
			}		
		}

		private void radioButton5_CheckedChanged(object sender, System.EventArgs e)
		{
			if(radioButton5.Checked == true)
			{
				if(comboBox1.Text != "")
				{
					CicState[int.Parse(comboBox1.Text)].wRecDirection  = (int)RECORD_DIRECTION.MIX_RECORD;
				}			
			}	
		}

		private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(comboBox1.Text != "None")
			{
				int nSel = int.Parse(comboBox1.Text);
				switch(CicState[nSel].wRecDirection)
				{
					case (int)RECORD_DIRECTION.CALL_IN_RECORD:		
						radioButton3.Checked = true;
						radioButton4.Checked = false;
						radioButton5.Checked = false;
						break;
					case (int)RECORD_DIRECTION.CALL_OUT_RECORD:		
						radioButton3.Checked = false;
						radioButton4.Checked = true;
						radioButton5.Checked = false;
						break;
					case (int)RECORD_DIRECTION.MIX_RECORD:			
						radioButton3.Checked = false;
						radioButton4.Checked = false;
						radioButton5.Checked = true;
						break;
				}
			}		
		}

		private void listView1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}
	}
}

⌨️ 快捷键说明

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