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

📄 form1.cs

📁 TAPI 3.0 Application development using C#.NET
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.checkBox1.Location = new System.Drawing.Point(264, 280);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(112, 16);
			this.checkBox1.TabIndex = 13;
			this.checkBox1.Text = "H.323 call(IP call)";
			this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
			// 
			// button5
			// 
			this.button5.Location = new System.Drawing.Point(536, 112);
			this.button5.Name = "button5";
			this.button5.TabIndex = 14;
			this.button5.Text = "Transfer";
			this.button5.Click += new System.EventHandler(this.button5_Click);
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(520, 80);
			this.textBox2.Name = "textBox2";
			this.textBox2.TabIndex = 15;
			this.textBox2.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(520, 56);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(88, 16);
			this.label3.TabIndex = 16;
			this.label3.Text = "tranfer address";
			// 
			// button6
			// 
			this.button6.Location = new System.Drawing.Point(520, 24);
			this.button6.Name = "button6";
			this.button6.TabIndex = 17;
			this.button6.Text = "Register";
			this.button6.Click += new System.EventHandler(this.button6_Click);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(632, 326);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.button6,
																		  this.label3,
																		  this.textBox2,
																		  this.button5,
																		  this.checkBox1,
																		  this.groupBox2,
																		  this.button4,
																		  this.button3,
																		  this.button2,
																		  this.label2,
																		  this.textBox1,
																		  this.groupBox1,
																		  this.label1,
																		  this.comboBox1});
			this.Name = "Form1";
			this.Text = "tapi3_dev";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			line=comboBox1.SelectedIndex;
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			TAPI3Lib.ITAddress ln=null;
			ln=ia[line];
			if(textBox1.Text.Length!=0)
			{
				MessageBox.Show(""+textBox1.Text,"Calling to");				
				try
				{
					if(!h323)
					{
						bcc = ln.CreateCall(textBox1.Text,TapiConstants.LINEADDRESSTYPE_PHONENUMBER|TapiConstants.LINEADDRESSTYPE_IPADDRESS,TapiConstants.TAPIMEDIATYPE_DATAMODEM|TapiConstants.TAPIMEDIATYPE_AUDIO);
						bcc.SetQOS(TapiConstants.TAPIMEDIATYPE_DATAMODEM|TapiConstants.TAPIMEDIATYPE_AUDIO,QOS_SERVICE_LEVEL.QSL_BEST_EFFORT);
						bcc.Connect(false);
					}
					else
					{
						bcc = ln.CreateCall(textBox1.Text,TapiConstants.LINEADDRESSTYPE_IPADDRESS,TapiConstants.TAPIMEDIATYPE_AUDIO);
						bcc.Connect(false);
					}
				}
				catch(Exception exp)
				{
					MessageBox.Show("Failed to create call!","TAPI3");
				}
			}
			else
			{
				MessageBox.Show("Please enter number to dial.. ");
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			listBox1.Items.Clear();
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			IEnumCall ec = ia[line].EnumerateCalls();
			uint arg=0;
			ITCallInfo ici;
			try
			{
				ec.Next(1,out ici,ref arg);
				ITBasicCallControl bc=(TAPI3Lib.ITBasicCallControl)ici;
				if(!reject)
				{
					bc.Answer();
				}
				else
				{
					bc.Disconnect(DISCONNECT_CODE.DC_REJECTED);
					ici.ReleaseUserUserInfo();
				}
			}
			catch(Exception exp)
			{
				MessageBox.Show("There may not be any calls to answer! \n\n"+exp.ToString(),"TAPI3");
			}
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			IEnumCall ec = ia[line].EnumerateCalls();
			uint arg = 0;
			ITCallInfo ici;
			try
			{
				ec.Next(1,out ici,ref arg);
				ITBasicCallControl bc=(ITBasicCallControl)ici;
				bc.Disconnect(DISCONNECT_CODE.DC_NORMAL);
				ici.ReleaseUserUserInfo();
			}
			catch(Exception exp)
			{
				MessageBox.Show("No call to disconnect!","TAPI3");
			}
		}

		private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
		{
			h323=checkBox1.Checked;
		}

		private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
		{
			reject=checkBox2.Checked;
		}

		private void button5_Click(object sender, System.EventArgs e)
		{
			IEnumCall ec = ia[line].EnumerateCalls();
			uint arg = 0;
			ITCallInfo ici;
			try
			{
				ec.Next(1,out ici,ref arg);
				ITBasicCallControl bc=(ITBasicCallControl)ici;
				bc.BlindTransfer(textBox2.Text);
				ici.ReleaseUserUserInfo();
			}
			catch(Exception exp)
			{
				MessageBox.Show("May not have any call to disconnect!\n\n"+exp.ToString(),"TAPI3");
			}
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			MessageBox.Show("To recieve calls from any line you need to register on that line\n,you can do this by selecting the line ansd press the register button!","Instruction");
		}

		private void button6_Click(object sender, System.EventArgs e)
		{
			try
			{
				registertoken[line]=tobj.RegisterCallNotifications(ia[line],true,true,TapiConstants.TAPIMEDIATYPE_AUDIO,2);	
				MessageBox.Show("Registration token : "+registertoken[line],"Registration Succeed for line "+line);
			}
			catch(Exception ein)
			{
				MessageBox.Show("Failed to register on line "+line,"Registration for calls");
			}
		}
	}
	class callnotification:TAPI3Lib.ITTAPIEventNotification
	{
		public delegate void listshow(string str);
		public listshow addtolist;
		
		public void Event(TAPI3Lib.TAPI_EVENT te,object eobj)
		{
			switch(te)
			{
				case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION:
					addtolist("call notification event has occured");
					break;
				case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT:
					TAPI3Lib.ITDigitDetectionEvent dd=(TAPI3Lib.ITDigitDetectionEvent)eobj;
					addtolist("Dialed digit"+dd.ToString());
					break;
				case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT:
					TAPI3Lib.ITDigitGenerationEvent dg=(TAPI3Lib.ITDigitGenerationEvent)eobj;
					MessageBox.Show("digit dialed!");
					addtolist("Dialed digit"+dg.ToString());
					break;
				case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT:
					addtolist("A phone event!");
					break;
				case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS:
					addtolist("Gather digit event!");
					break;
				case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
					TAPI3Lib.ITCallStateEvent a=(TAPI3Lib.ITCallStateEvent)eobj;
					TAPI3Lib.ITCallInfo b=a.Call;
				switch(b.CallState)
				{
					case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
						addtolist("dialing");
						break;
					case TAPI3Lib.CALL_STATE.CS_CONNECTED:
						addtolist("Connected");
						break;
					case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
						addtolist("Disconnected");
						break;
					case TAPI3Lib.CALL_STATE.CS_OFFERING:
						addtolist("A party wants to communicate with you!");
						break;
					case TAPI3Lib.CALL_STATE.CS_IDLE:
						addtolist("Call is created!");
						break;
				}
				break;
			}
		}
	}
}

⌨️ 快捷键说明

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