检测到网络断需要播放提示声音 选用的控件为:
使用MCI Command String多媒体设备程序接口播放mp3,avi等
using System.Runtime.InteropServices;public static uint SND_ASYNC = 0x0001;
public static uint SND_FILENAME = 0x00020000;
[DllImport("winmm.dll")]
public static extern uint mciSendString(string lpstrCommand,
string lpstrReturnString, uint uReturnLength, uint hWndCallback);
public void Play()
{
mciSendString(@"close temp_alias", null, 0, 0);
mciSendString(@"open ""恋爱ing.mp3"" alias temp_alias", null, 0, 0);
mciSendString("play temp_alias repeat", null, 0, 0);
}
关于mciSendString的详细参数说明,请参见MSDN,或是http://blog.csdn.net/psongchao/archive/2007/01/19/1487788.aspx
但是 该控件在多线程中不能直接调用的方式 还需要使用委托的方式 可能跟他使用的堆栈有些关系
简单的委托示例
在调用委托之前,你需要先声明一个委托,并把它绑定到一个真正实现的方法上即可。
private delegate void MyDelegate(string sDescription);
static void OutPut(string sPara)
{
Console.WriteLine(sPara);
}
static void Main(string[] args)
{
//声明一个委托,并把OutPut当成是委托的一个实例
MyDelegate dlgt = new MyDelegate(OutPut);
//直接调用委托
dlgt("Call the delegate.");
}
于是程序输出结果"Call the delegate."。
另一种委托的调用方式就是使用Invoke的形式来调用,当然两种调用结果是不一样的。
button 控件 不能使能双击事件 虽然有属性 但是不能触发,所以对于监控点 采用的是LABEL方式 其实用其他的都可以
‘
对于Lable采用了ContextMenuStrip 实现了右键删除的功能 其中删除过程中需要找到对应的Lable 以下为方法
ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
ContextMenuStrip strip = menuItem.GetCurrentParent() as ContextMenuStrip;
Label lb = strip.SourceControl as Label;