using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Threading;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private delegate void _CallerID([MarshalAs(UnmanagedType.BStr)] string DeviceSerial, [MarshalAs(UnmanagedType.BStr)] string Line, [MarshalAs(UnmanagedType.BStr)] string PhoneNumber, [MarshalAs(UnmanagedType.BStr)] string DateTime, [MarshalAs(UnmanagedType.BStr)] string Other);
private delegate void _Signal([MarshalAs(UnmanagedType.BStr)] string DeviceModel, [MarshalAs(UnmanagedType.BStr)] string DeviceSerial, int Signal1, int Signal2, int Signal3, int Signal4);
private delegate void _SetEvents(_CallerID CallerIDEvent, _Signal SignalEvent);
[DllImport("cid.dll", EntryPoint = "SetEvents", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern void SetEvents(_CallerID CallerIDEvent, _Signal SignalEvent);
private _CallerID CallerIDEvent1;
private _Signal SignalEvent1;
public int counter = 0;
public Form2 popForm ;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
CallerIDEvent1 = new _CallerID(CallerID);
SignalEvent1 = new _Signal(Signal);
SetEvents(CallerIDEvent1, SignalEvent1);
}
private void CallerID([MarshalAs(UnmanagedType.BStr)] string DeviceSerial, [MarshalAs(UnmanagedType.BStr)] string Line, [MarshalAs(UnmanagedType.BStr)] string PhoneNumber, [MarshalAs(UnmanagedType.BStr)] string DateTime, [MarshalAs(UnmanagedType.BStr)] string Other)
{
string temp = "";
counter++;
label2.Text = counter.ToString();
temp = counter.ToString() + " : "+ PhoneNumber + " Line: " + Line + " Date Time: " + DateTime + " Device Serial: " + DeviceSerial + " " + Other;
listBox1.Items.Add(temp);
if (listBox1.Items.Count > 7)
{
listBox1.Items.RemoveAt(0);
}
if (popUp.Checked) {
popForm = new Form2();
popForm.info = temp; popForm.callerID = PhoneNumber;
popForm.Show();
}
}
private void Signal([MarshalAs(UnmanagedType.BStr)] string DeviceModel, [MarshalAs(UnmanagedType.BStr)] string DeviceSerial, int Signal1, int Signal2, int Signal3, int Signal4)
{
string temp = "";
temp = DeviceModel + " - " + DeviceSerial;
if (temp.Length < 5)
{
temp = "No connection";
}
label1.Text = temp;
progressBar1.Value = Signal1;
progressBar2.Value = Signal2;
progressBar3.Value = Signal3;
progressBar4.Value = Signal4;
label3.Text = Signal1.ToString();
label4.Text = Signal2.ToString();
label5.Text = Signal3.ToString();
label6.Text = Signal4.ToString();
}
}
}