Click here to Skip to main content
15,906,947 members
Home / Discussions / C#
   

C#

 
AnswerRe: Retreving text from treeview problem. Pin
KKrista4-Jun-07 21:23
KKrista4-Jun-07 21:23 
QuestionHelp: checking a variable against a string ignoring case senstivity. Pin
jblouir4-Jun-07 12:15
jblouir4-Jun-07 12:15 
AnswerRe: Help: checking a variable against a string ignoring case senstivity. Pin
Luc Pattyn4-Jun-07 12:36
sitebuilderLuc Pattyn4-Jun-07 12:36 
GeneralRe: Help: checking a variable against a string ignoring case senstivity. Pin
jblouir4-Jun-07 12:42
jblouir4-Jun-07 12:42 
GeneralRe: Help: checking a variable against a string ignoring case senstivity. Pin
Brady Kelly4-Jun-07 23:21
Brady Kelly4-Jun-07 23:21 
AnswerRe: Help: checking a variable against a string ignoring case senstivity. Pin
Hesham Yassin4-Jun-07 22:39
Hesham Yassin4-Jun-07 22:39 
QuestionField Names being shorted Pin
(Steven Hicks)n+14-Jun-07 11:46
(Steven Hicks)n+14-Jun-07 11:46 
Questionhelp me with tapi 3 call status and tone detection Pin
georgishelpmegodtoo4-Jun-07 11:17
georgishelpmegodtoo4-Jun-07 11:17 
hi i'm developing a software using c# that detects the dialed digits and the status(sp when connected and desconnected) of a call that is made by a handset attached to the modem.
i have developed some code but it doesn't work.please someone help me it's urgent.
i connected the main line to one of the modems telephone jack and the handset with the other jack and the computer is connected using the serial port and then
here is the code for status of the call
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using TAPI3Lib;

namespace tapi3call_status
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
public TAPIClass tapiobject;
private ITAddress[] ia = new TAPI3Lib.ITAddress[10];
uint lines;
int line;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label3;
public System.Windows.Forms.TextBox textBox2;
public callstatus cs = new callstatus();
private System.Windows.Forms.ListBox listBox1;



///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;
public class CLineDevice
{
public string d_Name;
public int d_ID;
public override string ToString()
{
return d_Name;
}
}


public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
initializetapi3();
}

//
// TODO: Add any constructor code after InitializeComponent call
//
void initializetapi3()
{

tapiobject = new TAPIClass();
tapiobject.Initialize();
IEnumAddress ea = tapiobject.EnumerateAddresses();
ITAddress ln;

cs = new callstatus();
cs.addtolist = new callstatus.listshow(this.status);
tapiobject.ITTAPIEventNotification_Event_Event += new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cs.Event);

uint arg3 = 0;
lines = 0;

for (int i = 0; i < 10; i++)
{
ea.Next(1, out ln, ref arg3);
ia[i] = ln;
if (ln != null)
{
comboBox1.Items.Add(ia[i].AddressName);
lines++;
}
else
break;
}

tapiobject.EventFilter = (int)(TAPI_EVENT.TE_CALLSTATE);
}
public void status(string str)
{
listBox1.Items.Add(str);
}

///
/// Clean up any resources being used.
///

protected override void Dispose(bool disposing)
{
tapiobject.Shutdown();
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 80);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Call Status";
//
// button1
//
this.button1.Location = new System.Drawing.Point(184, 136);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 2;
this.button1.Text = "clear status";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 24);
this.label2.TabIndex = 3;
this.label2.Text = "line devices";
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(120, 16);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(224, 21);
this.comboBox1.TabIndex = 4;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 208);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 24);
this.label3.TabIndex = 5;
this.label3.Text = "Call Duration";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(120, 208);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(88, 20);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "0.0";
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(120, 72);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(192, 56);
this.listBox1.TabIndex = 7;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 254);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());

}

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

}

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

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

}

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

}

private void textBox2_TextChanged(object sender, EventArgs e)
{

}

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

}

}
public class callstatus : TAPI3Lib.ITTAPIEventNotification
{
public StopWatch sw = new StopWatch();
public delegate void listshow(string str);
public listshow addtolist;
public void Event(TAPI3Lib.TAPI_EVENT te, object eobj)
{
Form1 fm = new Form1();
if (te == 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");

sw.Start();
fm.textBox2.Text = "0";

break;
case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
addtolist("Disconnected");

sw.Stop();
fm.textBox2.Text = sw.GetElapsedTimeMinutes().ToString();

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;
}

}

}

public class StopWatch
{

private DateTime startTime;
private DateTime stopTime;
private bool running = false;


public void Start()
{
this.startTime = DateTime.Now;
this.running = true;
}


public void Stop()
{
this.stopTime = DateTime.Now;
this.running = false;
}


// elaspsed time in minutes
public double GetElapsedTimeMinutes()
{
TimeSpan interval;

if (running)
interval = DateTime.Now - startTime;
else
interval = stopTime - startTime;

return interval.TotalMinutes;
}


// elaspsed time in seconds
public double GetElapsedTimeSecs()
{
TimeSpan interval;

if (running)
interval = DateTime.Now - startTime;
else
interval = stopTime - startTime;

return interval.TotalSeconds;
}

}
}
}
and the code for detecting the dialed number
#define Win32
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using TAPI3Lib;
//using TERMMGRLib;
using System.Runtime.InteropServices;
//
using System.Threading;
using System.Data;

namespace tonedetection
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private System.Windows.Forms.TextBox dtmf;
public digitdetect dd = new digitdetect();
//public AxTAPIEXLib.AxTAPIExCtl tapi;
public TAPI3Lib.TAPIClass tapi;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;
#region Windows Form Designer generated code
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
Initializetonemonit();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
public void Initializetonemonit()
{
try
{
tapi = new TAPIClass();
tapi.Initialize();
dd = new digitdetect();
dd.tapi_tonemonit();

tapi.ITTAPIEventNotification_Event_Event+= new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(dd.tapi_event);
//tapi.EventFilter=(int)(TAPI_EVENT.TE_TONEEVENT);
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}

}
///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}


///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///


private void InitializeComponent()
{
this.dtmf = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// dtmf
//
this.dtmf.BackColor = System.Drawing.SystemColors.HighlightText;
this.dtmf.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dtmf.Location = new System.Drawing.Point(40, 104);
this.dtmf.Name = "dtmf";
this.dtmf.ReadOnly = true;
this.dtmf.Size = new System.Drawing.Size(216, 26);
this.dtmf.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(392, 198);
this.Controls.Add(this.dtmf);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private void Form1_Load(object sender, EventArgs e)
{

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





}



}


public class digitdetect
{

//MonitorTones_Add 1, 80, 697, 1209, 0 ' "1"
//.MonitorTones_Add 2, 80, 697, 1336, 0 ' "2"
//.MonitorTones_Add 3, 80, 697, 1477, 0 ' "3"
//.MonitorTones_Add 4, 80, 770, 1209, 0 ' "4"
//.MonitorTones_Add 5, 80, 770, 1336, 0 ' "5"
//.MonitorTones_Add 6, 80, 770, 1477, 0 ' "6"
//.MonitorTones_Add 7, 80, 852, 1209, 0 ' "7"
//.MonitorTones_Add 8, 80, 852, 1336, 0 ' "8"
//.MonitorTones_Add 9, 80, 852, 1477, 0 ' "9"
//.MonitorTones_Add 10, 80, 941, 1209, 0 ' "*"
//.MonitorTones_Add 0, 80, 941, 1336, 0 ' "0"
//.MonitorTones_Add 12, 80, 941, 1477, 0 ' "#"
//************
//currCall.MonitorTones_Add(BUSY_ID, BusyTone.Duration, BusyTone.FirstFreq, BusyTone.SecondFreq, 0);
//*********
//Function MonitorTones_Add(
//AppSpecific As Long,
//Duration As Long,
//Frequency1 As Long, Frequency2 As Long, Frequency3 As Long ) As Boolean
//*************************
TAPI3Lib.TAPI_DETECTTONE currentcal_0;
TAPI3Lib.TAPI_DETECTTONE currentcal_1;
TAPI3Lib.TAPI_DETECTTONE currentcal_2;
TAPI3Lib.TAPI_DETECTTONE currentcal_3;
TAPI3Lib.TAPI_DETECTTONE currentcal_4;
TAPI3Lib.TAPI_DETECTTONE currentcal_5;
TAPI3Lib.TAPI_DETECTTONE currentcal_6;
TAPI3Lib.TAPI_DETECTTONE currentcal_7;
TAPI3Lib.TAPI_DETECTTONE currentcal_8;
TAPI3Lib.TAPI_DETECTTONE currentcal_9;
TAPI3Lib.TAPI_DETECTTONE currentcal_10;
TAPI3Lib.TAPI_DETECTTONE currentcal_11;



//public TAPIEXLib.ITAPICall currentcall;


public void tapi_tonemonit()
{


currentcal_0.dwAppSpecific=1;
currentcal_0.dwDuration=80;
currentcal_0.dwFrequency1=941;
currentcal_0.dwFrequency2=1336;
currentcal_0.dwFrequency3=0;

currentcal_1.dwAppSpecific=1;
currentcal_1.dwDuration=80;
currentcal_1.dwFrequency1=697;
currentcal_1.dwFrequency2=1209;
currentcal_1.dwFrequency3=0;

currentcal_2.dwAppSpecific=1;
currentcal_2.dwDuration=80;
currentcal_2.dwFrequency1=697;
currentcal_2.dwFrequency2=1336;
currentcal_2.dwFrequency3=0;

currentcal_3.dwAppSpecific=1;
currentcal_3.dwDuration=80;
currentcal_3.dwFrequency1=697;
currentcal_3.dwFrequency2=1447;
currentcal_3.dwFrequency3=0;

currentcal_4.dwAppSpecific=1;
currentcal_4.dwDuration=80;
currentcal_4.dwFrequency1=770;
currentcal_4.dwFrequency2=1209;
currentcal_4.dwFrequency3=0;

currentcal_5.dwAppSpecific=1;
currentcal_5.dwDuration=80;
currentcal_5.dwFrequency1=770;
currentcal_5.dwFrequency2=1336;
currentcal_5.dwFrequency3=0;


currentcal_6.dwAppSpecific=1;
currentcal_6.dwDuration=80;
currentcal_6.dwFrequency1=770;
currentcal_6.dwFrequency2=1447;
currentcal_6.dwFrequency3=0;

currentcal_7.dwAppSpecific=1;
currentcal_7.dwDuration=80;
currentcal_7.dwFrequency1=852;
currentcal_7.dwFrequency2=1209;
currentcal_7.dwFrequency3=0;

currentcal_8.dwAppSpecific=1;
currentcal_8.dwDuration=80;
currentcal_8.dwFrequency1=852;
currentcal_8.dwFrequency2=1336;
currentcal_8.dwFrequency3=0;

currentcal_9.dwAppSpecific=1;
currentcal_9.dwDuration=80;
currentcal_9.dwFrequency1=852;
currentcal_9.dwFrequency2=1447;
currentcal_9.dwFrequency3=0;
//*
currentcal_10.dwAppSpecific=1;
currentcal_10.dwDuration=80;
currentcal_10.dwFrequency1=941;
currentcal_10.dwFrequency2=1209;
currentcal_10.dwFrequency3=0;
//#
currentcal_11.dwAppSpecific=1;
currentcal_11.dwDuration=80;
currentcal_11.dwFrequency1=941;
currentcal_11.dwFrequency2=1447;
currentcal_11.dwFrequency3=0;


// currentcall.MonitorTones_Add(1,80,697,1209,0);
// currentcall.MonitorTones_Add(2,80,697,1336,0);
// currentcall.MonitorTones_Add(3,80,697,1477,0);
// currentcall.MonitorTones_Add(4,80,770,1209,0);
// currentcall.MonitorTones_Add(5,80,770,1336,0);
// currentcall.MonitorTones_Add(6,80,770,1209,0);
// currentcall.MonitorTones_Add(7,80,852,1209,0);
// currentcall.MonitorTones_Add(8,80,852,1336,0);
// currentcall.MonitorTones_Add(9,80,852,1477,0);
/// currentcall.MonitorTones_Add(10,80,941,1209,0); //*
// currentcall.MonitorTones_Add(0,80,941,1336,0);
// currentcall.MonitorTones_Add(11,80,941,1477,0); //#

}

public void Addtext(ref string msg)
{
//fm = new Form1();
TextBox dtmf = new TextBox();
dtmf.Text=msg;
}

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


// tapi = new AxTAPIEXLib.AxTAPIExCtl();

//tapi.initialize();



}
public void tapi_event(TAPI3Lib.TAPI_EVENT te,object eobj)//TAPI3Lib.ITToneDetectionEvent e,Object eventSender )
{
if(te==TAPI3Lib.TAPI_EVENT.TE_TONEEVENT)
{

TAPI3Lib.ITToneDetectionEvent e=(TAPI3Lib.ITToneDetectionEvent)eobj;


switch ( e.AppSpecific)

{
case 0:
string temp_string0 = "0";
Addtext( ref temp_string0);
break;

case 1:

string temp_string = "1";
Addtext(ref temp_string);
break;

case 2:

string temp_string2 = "2";
Addtext(ref temp_string2);
break;

case 3:

string temp_string3 = "3";
Addtext(ref temp_string3);
break;

case 4:

string temp_string4 = "4";
Addtext(ref temp_string4);
break;

case 5:

string temp_string5 = "5";
Addtext(ref temp_string5);
break;

case 6:

string temp_string6 = "6";
Addtext(ref temp_string6);
break;

case 7:

string temp_string7 = "7";
Addtext(ref temp_string7);
break;

case 8:

string temp_string8 = "8";
Addtext(ref temp_string8);
break;

case 9:

string temp_string9 = "9";
Addtext(ref temp_string9);
break;


}

}
else
{
string msg2="no tone";
Addtext(ref msg2);
}
}


}




thanks

AnswerRe: help me with tapi 3 call status and tone detection Pin
Dave Kreskowiak4-Jun-07 16:54
mveDave Kreskowiak4-Jun-07 16:54 
GeneralRe: help me with tapi 3 call status and tone detection Pin
georgishelpmegodtoo5-Jun-07 0:07
georgishelpmegodtoo5-Jun-07 0:07 
GeneralRe: help me with tapi 3 call status and tone detection Pin
Dave Kreskowiak6-Jun-07 16:32
mveDave Kreskowiak6-Jun-07 16:32 
GeneralRe: help me with tapi 3 call status and tone detection Pin
georgishelpmegodtoo7-Jun-07 1:28
georgishelpmegodtoo7-Jun-07 1:28 
GeneralRe: help me with tapi 3 call status and tone detection Pin
Dave Kreskowiak7-Jun-07 13:39
mveDave Kreskowiak7-Jun-07 13:39 
AnswerRe: help me with tapi 3 call status and tone detection Pin
Muammar©4-Jun-07 21:14
Muammar©4-Jun-07 21:14 
AnswerRe: help me with tapi 3 call status and tone detection Pin
Nouman Bhatti5-Jun-07 2:03
Nouman Bhatti5-Jun-07 2:03 
GeneralRe: help me with tapi 3 call status and tone detection Pin
georgishelpmegodtoo7-Jun-07 1:29
georgishelpmegodtoo7-Jun-07 1:29 
GeneralRe: help me with tapi 3 call status and tone detection Pin
Nouman Bhatti7-Jun-07 20:55
Nouman Bhatti7-Jun-07 20:55 
QuestionGet highlighted text from any window with special shortcut Pin
mgiaco824-Jun-07 10:34
mgiaco824-Jun-07 10:34 
AnswerRe: Get highlighted text from any window with special shortcut Pin
mgiaco825-Jun-07 2:20
mgiaco825-Jun-07 2:20 
Question[Message Deleted] Pin
R_L_H4-Jun-07 10:27
R_L_H4-Jun-07 10:27 
AnswerRe: How Do You Disable All Click Events For A .Net Control? Pin
Dave Kreskowiak4-Jun-07 10:42
mveDave Kreskowiak4-Jun-07 10:42 
AnswerRe: How Do You Disable All Click Events For A .Net Control? Pin
Ian Shlasko4-Jun-07 10:49
Ian Shlasko4-Jun-07 10:49 
General[Message Deleted] Pin
R_L_H4-Jun-07 10:53
R_L_H4-Jun-07 10:53 
GeneralRe: How Do You Disable All Click Events For A .Net Control? Pin
Ian Shlasko4-Jun-07 12:00
Ian Shlasko4-Jun-07 12:00 
GeneralRe: How Do You Disable All Click Events For A .Net Control? Pin
Dave Kreskowiak4-Jun-07 14:00
mveDave Kreskowiak4-Jun-07 14:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.