TrayMenu悬停Item事件

时间:2014-08-19 08:31:32

标签: c#

我用子菜单(设置......)构建了trayMenu,当我悬停这个项目时,我需要hanlde事件,我可以弹出一些消息或做其他事情。

我无法找到捕捉此事件的方法。

我的代码+我已经准备好尝试了。

private static NotifyIcon trayIcon;
private static ContextMenu tm;
private static ContextMenu tmNowActions;
private static ContextMenu tmSettings;

static void Main(string[] args)
{

    SysTrayApp();
    Application.Run();
}

public static void SysTrayApp()
{

    tm = new ContextMenu();
    //Now Action
    tmNowActions = new ContextMenu();
    tmNowActions.MenuItems.Add("Check if file ready.", IsFileExist);
    tmNowActions.MenuItems.Add("Get SNXRATES data.", GetDataSNXRATES);
    tmNowActions.MenuItems.Add("Update SNXRATES", GetDataSNXRATES);
    tm.MenuItems.Add("Now actions").MergeMenu(tmNowActions);
    //Now Action

    //settings
    tmSettings = new ContextMenu();
    tmSettings.MenuItems.Add("Show Scheduler", ShowScheduler);
    tmSettings.MenuItems.Add("Hide Scheduler", HideScheduler);
    tm.MenuItems.Add("Settings").MergeMenu(tmSettings);
    //settings

    tm.MenuItems.Add("-");
    tm.MenuItems.Add("Exit", OnExit);
    trayIcon = new NotifyIcon();
    trayIcon.Text = "SilverNet";
    trayIcon.Icon = new Icon(@"C:\Users\vladimirp.SILVERNET\Downloads\Glyphish-Glyphish-190-bank.ico", 12, 12);
    // Add menu to tray icon and show it.
    trayIcon.ContextMenu = tm;
    trayIcon.Visible = true;
    Scheduler.ShowDialog();

}
public static void ShowScheduler(object sender, EventArgs e)
{
}
public static void HideScheduler(object sender, EventArgs e)
{
}
public static void IsFileExist(object sender, EventArgs e)
{
}
public static void GetDataSNXRATES(object sender, EventArgs e)
{
}
public static void UpdateSNXRATES(object sender, EventArgs e)
{
}

public static void NowAction(object sender, EventArgs e)
{
}

private static void MenuSelected(object sender, EventArgs e)
{
//this not working
    if (sender == "Settings")
    {

    }

}

0 个答案:

没有答案