📄 录音记录.cs
字号:
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using OpenNETCF.IO;
using Microsoft.WindowsMobile.Status;
using System.Threading;
using Microsoft.WindowsMobile.PocketOutlook;
namespace SmartAnswerCall
{
public partial class 录音记录 : Form
{
private SmsMessage sms;
private SystemState state电话打进;
public static bool bool启用黑名单;
public static bool bool自动录音;
public static string str程序目录;
public static List<string> list列表;
public static bool bool自动启动;
public static int int延迟时间;
public static string str黑名单;
public static string str录音目录;
private SystemState state通话;
private int int刚通话时间;
public static string str来电号码;
public static bool bool接通;
public static bool bool回复短信;
private bool bool来电号码;
private string str日期;
private string str时间;
public static List<string> list临时;
public static List<string> list;
static 录音记录()
{
str来电号码 = "";
bool启用黑名单 = true;
bool自动录音 = true;
bool回复短信 = false;
bool接通 = false;
list列表 = new List<string>();
list临时 = new List<string>();
bool自动启动 = false;
int延迟时间 = 5;
str黑名单 = "10000";
}
public 录音记录()
{
this.sms = new SmsMessage();
this.int刚通话时间 = 0;
this.bool来电号码 = false;
this.str日期 = "";
this.str时间 = "";
this.even加载();
//取程序所在的目录
str程序目录 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
str录音目录 = str程序目录 + @"\Recorded\";
InitializeComponent();
}
private void even加载()
{
this.state通话 = new SystemState(SystemProperty.PhoneCallTalking);
this.state通话.Changed += new ChangeEventHandler(this.通话事件 );
this.state电话打进 = new SystemState(SystemProperty.PhoneIncomingCallerNumber);
this.state电话打进.Changed += new ChangeEventHandler(this.电话打进事件);
}
//--------------------------------------------------------------------------------------------------------------------------------------------
/*处理电话打进的事件(处理来电号码、启用定时器)
* 蓝浪2008-9-22
*/
private void 电话打进事件(object A_0, ChangeEventArgs A_1)
{
string str = "";
if (A_1.NewValue != null)
{
str来电号码 = (string)A_1.NewValue;
//处理来电号码,在0---9范围内去掉其它的符号
for (int i = 0; i < str来电号码.Length; i++)
{
if ((str来电号码[i] <= '9') && (str来电号码[i] >= '0'))
{
str = str + str来电号码[i].ToString();
}
}
str来电号码 = str;
if (录音记录.bool启用黑名单 )
{
if (str来电号码.IndexOf('+') == 0)
{
str来电号码 = str来电号码.Substring(3);
}
try
{
if (str黑名单.IndexOf(str来电号码) != -1)
{
处理方法.挂断();
this.tim时间.Enabled = false;
this.timer短信.Enabled = false;
return;
}
}
catch
{
}
}
if (bool回复短信)
{
this.timer短信.Enabled = true;
try
{
处理方法.挂断();
this.tim时间.Enabled = false;
this.timer短信.Enabled = true;
return;
}
catch
{
}
}
this.bool来电号码 = true;
this.tim时间 .Enabled = true;
this.int刚通话时间 = 0;
}
else
{
this.bool来电号码 = false;
this.tim时间.Enabled = false;
this.timer短信.Enabled = false;
this.int刚通话时间 = 0;
}
}
//--------------------------------------------------------------------------------------------------------------------------------------------
/*显示打进的电话列表并把之写进文件
*蓝浪2008-9-22
*/
private void 电话列表(string A_0, string A_1)
{
list临时.Insert(0, DateTime.Now.ToString("T") + "--" + str来电号码 + A_1);
list列表.Insert(0, A_0);
string text = "";
text = list临时[0];
this.listView电话 .Items.Insert(0, new ListViewItem(text));
this.listView电话.Refresh();
FileHelper.WriteAllLines(str录音目录 + "lstShow.ini", list临时.ToArray());
FileHelper.WriteAllLines(str录音目录 + "lstPath.ini", list列表.ToArray());
}
//--------------------------------------------------------------------------------------------------------------------------------------------
/* 处理通话时的事件(录音)
* 蓝浪2008-9-22
*/
private void 通话事件(object A_0, ChangeEventArgs A_1)
{
if (A_1.NewValue != null)
{
if (((int)A_1.NewValue) == 1)
{
bool接通 = true;
this.bool来电号码 = false;
if (this.int刚通话时间 < int延迟时间)
{
this.tim时间.Enabled = false;
timer短信.Enabled = false;
if (!(!bool自动录音 || SmartAnswerCall.处理方法.m))
{
this.str日期 = DateTime.Now.ToString("D");
this.str时间 = DateTime.Now.ToString("T").Replace(":", "");
Directory.CreateDirectory(str录音目录 + this.str日期 + @"\AUTO" + this.str时间);
SmartAnswerCall.处理方法.用户留言录音(str录音目录 + this.str日期 + @"\AUTO" + this.str时间 + @"\0.wav", 10);
this.电话列表(str录音目录 + this.str日期 + @"\AUTO" + this.str时间 + @"\", "AUTO");
}
}
}
else
{
this.bool来电号码 = false;
bool接通 = false;
this.tim时间.Enabled = false;
if (this.int刚通话时间 > int延迟时间)
{
}
}
}
//下面是刷新电话列表
if (File.Exists(str程序目录 + @"\Recorded\lstShow.ini"))
{
list = new List<string>();
list = list临时;
list.Clear();
list.AddRange(FileHelper.ReadAllLines(str程序目录 + @"\Recorded\lstShow.ini"));
}
if (list临时.Count > 0)
{
this.listView电话.Items.Clear();
for (int i = 0; i < list.Count; i++)
{
this.listView电话.Items.Add(new ListViewItem(list[i]));
}
}
}
//--------------------------------------------------------------------------------------------------------------------------------------------
/* 对窗体的显示\隐藏操作
* 蓝浪2008-9-22
*/
[DllImport("coredll")]
private static extern bool ShowWindow(IntPtr A_0, int A_1);
//--------------------------------------------------------------------------------------------------------------------------------------------
/* 初始化,加载文件
* 蓝浪2008-9-21
*/
private void 录音记录_Load(object sender, EventArgs e)
{
even加载();
str程序目录 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
if (File.Exists(str程序目录 + @"\Recorded\lstPath.ini"))
{
list列表.AddRange(FileHelper.ReadAllLines(str程序目录 + @"\Recorded\lstPath.ini"));
}
if (File.Exists(str程序目录 + @"\Recorded\lstShow.ini"))
{
list临时.AddRange(FileHelper.ReadAllLines(str程序目录 + @"\Recorded\lstShow.ini"));
}
if (list临时.Count > 0)
{
for (int i = 0; i < list临时.Count; i++)
{
this.listView电话 .Items.Add(new ListViewItem(list临时[i]));
}
}
if (File.Exists(str程序目录 + @"\AutoRespond.ini"))
{
try
{
string[] strArray = FileHelper.ReadAllLines(str程序目录 + @"\AutoRespond.ini");
bool自动启动 = Convert.ToBoolean(strArray[0]);
bool自动录音 = Convert.ToBoolean(strArray[1]);
int延迟时间 = Convert.ToInt32(strArray[2]);
bool启用黑名单 = Convert.ToBoolean(strArray[3]);
SmartAnswerCall.处理方法.int录音连贯值 = Convert.ToInt32(strArray[4]);
str黑名单 = strArray[5];
bool回复短信 = Convert.ToBoolean(strArray[6]);
}
catch
{
File.Delete(str程序目录 + @"\AutoRespond.ini");
}
}
ShowWindow(base.Handle, 6);
}
//--------------------------------------------------------------------------------------------------------------------------------------------
/*详细设置 (录音连贯值.
自动启动
自动录音
来电黑名单)
* 蓝浪2008-9-22
*/
private void menu设置_Click(object sender, EventArgs e)
{
详细设置 frm设置 = new 详细设置();
string[] contents = new string[7];
frm设置.txt录音连贯值.Text =SmartAnswerCall.处理方法.int录音连贯值.ToString();
frm设置.chb自动启动.Checked = bool自动启动;
frm设置.chb自动录音.Checked = bool自动录音;
frm设置.chb来电黑名单.Checked = bool启用黑名单;
if (frm设置.ShowDialog() == DialogResult.OK)
{
int延迟时间 = Convert.ToInt32(frm设置.cbo延迟时间.Text);
bool自动启动 = frm设置.chb自动启动.Checked;
bool自动录音 = frm设置.chb自动录音.Checked;
bool回复短信 = frm设置.chb短信回复.Checked;
bool启用黑名单 = frm设置.chb来电黑名单.Checked;
SmartAnswerCall.处理方法.int录音连贯值 = Convert.ToInt32(frm设置.txt录音连贯值.Text);
contents[0] = bool自动启动.ToString();
contents[1] = bool自动录音.ToString();
contents[2] = int延迟时间.ToString();
contents[3] = bool启用黑名单.ToString();
contents[4] = SmartAnswerCall . 处理方法.int录音连贯值.ToString();
contents[5] = str黑名单;
contents[6] = bool回复短信.ToString();
FileHelper.WriteAllLines(str程序目录 + @"\AutoRespond.ini", contents);
}
frm设置.Dispose();
}
//--------------------------------------------------------------------------------------------------------------------------------------------
/* 电话打进来时进行电话留言录音
* 蓝浪2008-9-23032877
*
*/
private void tim时间_Tick(object sender, EventArgs e)
{
if (!this.bool来电号码)
{
this.timer短信.Enabled = false;
this.tim时间.Enabled = false;
this.int刚通话时间 = 0;
}
else
{
this.int刚通话时间++;
if (this.int刚通话时间 > int延迟时间)
{
this.timer短信.Enabled = false;
this.tim时间.Enabled = false;
if (!SmartAnswerCall.处理方法.m)
{
SmartAnswerCall.处理方法.接听();
bool接通 = true;
Thread.Sleep(100);
SmartAnswerCall.处理方法.播放提示录音();
this.bool来电号码 = false;
Thread.Sleep(0x2710);
if (bool接通)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -