473,480 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

Expand|Select|Wrap|Line Numbers
  1. using System.Diagnostics;
  2. using TAPI3Lib;
  3. using System;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. using System.Collections;
  8. using System.Reflection;
  9. using System.Runtime.CompilerServices;
  10. using System.Runtime.InteropServices;
  11. using IVR_C;
  12.  
  13.  
  14.  
  15. namespace IVR_C
  16. {
  17.     public partial class Form1:Form
  18.     {
  19.         public class Form1partial : System.Windows.Forms.Form
  20.         {
  21.             [STAThread]
  22.             static void Main()
  23.             {
  24.                 Application.Run(new Form1partial());
  25.             }
  26.             #region "Windows Form Designer generated code "
  27.             public Form1partial()
  28.             {
  29.                 if (m_vb6FormDefInstance == null)
  30.                 {
  31.                     if (m_InitializingDefInstance)
  32.                     {
  33.                         m_vb6FormDefInstance = this;
  34.                     }
  35.                     else
  36.                     {
  37.                         try
  38.                         {
  39.                             //For the start-up form, the first instance created is the default instance.
  40.                             if (System.Reflection.Assembly.GetExecutingAssembly().EntryPoint.DeclaringType == this.GetType())
  41.                             {
  42.                                 m_vb6FormDefInstance = this;
  43.                             }
  44.                         }
  45.                         catch
  46.                         {
  47.                         }
  48.                     }
  49.                 }
  50.                 //This call is required by the Windows Form Designer.
  51.                 InitializeComponent();
  52.             }
  53.         }
  54.         //Form overrides dispose to clean up the component list.
  55.         protected override void Dispose (bool Disposing)
  56.         {
  57.             if (Disposing)
  58.             {
  59.                 if (!Convert.ToBoolean( components == null))
  60.                 {
  61.                     components.Dispose();
  62.                 }
  63.             }
  64.             base.Dispose(Disposing);
  65.         }
  66.         //Required by the Windows Form Designer
  67.         //private System.ComponentModel.Container components = null;
  68.         public System.Windows.Forms.ToolTip ToolTip1;
  69.         public System.Windows.Forms.TextBox EdAutoAnswerRingCount;
  70.         public System.Windows.Forms.CheckBox CBAcceptOnOffering;
  71.         public System.Windows.Forms.CheckBox CbAnswerOnOffering;
  72.         public System.Windows.Forms.Label Label3;
  73.         public System.Windows.Forms.GroupBox Frame1;
  74.         public System.Windows.Forms.TextBox TxtLog;
  75.         public System.Windows.Forms.Button BnClose;
  76.         public System.Windows.Forms.Button BnOpen;
  77.         public System.Windows.Forms.ListBox LtLines;
  78.  
  79.         public System.Windows.Forms.Label Label1;
  80. //NOTE: The following procedure is required by the Windows Form Designer
  81.         //It can be modified using the Windows Form Designer.
  82.         //Do not modify it using the code editor.
  83.         internal AxTAPIEXLib.AxTAPIExCtl mTAPIEx;
  84.         [System.Diagnostics.DebuggerStepThrough()]
  85.         private void InitializeComponent ()
  86.         {
  87.             this.components = new System.ComponentModel.Container();
  88.             base.Load += new System.EventHandler(Form1_Load);
  89.             base.Closed += new System.EventHandler(Form1_Closed);
  90.             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1partial));
  91.             this.ToolTip1 = new System.Windows.Forms.ToolTip(this.components);
  92.             this.Frame1 = new System.Windows.Forms.GroupBox();
  93.             this.EdAutoAnswerRingCount = new System.Windows.Forms.TextBox();
  94.             this.CBAcceptOnOffering = new System.Windows.Forms.CheckBox();
  95.             this.CbAnswerOnOffering = new System.Windows.Forms.CheckBox();
  96.             this.Label3 = new System.Windows.Forms.Label();
  97.             this.TxtLog = new System.Windows.Forms.TextBox();
  98.             this.BnClose = new System.Windows.Forms.Button();
  99.             BnClose.Click += new System.EventHandler(BnClose_Click);
  100.             this.BnOpen = new System.Windows.Forms.Button();
  101.             BnOpen.Click += new System.EventHandler(BnOpen_Click);
  102.             this.LtLines = new System.Windows.Forms.ListBox();
  103.             this.Label1 = new System.Windows.Forms.Label();
  104.             this.mTAPIEx = new AxTAPIEXLib.AxTAPIExCtl();
  105.             mTAPIEx.OnConnected += new AxTAPIEXLib._ITAPIExEvents_OnConnectedEventHandler(mTapiex_OnConnected);
  106.             mTAPIEx.OnDebug += new AxTAPIEXLib._ITAPIExEvents_OnDebugEventHandler(mTapiex_OnDebug);
  107.             mTAPIEx.OnDTMF += new AxTAPIEXLib._ITAPIExEvents_OnDTMFEventHandler(mTapiex_OnDTMF);
  108.             mTAPIEx.OnDTMFTimeOut += new AxTAPIEXLib._ITAPIExEvents_OnDTMFTimeOutEventHandler(mTAPIEx_OnDTMFTimeOut);
  109.             mTAPIEx.OnCallStateChange += new AxTAPIEXLib._ITAPIExEvents_OnCallStateChangeEventHandler(mTAPIEx_OnCallStateChange);
  110.             mTAPIEx.OnOffering += new AxTAPIEXLib._ITAPIExEvents_OnOfferingEventHandler(mTAPIEx_OnOffering);
  111.             mTAPIEx.OnPlayBackComplete += new AxTAPIEXLib._ITAPIExEvents_OnPlayBackCompleteEventHandler(mTapiex_OnPlayBackComplete);
  112.             mTAPIEx.OnRing += new AxTAPIEXLib._ITAPIExEvents_OnRingEventHandler(mTapiex_OnRing);
  113.             this.Frame1.SuspendLayout();
  114.             ((System.ComponentModel.ISupportInitialize)(this.mTAPIEx)).BeginInit();
  115.             this.SuspendLayout();
  116.             //
  117.             //Frame1
  118.             //
  119.             this.Frame1.BackColor = System.Drawing.SystemColors.Control;
  120.             this.Frame1.Controls.Add(this.EdAutoAnswerRingCount);
  121.             this.Frame1.Controls.Add(this.CBAcceptOnOffering);
  122.             this.Frame1.Controls.Add(this.CbAnswerOnOffering);
  123.             this.Frame1.Controls.Add(this.Label3);
  124.             this.Frame1.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  125.             this.Frame1.ForeColor = System.Drawing.SystemColors.ControlText;
  126.             this.Frame1.Location = new System.Drawing.Point(8, 72);
  127.             this.Frame1.Name = "Frame1";
  128.             this.Frame1.RightToLeft = System.Windows.Forms.RightToLeft.No;
  129.             this.Frame1.Size = new System.Drawing.Size(480, 64);
  130.             this.Frame1.TabIndex = 6;
  131.             this.Frame1.TabStop = false;
  132.             this.Frame1.Text = "Options";
  133.             //
  134.             //EdAutoAnswerRingCount
  135.             //
  136.             this.EdAutoAnswerRingCount.AcceptsReturn = true;
  137.             this.EdAutoAnswerRingCount.AutoSize = false;
  138.             this.EdAutoAnswerRingCount.BackColor = System.Drawing.SystemColors.Window;
  139.             this.EdAutoAnswerRingCount.Cursor = System.Windows.Forms.Cursors.IBeam;
  140.             this.EdAutoAnswerRingCount.Font = new System.Drawing.Font("Arial", (float) (8.0), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  141.             this.EdAutoAnswerRingCount.ForeColor = System.Drawing.SystemColors.WindowText;
  142.             this.EdAutoAnswerRingCount.Location = new System.Drawing.Point(136, 16);
  143.             this.EdAutoAnswerRingCount.MaxLength = 0;
  144.             this.EdAutoAnswerRingCount.Name = "EdAutoAnswerRingCount";
  145.             this.EdAutoAnswerRingCount.RightToLeft = System.Windows.Forms.RightToLeft.No;
  146.             this.EdAutoAnswerRingCount.Size = new System.Drawing.Size(25, 19);
  147.             this.EdAutoAnswerRingCount.TabIndex = 9;
  148.             this.EdAutoAnswerRingCount.Text = "2";
  149.             //
  150.             //CBAcceptOnOffering
  151.             //
  152.             this.CBAcceptOnOffering.BackColor = System.Drawing.SystemColors.Control;
  153.             this.CBAcceptOnOffering.Cursor = System.Windows.Forms.Cursors.Default;
  154.             this.CBAcceptOnOffering.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  155.             this.CBAcceptOnOffering.ForeColor = System.Drawing.SystemColors.ControlText;
  156.             this.CBAcceptOnOffering.Location = new System.Drawing.Point(8, 35);
  157.             this.CBAcceptOnOffering.Name = "CBAcceptOnOffering";
  158.             this.CBAcceptOnOffering.RightToLeft = System.Windows.Forms.RightToLeft.No;
  159.             this.CBAcceptOnOffering.Size = new System.Drawing.Size(216, 17);
  160.             this.CBAcceptOnOffering.TabIndex = 8;
  161.             this.CBAcceptOnOffering.Text = "Accept on offering (for ISDN line)";
  162.             //
  163.             //CbAnswerOnOffering
  164.             //
  165.             this.CbAnswerOnOffering.BackColor = System.Drawing.SystemColors.Control;
  166.             this.CbAnswerOnOffering.Cursor = System.Windows.Forms.Cursors.Default;
  167.             this.CbAnswerOnOffering.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  168.             this.CbAnswerOnOffering.ForeColor = System.Drawing.SystemColors.ControlText;
  169.             this.CbAnswerOnOffering.Location = new System.Drawing.Point(248, 24);
  170.             this.CbAnswerOnOffering.Name = "CbAnswerOnOffering";
  171.             this.CbAnswerOnOffering.RightToLeft = System.Windows.Forms.RightToLeft.No;
  172.             this.CbAnswerOnOffering.Size = new System.Drawing.Size(168, 32);
  173.             this.CbAnswerOnOffering.TabIndex = 7;
  174.             this.CbAnswerOnOffering.Text = "Answer on offering (for IP or digital line)";
  175.             //
  176.             //Label3
  177.             //
  178.             this.Label3.BackColor = System.Drawing.SystemColors.Control;
  179.             this.Label3.Cursor = System.Windows.Forms.Cursors.Default;
  180.             this.Label3.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  181.             this.Label3.ForeColor = System.Drawing.SystemColors.ControlText;
  182.             this.Label3.Location = new System.Drawing.Point(16, 16);
  183.             this.Label3.Name = "Label3";
  184.             this.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No;
  185.             this.Label3.Size = new System.Drawing.Size(121, 17);
  186.             this.Label3.TabIndex = 4;
  187.             this.Label3.Text = "Auto Answer after Ring";
  188.             //
  189.             //TxtLog
  190.             //
  191.             this.TxtLog.AcceptsReturn = true;
  192.             this.TxtLog.AutoSize = false;
  193.             this.TxtLog.BackColor = System.Drawing.SystemColors.Window;
  194.             this.TxtLog.Cursor = System.Windows.Forms.Cursors.IBeam;
  195.             this.TxtLog.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  196.             this.TxtLog.ForeColor = System.Drawing.SystemColors.WindowText;
  197.             this.TxtLog.Location = new System.Drawing.Point(0, 144);
  198.             this.TxtLog.MaxLength = 0;
  199.             this.TxtLog.Multiline = true;
  200.             this.TxtLog.Name = "TxtLog";
  201.             this.TxtLog.RightToLeft = System.Windows.Forms.RightToLeft.No;
  202.             this.TxtLog.ScrollBars = System.Windows.Forms.ScrollBars.Both;
  203.             this.TxtLog.Size = new System.Drawing.Size(496, 216);
  204.             this.TxtLog.TabIndex = 5;
  205.             this.TxtLog.Text = "";
  206.             this.TxtLog.WordWrap = false;
  207.             //
  208.             //BnClose
  209.             //
  210.             this.BnClose.BackColor = System.Drawing.SystemColors.Control;
  211.             this.BnClose.Cursor = System.Windows.Forms.Cursors.Default;
  212.             this.BnClose.Enabled = false;
  213.             this.BnClose.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  214.             this.BnClose.ForeColor = System.Drawing.SystemColors.ControlText;
  215.             this.BnClose.Location = new System.Drawing.Point(328, 40);
  216.             this.BnClose.Name = "BnClose";
  217.             this.BnClose.RightToLeft = System.Windows.Forms.RightToLeft.No;
  218.             this.BnClose.Size = new System.Drawing.Size(97, 25);
  219.             this.BnClose.TabIndex = 3;
  220.             this.BnClose.Text = "Close All";
  221.             //
  222.             //BnOpen
  223.             //
  224.             this.BnOpen.BackColor = System.Drawing.SystemColors.Control;
  225.             this.BnOpen.Cursor = System.Windows.Forms.Cursors.Default;
  226.             this.BnOpen.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  227.             this.BnOpen.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  228.             this.BnOpen.ForeColor = System.Drawing.SystemColors.ControlText;
  229.             this.BnOpen.Location = new System.Drawing.Point(328, 8);
  230.             this.BnOpen.Name = "BnOpen";
  231.             this.BnOpen.RightToLeft = System.Windows.Forms.RightToLeft.No;
  232.             this.BnOpen.Size = new System.Drawing.Size(97, 25);
  233.             this.BnOpen.TabIndex = 2;
  234.             this.BnOpen.Text = "Open All";
  235.             //
  236.             //LtLines
  237.             //
  238.             this.LtLines.BackColor = System.Drawing.SystemColors.Window;
  239.             this.LtLines.Cursor = System.Windows.Forms.Cursors.Default;
  240.             this.LtLines.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  241.             this.LtLines.ForeColor = System.Drawing.SystemColors.WindowText;
  242.             this.LtLines.ItemHeight = 15;
  243.             this.LtLines.Location = new System.Drawing.Point(8, 24);
  244.             this.LtLines.Name = "LtLines";
  245.             this.LtLines.RightToLeft = System.Windows.Forms.RightToLeft.No;
  246.             this.LtLines.Size = new System.Drawing.Size(297, 34);
  247.             this.LtLines.TabIndex = 0;
  248.             //
  249.             //Label1
  250.             //
  251.             this.Label1.BackColor = System.Drawing.SystemColors.Control;
  252.             this.Label1.Cursor = System.Windows.Forms.Cursors.Default;
  253.             this.Label1.Font = new System.Drawing.Font("MS Reference Sans Serif", (float) (8.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  254.             this.Label1.ForeColor = System.Drawing.SystemColors.ControlText;
  255.             this.Label1.Location = new System.Drawing.Point(8, 8);
  256.             this.Label1.Name = "Label1";
  257.             this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
  258.             this.Label1.Size = new System.Drawing.Size(113, 17);
  259.             this.Label1.TabIndex = 1;
  260.             this.Label1.Text = "Devices";
  261.             //
  262.             //mTAPIEx
  263.             //
  264.             this.mTAPIEx.Enabled = true;
  265.             this.mTAPIEx.Location = new System.Drawing.Point(448, 32);
  266.             this.mTAPIEx.Name = "mTAPIEx";
  267.             this.mTAPIEx.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("mTAPIEx.OcxState")));
  268.             this.mTAPIEx.Size = new System.Drawing.Size(30, 30);
  269.             this.mTAPIEx.TabIndex = 7;
  270.             //
  271.             //Form1
  272.             //
  273.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  274.             this.BackColor = System.Drawing.SystemColors.Control;
  275.             this.CancelButton = this.BnOpen;
  276.             this.ClientSize = new System.Drawing.Size(504, 366);
  277.             this.Controls.Add(this.mTAPIEx);
  278.             this.Controls.Add(this.Frame1);
  279.             this.Controls.Add(this.TxtLog);
  280.             this.Controls.Add(this.BnClose);
  281.             this.Controls.Add(this.BnOpen);
  282.             this.Controls.Add(this.LtLines);
  283.             this.Controls.Add(this.Label1);
  284.             this.Cursor = System.Windows.Forms.Cursors.Default;
  285.             this.Font = new System.Drawing.Font("Arial", (float) (8.0), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,((byte)(0)));
  286.             this.Location = new System.Drawing.Point(4, 23);
  287.             this.Name = "Form1";
  288.             this.RightToLeft = System.Windows.Forms.RightToLeft.No;
  289.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  290.             this.Text = "Simple IVRS Demo";
  291.             this.Frame1.ResumeLayout(false);
  292.             ((System.ComponentModel.ISupportInitialize)(this.mTAPIEx)).EndInit();
  293.             this.ResumeLayout(false);
  294.  
  295.         }
  296.         #endregion
  297.         #region "Upgrade Support "
  298.         private static Form1partial m_vb6FormDefInstance;
  299.         private static bool m_InitializingDefInstance;
  300.         public static Form1partial DefInstance
  301.         {
  302.             get{
  303.                 Form1partial returnValue;
  304.                 if (m_vb6FormDefInstance == null || m_vb6FormDefInstance.IsDisposed)
  305.                 {
  306.                     m_InitializingDefInstance = true;
  307.                     m_vb6FormDefInstance = new Form1partial();
  308.                     m_InitializingDefInstance = false;
  309.                 }
  310.                 returnValue = m_vb6FormDefInstance;
  311.                 return returnValue;
  312.             }
  313.             set
  314.             {
  315.                 m_vb6FormDefInstance = value;
  316.             }
  317.         }
  318.         #endregion
  319.         //######################################################################################
  320.         //# Program name: Simple IVR Demo                                                      #
  321.         //#                                                                                    #
  322.         //# Version: v1.5                                                                      #
  323.         //#                                                                                    #
  324.         //# Last modification Date: Nov. 23th 2004                                             #
  325.         //#                                                                                    #
  326.         //# Requirements: TAPIEx control,  VOICE modem or TAPI compliant telephony device      #
  327.         //#                                                                                    #
  328.         //# Operating System: Windows 98, Windows ME, Windows NT 4, Windows 2000, Windows XP   #
  329.         //#                                                                                    #
  330.         //# Note: Under Windows NT 4 voice modems may not supported because of the lack of a   #
  331.         //# voice capable TAPI universal modem driver.                                         #
  332.         //#                                                                                    #
  333.         //# Program Purpose: To demonstrate how to add telephony functions to your application #
  334.         //# using the TAPIEx ActiveX control.                                                  #
  335.         //#                                                                                    #
  336.         //######################################################################################
  337.         const string WAVE_PATH = "../../../wave_pcm/";
  338.  
  339.         public class CLineDevice
  340.         {
  341.             public string m_Name;
  342.             public int m_ID;
  343.             public override string ToString()
  344.             {
  345.                 return m_Name;
  346.             }
  347.         }
  348.  
  349.         private void BnClose_Click (System.Object eventSender, System.EventArgs eventArgs)
  350.         {
  351.             mTAPIEx.CloseAll();
  352.             BnOpen.Enabled = true;
  353.             BnClose.Enabled = ! BnOpen.Enabled;
  354.         }
  355.  
  356.         private void BnOpen_Click (System.Object eventSender, System.EventArgs eventArgs)
  357.         {
  358.             short i;
  359.             CLineDevice lDevice;
  360.             for (i = 0; i <= LtLines.Items.Count - 1; i++)
  361.             {
  362.  
  363.                 lDevice=(CLineDevice)LtLines.Items[i];
  364.                 mTAPIEx.Lines.Item(lDevice.m_ID).Open(); //Open the line
  365.             }
  366.  
  367.             BnOpen.Enabled = false;
  368.             BnClose.Enabled = ! BnOpen.Enabled;
  369.         }
  370.  
  371.  
  372.         private void Form1_Load (System.Object eventSender, System.EventArgs eventArgs)
  373.         {
  374.             TAPIEXLib.ITAPILine line;
  375.  
  376.             mTAPIEx.initialize(); //Initialize
  377.             foreach (TAPIEXLib.ITAPILine tempLoopVar_line in mTAPIEx.Lines) //enumerate the line devices
  378.             {
  379.                 line = tempLoopVar_line;
  380.                 if (Convert.ToBoolean(line.Caps.Media_Modes & TAPIEXLib.LINEMEDIAMODE.MEDIAMODE_AUTOMATEDVOICE) || Convert.ToBoolean(line.Caps.Media_Modes & TAPIEXLib.LINEMEDIAMODE.MEDIAMODE_INTERACTIVEVOICE))
  381.                 {
  382.                     CLineDevice lDevice = new CLineDevice();
  383.                     lDevice.m_Name = line.DeviceName;
  384.                     lDevice.m_ID = line.DeviceID;
  385.                     LtLines.Items.Add(lDevice);
  386.                 }
  387.             }
  388.         }
  389.  
  390. //UPGRADE_WARNING: Form event Form1.Unload has a new behavior. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup2065"'
  391.         private void Form1_Closed (System.Object eventSender, System.EventArgs eventArgs)
  392.         {
  393.             mTAPIEx.UnInitialize();
  394.         }
  395.  
  396.         private void mTapiex_OnConnected (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnConnectedEvent eventArgs)
  397.         {
  398.             eventArgs.m_Call.PlaybackFile(WAVE_PATH + "welcome.wav");
  399.             eventArgs.m_Call.PlaybackFile(WAVE_PATH + "menu.wav");
  400.             eventArgs.m_Call.User_Data1 = 0;
  401.             eventArgs.m_Call.User_Data2 = 0;
  402.         }
  403.  
  404.         private void mTapiex_OnDebug (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnDebugEvent eventArgs)
  405.         {
  406.             TxtLog.Text = eventArgs.msg + Convert.ToChar(13) + Convert.ToChar(10) + TxtLog.Text;
  407.         }
  408.  
  409.         private void mTapiex_OnDTMF (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnDTMFEvent eventArgs)
  410.         {
  411.             if (System.Convert.ToInt32(eventArgs.m_Call.User_Data1) == 1) //"any key to hang up the call"
  412.             {
  413.  
  414.                 eventArgs.m_Call.StopRecord();
  415.                 eventArgs.m_Call.PlaybackFile(WAVE_PATH + "rec_end.wav");
  416.             }
  417.             else
  418.             {
  419.                 switch (Convert.ToChar(eventArgs.keyCode))
  420.                 {
  421.                     default:
  422.                         if (Convert.ToChar(eventArgs.keyCode) == '3')
  423.                         {
  424.  
  425.                             eventArgs.m_Call.StopPlayBack();
  426.                             eventArgs.m_Call.PlaybackFile(WAVE_PATH + "Menu_Opt" + Convert.ToChar(eventArgs.keyCode) + ".wav");
  427.                             //play the option wave
  428.                             eventArgs.m_Call.User_Data1 = 1; //recording message, then any key to stop
  429.                             eventArgs.m_Call.Record("rec_message_" + eventArgs.m_Call.Handle + "_.wav");
  430.                             break;
  431.                             //will record the user's messages
  432.                         }
  433.                         if (Convert.ToChar(eventArgs.keyCode) == '2')
  434.                         {
  435.  
  436.                             eventArgs.m_Call.StopPlayBack();
  437.                             eventArgs.m_Call.PlaybackFile(WAVE_PATH + "Menu_Opt" + Convert.ToChar(eventArgs.keyCode) + ".wav");
  438.                             break;
  439.                         }
  440.                         if (Convert.ToChar(eventArgs.keyCode) == '1')
  441.                         {
  442.                             eventArgs.m_Call.StopPlayBack();
  443.                             eventArgs.m_Call.PlaybackFile(WAVE_PATH + "Menu_Opt" + Convert.ToChar(eventArgs.keyCode) + ".wav");
  444.                             break;
  445.  
  446.                         }
  447.                         break;
  448.                 }
  449.             }
  450.         }
  451.  
  452.  
  453.         private void mTAPIEx_OnDTMFTimeOut (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnDTMFTimeOutEvent eventArgs)
  454.         {
  455.             eventArgs.m_Call.DTMF_TimeOut = 0;
  456.             eventArgs.m_Call.StopPlayBack();
  457.             eventArgs.m_Call.PlaybackFile(WAVE_PATH + "timeout.wav");
  458.         }
  459.  
  460.  
  461.         //Normally for ISDN incoming calls:
  462.         //CALLSTATE (OFFERING)
  463.         //Accept()
  464.         //CALLSTATE (ACCEPTED)
  465.         //Answer()
  466.         //CALLSTATE (CONNECTED)
  467.  
  468.         private void mTAPIEx_OnCallStateChange (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnCallStateChangeEvent eventArgs)
  469.         {
  470.             if ((eventArgs.newState == TAPIEXLib.TAPI_CALLSTATE.CALLSTATE_ACCEPTED) && (System.Convert.ToInt32(eventArgs.m_Call.User_Data2) == 1))
  471.             {
  472.                 //ISDN need answer the call on accept
  473.                 eventArgs.m_Call.Answer();
  474.                 eventArgs.m_Call.User_Data2 = 0;
  475.             }
  476.         }
  477.  
  478.         private void mTAPIEx_OnOffering (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnOfferingEvent eventArgs)
  479.         {
  480.             if (System.Convert.ToBoolean(CBAcceptOnOffering.CheckState)) // for ISDN
  481.             {
  482.                 eventArgs.m_Call.Accept( ""); // Accept the call
  483.                 eventArgs.m_Call.User_Data2 = 1;
  484.             }
  485.  
  486.             if (System.Convert.ToBoolean(CbAnswerOnOffering.CheckState)) // answer the call on offering
  487.             {
  488.                 eventArgs.m_Call.Answer();
  489.             }
  490.         }
  491.  
  492.         private void mTapiex_OnPlayBackComplete (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnPlayBackCompleteEvent eventArgs)
  493.         {
  494.  
  495.             if (eventArgs.m_Call.ActivePlayBackFile == WAVE_PATH + "menu.wav") //after the menu wave , time 30 seconds DTMF timeout
  496.             {
  497.                 eventArgs.m_Call.DTMF_TimeOut = 30;
  498.             }
  499.             else
  500.             {
  501.                 if (eventArgs.m_Call.ActivePlayBackFile == WAVE_PATH + "rec_end.wav" | eventArgs.m_Call.ActivePlayBackFile == WAVE_PATH + "timeout.wav")
  502.                 {
  503.                     eventArgs.m_Call.Drop();
  504.                 }
  505.                 //after the end  or timeout wave playback completed, drop the call.
  506.             }
  507.  
  508.         }
  509.  
  510.         private void mTapiex_OnRing (System.Object eventSender, AxTAPIEXLib._ITAPIExEvents_OnRingEvent eventArgs)
  511.         {
  512.             System.Diagnostics.Debug.WriteLine(eventArgs.ringCount);
  513.             if (eventArgs.ringCount >= System.Convert.ToInt16(EdAutoAnswerRingCount.Text))
  514.             {
  515.                 eventArgs.m_Call.Answer();
  516.             }
  517.         }
  518.     }
  519. }
Oct 18 '10 #1
0 1042

Sign in to post your reply or Sign up for a free account.

Similar topics

0
445
by: Vi | last post by:
Some of you might be interested in this open source AutoUpdater for ..NET "Sharp AutoUpdater provides an auto-update feature for .NET applications. Using XML configuration files, Sharp...
4
1596
by: Baskar RajaSekharan | last post by:
Please clarify My doubt.. 1) How to find out whether the component devekopment in Csharp is in Relase Mode or Run Mode? 2) Like Class Id in C++ , what the Unique Id for C-shap Component?
4
2487
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
2
3868
by: HishHish | last post by:
I have a Java code that I want to convert it to C-sharp in order to put it in my ASP.NET web application. I used the JLCA (Java Language Conversion Assistant) for conversion, but it gave me many...
2
3055
by: Mc Spooney | last post by:
I have installed the open source C# IDE, Sharp Develop. Is there a component pallete to allow you to drag and drop controls, such as text boxes and labels etc onto a form ? If so how do you switch...
5
1681
by: Alberto | last post by:
What sharp (from c sharp) stand for or where does it comes from? thank you
4
1231
by: jose | last post by:
Is it possible join in the same project a visual basic net form and a c sharp form?? if the answer is yes, how can I do it? Thanks for your answers
1
997
by: Loane Sharp | last post by:
Hi there Can you point me in the right direction? - I am looking for two or three of the more popular ASP.NET component vendors to supplement the functionality of my VS 2005 web application. Best...
20
2581
by: windandwaves | last post by:
Hi Folk I am a PHP programmer, but I like to learn c-sharp as it seems to be in hot demand around here. My questions are: - how does c-sharp relate to PHP - do you like c-sharp and its...
3
1385
by: Laoballer | last post by:
Hello all, I'm new to C sharp and am starting a project where I have to bring in historic weather data into a mysql database. The weather data can be retrieved via anonymous ftp spanning multiple...
0
7106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4501
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3013
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.