how to use TapieX component in c sharp????

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Richi Pandey

    how to use TapieX component in c sharp????

    Code:
    using System.Diagnostics;
    using TAPI3Lib;
    using System;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Collections;
    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using IVR_C;
    
    
    
    namespace IVR_C
    {
        public partial class Form1:Form
        {
            public class Form1partial : System.Windows.Forms.Form
            {
                [STAThread]
                static void Main()
                {
                    Application.Run(new Form1partial());
                }
                #region "Windows Form Designer generated code "
                public Form1partial()
                {
                    if (m_vb6FormDefInstance == null)
                    {
                        if (m_InitializingDefInstance)
                        {
                            m_vb6FormDefInstance = this;
                        }
                        else
                        {
                            try
                            {
                                //For the start-up form, the first instance created is the default instance.
                                if (System.Reflection.Assembly.GetExecutingAssembly().EntryPoint.DeclaringType == this.GetType())
                                {
                                    m_vb6FormDefInstance = this;
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    //This call is required by the Windows Form Designer.
                    InitializeComponent();
                }
            }
    		//Form overrides dispose to clean up the component list.
    		protected override void Dispose (bool Disposing)
    		{
    			if (Disposing)
    			{
    				if (!Convert.ToBoolean( components == null))
    				{
    					components.Dispose();
    				}
    			}
    			base.Dispose(Disposing);
    		}
    		//Required by the Windows Form Designer
    		//private System.ComponentModel.Container components = null;
    		public System.Windows.Forms.ToolTip ToolTip1;
    		public System.Windows.Forms.TextBox EdAutoAnswerRingCount;
    		public System.Windows.Forms.CheckBox CBAcceptOnOffering;
    		public System.Windows.Forms.CheckBox CbAnswerOnOffering;
    		public System.Windows.Forms.Label Label3;
    		public System.Windows.Forms.GroupBox Frame1;
    		public System.Windows.Forms.TextBox TxtLog;
    		public System.Windows.Forms.Button BnClose;
    		public System.Windows.Forms.Button BnOpen;
    		public System.Windows.Forms.ListBox LtLines;
    		
    		public System.Windows.Forms.Label Label1;
    //NOTE: The following procedure is required by the Windows Form Designer
    		//It can be modified using the Windows Form Designer.
    		//Do not modify it using the code editor.
    		internal AxTAPIEXLib.AxTAPIExCtl mTAPIEx;
    		[System.Diagnostics.DebuggerStepThrough()]
            private void InitializeComponent ()
    		{
    			this.components = new System.ComponentModel.Container();
    			base.Load += new System.EventHandler(Form1_Load);
    			base.Closed += new System.EventHandler(Form1_Closed);
    			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1partial));
    			this.ToolTip1 = new System.Windows.Forms.ToolTip(this.components);
    			this.Frame1 = new System.Windows.Forms.GroupBox();
    			this.EdAutoAnswerRingCount = new System.Windows.Forms.TextBox();
    			this.CBAcceptOnOffering = new System.Windows.Forms.CheckBox();
    			this.CbAnswerOnOffering = new System.Windows.Forms.CheckBox();
    			this.Label3 = new System.Windows.Forms.Label();
    			this.TxtLog = new System.Windows.Forms.TextBox();
    			this.BnClose = new System.Windows.Forms.Button();
    			BnClose.Click += new System.EventHandler(BnClose_Click);
    			this.BnOpen = new System.Windows.Forms.Button();
    			BnOpen.Click += new System.EventHandler(BnOpen_Click);
    			this.LtLines = new System.Windows.Forms.ListBox();
    			this.Label1 = new System.Windows.Forms.Label();
    			this.mTAPIEx = new AxTAPIEXLib.AxTAPIExCtl();
    			mTAPIEx.OnConnected += new AxTAPIEXLib._ITAPIExEvents_OnConnectedEventHandler(mTapiex_OnConnected);
    			mTAPIEx.OnDebug += new AxTAPIEXLib._ITAPIExEvents_OnDebugEventHandler(mTapiex_OnDebug);
    			mTAPIEx.OnDTMF += new AxTAPIEXLib._ITAPIExEvents_OnDTMFEventHandler(mTapiex_OnDTMF);
    			mTAPIEx.OnDTMFTimeOut += new AxTAPIEXLib._ITAPIExEvents_OnDTMFTimeOutEventHandler(mTAPIEx_OnDTMFTimeOut);
    			mTAPIEx.OnCallStateChange += new AxTAPIEXLib._ITAPIExEvents_OnCallStateChangeEventHandler(mTAPIEx_OnCallStateChange);
    			mTAPIEx.OnOffering += new AxTAPIEXLib._ITAPIExEvents_OnOfferingEventHandler(mTAPIEx_OnOffering);
    			mTAPIEx.OnPlayBackComplete += new AxTAPIEXLib._ITAPIExEvents_OnPlayBackCompleteEventHandler(mTapiex_OnPlayBackComplete);
    			mTAPIEx.OnRing += new AxTAPIEXLib._ITAPIExEvents_OnRingEventHandler(mTapiex_OnRing);
    			this.Frame1.SuspendLayout();
    			((System.ComponentModel.ISupportInitialize)(this.mTAPIEx)).BeginInit();
    			this.SuspendLayout();
    			//
    			//Frame1
    			//
    			this.Frame1.BackColor = System.Drawing.SystemColors.Control;
    			this.Frame1.Controls.Add(this.EdAutoAnswerRingCount);
    			this.Frame1.Controls.Add(this.CBAcceptOnOffering);
    			this.Frame1.Controls.Add(this.CbAnswerOnOffering);
    			this.Frame1.Controls.Add(this.Label3);
    			this.Frame1.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.Frame1.ForeColor = System.Drawing.SystemColors.ControlText;
    			this.Frame1.Location = new System.Drawing.Point(8, 72);
    			this.Frame1.Name = "Frame1";
    			this.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.Frame1.Size = new System.Drawing.Size(480, 64);
    			this.Frame1.TabIndex = 6;
    			this.Frame1.TabStop = false;
    			this.Frame1.Text = "Options";
    			//
    			//EdAutoAnswerRingCount
    			//
    			this.EdAutoAnswerRingCount.AcceptsReturn = true;
    			this.EdAutoAnswerRingCount.AutoSize = false;
    			this.EdAutoAnswerRingCount.BackColor = System.Drawing.SystemColors.Window;
    			this.EdAutoAnswerRingCount.Cursor = System.Windows.Forms.Cursors.IBeam;
    			this.EdAutoAnswerRingCount.Font = new System.Drawing.Font("Arial", (float) (8.0), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.EdAutoAnswerRingCount.ForeColor = System.Drawing.SystemColors.WindowText;
    			this.EdAutoAnswerRingCount.Location = new System.Drawing.Point(136, 16);
    			this.EdAutoAnswerRingCount.MaxLength = 0;
    			this.EdAutoAnswerRingCount.Name = "EdAutoAnswerRingCount";
    			this.EdAutoAnswerRingCount.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.EdAutoAnswerRingCount.Size = new System.Drawing.Size(25, 19);
    			this.EdAutoAnswerRingCount.TabIndex = 9;
    			this.EdAutoAnswerRingCount.Text = "2";
    			//
    			//CBAcceptOnOffering
    			//
    			this.CBAcceptOnOffering.BackColor = System.Drawing.SystemColors.Control;
    			this.CBAcceptOnOffering.Cursor = System.Windows.Forms.Cursors.Default;
    			this.CBAcceptOnOffering.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.CBAcceptOnOffering.ForeColor = System.Drawing.SystemColors.ControlText;
    			this.CBAcceptOnOffering.Location = new System.Drawing.Point(8, 35);
    			this.CBAcceptOnOffering.Name = "CBAcceptOnOffering";
    			this.CBAcceptOnOffering.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.CBAcceptOnOffering.Size = new System.Drawing.Size(216, 17);
    			this.CBAcceptOnOffering.TabIndex = 8;
    			this.CBAcceptOnOffering.Text = "Accept on offering (for ISDN line)";
    			//
    			//CbAnswerOnOffering
    			//
    			this.CbAnswerOnOffering.BackColor = System.Drawing.SystemColors.Control;
    			this.CbAnswerOnOffering.Cursor = System.Windows.Forms.Cursors.Default;
    			this.CbAnswerOnOffering.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.CbAnswerOnOffering.ForeColor = System.Drawing.SystemColors.ControlText;
    			this.CbAnswerOnOffering.Location = new System.Drawing.Point(248, 24);
    			this.CbAnswerOnOffering.Name = "CbAnswerOnOffering";
    			this.CbAnswerOnOffering.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.CbAnswerOnOffering.Size = new System.Drawing.Size(168, 32);
    			this.CbAnswerOnOffering.TabIndex = 7;
    			this.CbAnswerOnOffering.Text = "Answer on offering (for IP or digital line)";
    			//
    			//Label3
    			//
    			this.Label3.BackColor = System.Drawing.SystemColors.Control;
    			this.Label3.Cursor = System.Windows.Forms.Cursors.Default;
    			this.Label3.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.Label3.ForeColor = System.Drawing.SystemColors.ControlText;
    			this.Label3.Location = new System.Drawing.Point(16, 16);
    			this.Label3.Name = "Label3";
    			this.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.Label3.Size = new System.Drawing.Size(121, 17);
    			this.Label3.TabIndex = 4;
    			this.Label3.Text = "Auto Answer after Ring";
    			//
    			//TxtLog
    			//
    			this.TxtLog.AcceptsReturn = true;
    			this.TxtLog.AutoSize = false;
    			this.TxtLog.BackColor = System.Drawing.SystemColors.Window;
    			this.TxtLog.Cursor = System.Windows.Forms.Cursors.IBeam;
    			this.TxtLog.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.TxtLog.ForeColor = System.Drawing.SystemColors.WindowText;
    			this.TxtLog.Location = new System.Drawing.Point(0, 144);
    			this.TxtLog.MaxLength = 0;
    			this.TxtLog.Multiline = true;
    			this.TxtLog.Name = "TxtLog";
    			this.TxtLog.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.TxtLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
    			this.TxtLog.Size = new System.Drawing.Size(496, 216);
    			this.TxtLog.TabIndex = 5;
    			this.TxtLog.Text = "";
    			this.TxtLog.WordWrap = false;
    			//
    			//BnClose
    			//
    			this.BnClose.BackColor = System.Drawing.SystemColors.Control;
    			this.BnClose.Cursor = System.Windows.Forms.Cursors.Default;
    			this.BnClose.Enabled = false;
    			this.BnClose.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.BnClose.ForeColor = System.Drawing.SystemColors.ControlText;
    			this.BnClose.Location = new System.Drawing.Point(328, 40);
    			this.BnClose.Name = "BnClose";
    			this.BnClose.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.BnClose.Size = new System.Drawing.Size(97, 25);
    			this.BnClose.TabIndex = 3;
    			this.BnClose.Text = "Close All";
    			//
    			//BnOpen
    			//
    			this.BnOpen.BackColor = System.Drawing.SystemColors.Control;
    			this.BnOpen.Cursor = System.Windows.Forms.Cursors.Default;
    			this.BnOpen.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    			this.BnOpen.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.BnOpen.ForeColor = System.Drawing.SystemColors.ControlText;
    			this.BnOpen.Location = new System.Drawing.Point(328, 8);
    			this.BnOpen.Name = "BnOpen";
    			this.BnOpen.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.BnOpen.Size = new System.Drawing.Size(97, 25);
    			this.BnOpen.TabIndex = 2;
    			this.BnOpen.Text = "Open All";
    			//
    			//LtLines
    			//
    			this.LtLines.BackColor = System.Drawing.SystemColors.Window;
    			this.LtLines.Cursor = System.Windows.Forms.Cursors.Default;
    			this.LtLines.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.LtLines.ForeColor = System.Drawing.SystemColors.WindowText;
    			this.LtLines.ItemHeight = 15;
    			this.LtLines.Location = new System.Drawing.Point(8, 24);
    			this.LtLines.Name = "LtLines";
    			this.LtLines.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.LtLines.Size = new System.Drawing.Size(297, 34);
    			this.LtLines.TabIndex = 0;
    			//
    			//Label1
    			//
    			this.Label1.BackColor = System.Drawing.SystemColors.Control;
    			this.Label1.Cursor = System.Windows.Forms.Cursors.Default;
    			this.Label1.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.Label1.ForeColor = System.Drawing.SystemColors.ControlText;
    			this.Label1.Location = new System.Drawing.Point(8, 8);
    			this.Label1.Name = "Label1";
    			this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.Label1.Size = new System.Drawing.Size(113, 17);
    			this.Label1.TabIndex = 1;
    			this.Label1.Text = "Devices";
    			//
    			//mTAPIEx
    			//
    			this.mTAPIEx.Enabled = true;
    			this.mTAPIEx.Location = new System.Drawing.Point(448, 32);
    			this.mTAPIEx.Name = "mTAPIEx";
    			this.mTAPIEx.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("mTAPIEx.OcxState")));
    			this.mTAPIEx.Size = new System.Drawing.Size(30, 30);
    			this.mTAPIEx.TabIndex = 7;
    			//
    			//Form1
    			//
    			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
    			this.BackColor = System.Drawing.SystemColors.Control;
    			this.CancelButton = this.BnOpen;
    			this.ClientSize = new System.Drawing.Size(504, 366);
    			this.Controls.Add(this.mTAPIEx);
    			this.Controls.Add(this.Frame1);
    			this.Controls.Add(this.TxtLog);
    			this.Controls.Add(this.BnClose);
    			this.Controls.Add(this.BnOpen);
    			this.Controls.Add(this.LtLines);
    			this.Controls.Add(this.Label1);
    			this.Cursor = System.Windows.Forms.Cursors.Default;
    			this.Font = new System.Drawing.Font("Arial", (float) (8.0), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
    			this.Location = new System.Drawing.Point(4, 23);
    			this.Name = "Form1";
    			this.RightToLeft = System.Windows.Forms.RightToLeft.No;
    			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
    			this.Text = "Simple IVRS Demo";
    			this.Frame1.ResumeLayout(false);
    			((System.ComponentModel.ISupportInitialize)(this.mTAPIEx)).EndInit();
    			this.ResumeLayout(false);
    			
    		}
    		#endregion
    		#region "Upgrade Support "
    		private static Form1partial m_vb6FormDefInstance;
    		private static bool m_InitializingDefInstance;
    		public static Form1partial DefInstance
    		{
    			get{
    				Form1partial returnValue;
    				if (m_vb6FormDefInstance == null || m_vb6FormDefInstance.IsDisposed)
    				{
    					m_InitializingDefInstance = true;
    					m_vb6FormDefInstance = new Form1partial();
    					m_InitializingDefInstance = false;
    				}
    				returnValue = m_vb6FormDefInstance;
    				return returnValue;
    			}
    			set
    			{
    				m_vb6FormDefInstance = value;
    			}
    		}
    		#endregion
    		//######################################################################################
    		//# Program name: Simple IVR Demo                                                      #
    		//#                                                                                    #
    		//# Version: v1.5                                                                      #
    		//#                                                                                    #
    		//# Last modification Date: Nov. 23th 2004                                             #
    		//#                                                                                    #
    		//# Requirements: TAPIEx control,  VOICE modem or TAPI compliant telephony device      #
    		//#                                                                                    #
    		//# Operating System: Windows 98, Windows ME, Windows NT 4, Windows 2000, Windows XP   #
    		//#                                                                                    #
    		//# Note: Under Windows NT 4 voice modems may not supported because of the lack of a   #
    		//# voice capable TAPI universal modem driver.                                         #
    		//#                                                                                    #
    		//# Program Purpose: To demonstrate how to add telephony functions to your application #
    		//# using the TAPIEx ActiveX control.                                                  #
    		//#                                                                                    #
    		//######################################################################################
    		const string WAVE_PATH = "../../../wave_pcm/";
    		
    		public class CLineDevice
    		{
    			public string m_Name;
    			public int m_ID;
    			public override string ToString()
    			{
    				return m_Name;
    			}
    		}
    		
    		private void BnClose_Click (System.Object eventSender, System.EventArgs eventArgs)
    		{
    			mTAPIEx.CloseAll();
    			BnOpen.Enabled = true;
    			BnClose.Enabled = ! BnOpen.Enabled;
    		}
    		
    		private void BnOpen_Click (System.Object eventSender, System.EventArgs eventArgs)
    		{
    			short i;
    			CLineDevice lDevice;
    			for (i = 0; i <= LtLines.Items.Count - 1; i++)
    			{
    				
    				lDevice=(CLineDevice)LtLines.Items[i];
    				mTAPIEx.Lines.Item(lDevice.m_ID).Open(); //Open the line
    			}
    			
    			BnOpen.Enabled = false;
    			BnClose.Enabled = ! BnOpen.Enabled;
    		}
    		
    		
    		private void Form1_Load (System.Object eventSender, System.EventArgs eventArgs)
    		{
    			TAPIEXLib.ITAPILine line;
    			
    			mTAPIEx.initialize(); //Initialize
    			foreach (TAPIEXLib.ITAPILine tempLoopVar_line in mTAPIEx.Lines) //enumerate the line devices
    			{
    				line = tempLoopVar_line;
    				if (Convert.ToBoolean(line.Caps.Media_Modes & TAPIEXLib.LINEMEDIAMODE.MEDIAMODE_AUTOMATEDVOICE) || Convert.ToBoolean(line.Caps.Media_Modes & TAPIEXLib.LINEMEDIAMODE.MEDIAMODE_INTERACTIVEVOICE))
    				{
    					CLineDevice lDevice = new CLineDevice();
    					lDevice.m_Name = line.DeviceName;
    					lDevice.m_ID = line.DeviceID;
    					LtLines.Items.Add(lDevice);
    				}
    			}
    		}
    		
    //UPGRADE_WARNING: Form event Form1.Unload has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2065"'
    		private void Form1_Closed (System.Object eventSender, System.EventArgs eventArgs)
    		{
    			mTAPIEx.UnInitialize();
    		}
    		
    		private void mTapiex_OnConnected (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnConnectedEvent eventArgs)
    		{
    			eventArgs.m_Call.PlaybackFile(WAVE_PATH + "welcome.wav");
    			eventArgs.m_Call.PlaybackFile(WAVE_PATH + "menu.wav");
    			eventArgs.m_Call.User_Data1 = 0;
    			eventArgs.m_Call.User_Data2 = 0;
    		}
    		
    		private void mTapiex_OnDebug (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnDebugEvent eventArgs)
    		{
    			TxtLog.Text = eventArgs.msg + Convert.ToChar(13) + Convert.ToChar(10) + TxtLog.Text;
    		}
    		
    		private void mTapiex_OnDTMF (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnDTMFEvent eventArgs)
    		{
    			if (System.Convert.ToInt32(eventArgs.m_Call.User_Data1) == 1) //"any key to hang up the call"
    			{
    				
    				eventArgs.m_Call.StopRecord();
    				eventArgs.m_Call.PlaybackFile(WAVE_PATH + "rec_end.wav");
    			}
    			else
    			{
    				switch (Convert.ToChar(eventArgs.keyCode))
    				{
    					default:
    						if (Convert.ToChar(eventArgs.keyCode) == '3')
    						{
    							
    							eventArgs.m_Call.StopPlayBack();
    							eventArgs.m_Call.PlaybackFile(WAVE_PATH + "Menu_Opt" + Convert.ToChar(eventArgs.keyCode) + ".wav");
    							//play the option wave
    							eventArgs.m_Call.User_Data1 = 1; //recording message, then any key to stop
    							eventArgs.m_Call.Record("rec_message_" + eventArgs.m_Call.Handle + "_.wav");
    							break;
    							//will record the user's messages
    						}
    						if (Convert.ToChar(eventArgs.keyCode) == '2')
    						{
    							
    							eventArgs.m_Call.StopPlayBack();
    							eventArgs.m_Call.PlaybackFile(WAVE_PATH + "Menu_Opt" + Convert.ToChar(eventArgs.keyCode) + ".wav");
    							break;
    						}
    						if (Convert.ToChar(eventArgs.keyCode) == '1')
    						{
    							eventArgs.m_Call.StopPlayBack();
    							eventArgs.m_Call.PlaybackFile(WAVE_PATH + "Menu_Opt" + Convert.ToChar(eventArgs.keyCode) + ".wav");
    							break;
    							
    						}
    						break;
    				}
    			}
    		}
    		
    		
    		private void mTAPIEx_OnDTMFTimeOut (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnDTMFTimeOutEvent eventArgs)
    		{
    			eventArgs.m_Call.DTMF_TimeOut = 0;
    			eventArgs.m_Call.StopPlayBack();
    			eventArgs.m_Call.PlaybackFile(WAVE_PATH + "timeout.wav");
    		}
    		
    		
    		//Normally for ISDN incoming calls:
    		//CALLSTATE (OFFERING)
    		//Accept()
    		//CALLSTATE (ACCEPTED)
    		//Answer()
    		//CALLSTATE (CONNECTED)
    		
    		private void mTAPIEx_OnCallStateChange (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnCallStateChangeEvent eventArgs)
    		{
    			if ((eventArgs.newState == TAPIEXLib.TAPI_CALLSTATE.CALLSTATE_ACCEPTED) && (System.Convert.ToInt32(eventArgs.m_Call.User_Data2) == 1))
    			{
    				//ISDN need answer the call on accept
    				eventArgs.m_Call.Answer();
    				eventArgs.m_Call.User_Data2 = 0;
    			}
    		}
    		
    		private void mTAPIEx_OnOffering (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnOfferingEvent eventArgs)
    		{
    			if (System.Convert.ToBoolean(CBAcceptOnOffering.CheckState)) // for ISDN
    			{
    				eventArgs.m_Call.Accept( ""); // Accept the call
    				eventArgs.m_Call.User_Data2 = 1;
    			}
    			
    			if (System.Convert.ToBoolean(CbAnswerOnOffering.CheckState)) // answer the call on offering
    			{
    				eventArgs.m_Call.Answer();
    			}
    		}
    		
    		private void mTapiex_OnPlayBackComplete (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnPlayBackCompleteEvent eventArgs)
    		{
    			
    			if (eventArgs.m_Call.ActivePlayBackFile == WAVE_PATH + "menu.wav") //after the menu wave , time 30 seconds DTMF timeout
    			{
    				eventArgs.m_Call.DTMF_TimeOut = 30;
    			}
    			else
    			{
    				if (eventArgs.m_Call.ActivePlayBackFile == WAVE_PATH + "rec_end.wav" | eventArgs.m_Call.ActivePlayBackFile == WAVE_PATH + "timeout.wav")
    				{
    					eventArgs.m_Call.Drop();
    				}
    				//after the end  or timeout wave playback completed, drop the call.
    			}
    			
    		}
    		
    		private void mTapiex_OnRing (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnRingEvent eventArgs)
    		{
    			System.Diagnostics.Debug.WriteLine(eventArgs.ringCount);
    			if (eventArgs.ringCount >= System.Convert.ToInt16(EdAutoAnswerRingCount.Text))
    			{
    				eventArgs.m_Call.Answer();
    			}
    		}
    	}
    }
    Last edited by MMcCarthy; Oct 18 '10, 09:03 AM. Reason: added code tags
Working...