本文整理汇总了C#中System.Windows.Forms.NotifyIcon.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# NotifyIcon.Dispose方法的具体用法?C# NotifyIcon.Dispose怎么用?C# NotifyIcon.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.NotifyIcon
的用法示例。
在下文中一共展示了NotifyIcon.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
public static void Show(TrayNotifierInfo trayNotifierInfo)
{
if ((trayNotifierInfo != null) && (trayNotifierInfo.TimeOut >= 0))
{
if (notifyIcon != null)
{
notifyIcon.Dispose();
}
NotifyIcon tempLocal0 = new NotifyIcon
{
Text = trayNotifierInfo.Text,
Icon = trayNotifierInfo.Icon,
BalloonTipIcon = trayNotifierInfo.TipIcon,
BalloonTipText = trayNotifierInfo.TipText,
BalloonTipTitle = trayNotifierInfo.TipTitle,
ContextMenuStrip = CreateContextMenu(trayNotifierInfo.MenuItems)
};
notifyIcon = tempLocal0;
EventHandler showFormClick = delegate
{
if (trayNotifierInfo.Source != null)
{
MainForm.ShowInstance(trayNotifierInfo.Source);
}
else
{
MainForm.ShowInstance();
}
notifyIcon.Dispose();
};
notifyIcon.BalloonTipClicked += showFormClick;
notifyIcon.DoubleClick += showFormClick;
notifyIcon.Click += showFormClick;
notifyIcon.Visible = true;
if (trayNotifierInfo.ShowBalloonTip)
{
notifyIcon.ShowBalloonTip(trayNotifierInfo.TimeOut * 0x3e8);
}
if (trayNotifierInfo.TimeOut > 0)
{
Timer tempLocal1 = new Timer
{
Interval = trayNotifierInfo.TimeOut * 0x3e8
};
timer = tempLocal1;
timer.Tick += delegate
{
notifyIcon.Dispose();
timer.Stop();
};
timer.Start();
}
}
}
示例2: Main
public static void Main (string[] args)
{
Thread notifyThread = new Thread(
delegate()
{
ShowWindow(GetConsoleWindow(), 0);
ContextMenu menu = new ContextMenu();
MenuItem mnuExit = new MenuItem("Выход");
menu.MenuItems.Add(0, mnuExit);
icon = new NotifyIcon()
{
Icon = SlideSwitcherServer.Resources.logo,
ContextMenu = menu,
Text = "Slide Switcher Server",
};
mnuExit.Click += delegate {
icon.Dispose();
Application.Exit();
};
icon.Visible = true;
icon.ShowBalloonTip(4000, "Slide Switcher", "Server", ToolTipIcon.Info);
Application.Run();
}
);
notifyThread.Start();
Server(port);
}
示例3: ShowNotification
static void ShowNotification(string text, string title)
{
var container = new Container();
var wait = new ManualResetEvent(false);
var trayicon = new NotifyIcon(container);
EventHandler done = null;
done = delegate {
wait.Set();
trayicon.BalloonTipClosed -= done;
trayicon.BalloonTipClicked -= done;
};
trayicon.BalloonTipClicked += done;
trayicon.BalloonTipClosed += done;
trayicon.BalloonTipTitle = title;
trayicon.BalloonTipText = text;
var exe = Environment.GetFolderPath(
Environment.SpecialFolder.ProgramFilesX86) +
@"\iTunes\iTunes.exe";
var icon = Icon.ExtractAssociatedIcon(exe);
trayicon.Icon = new Icon(icon, 16, 16);
trayicon.Visible = true;
trayicon.ShowBalloonTip(5000);
wait.WaitOne(10000);
trayicon.Visible = false;
trayicon.Dispose();
icon.Dispose();
container.Dispose();
}
示例4: ExecutionLoop
protected override void ExecutionLoop(IAsyncResult result)
{
icon = new NotifyIcon();
timer = new Timer();
icons = new Icon[4];
for (int i = 0; i < 4; i++)
{
icons[i] = (Icon) GetResourceObject( (i + 1).ToString());
}
icon.Icon = icons[currentIconIndex];
icon.Text = GetResourceString("IconTip");
icon.Visible = true;
icon.DoubleClick += OnIconDoubleClick;
timer.Tick += OnTimerTick;
timer.Interval = 350;
timer.Start();
Application.Run();
icon.Dispose();
timer.Dispose();
}
示例5: CreateTrayMenu
public static void CreateTrayMenu()
{
if (Environment.OSVersion.Platform != PlatformID.Win32NT)
return;
var menu = new NotifyIcon
{
ContextMenu = new ContextMenu()
};
menu.ContextMenu.MenuItems.Add(new MenuItem("&Reload", delegate
{
Application.Restart();
}));
menu.ContextMenu.MenuItems.Add(new MenuItem("&Exit", delegate
{
Environment.Exit(0);
}));
var favicon = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Script).FullName + ".favicon.ico");
if (favicon != null)
{
menu.Icon = new Icon(favicon);
menu.Visible = true;
}
ApplicationExit += delegate
{
menu.Visible = false;
menu.Dispose();
};
}
示例6: MainAppContext
public MainAppContext()
{
NotifyIcon trayIcon = new NotifyIcon() { Icon = Properties.Resources.TopMost, Text = "MakeTopMost", Visible = true };
trayIcon.Click += (s, e) =>
{
if (this.lastMenu != null)
{
this.lastMenu.Dispose();
}
this.lastMenu = this.CreateMenu();
NativeWindow trayIconWindow = (NativeWindow)typeof(NotifyIcon).GetField("window", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(trayIcon);
POINT cursorLocation = new POINT(); NativeMethods.GetCursorPos(out cursorLocation);
SystemWindow.ForegroundWindow = new SystemWindow(trayIconWindow.Handle);
NativeMethods.TrackPopupMenuEx(new HandleRef(this.lastMenu, this.lastMenu.Handle), 72, cursorLocation.X, cursorLocation.Y, new HandleRef(trayIconWindow, trayIconWindow.Handle), IntPtr.Zero);
NativeMethods.PostMessage(new HandleRef(trayIconWindow, trayIconWindow.Handle), 0, IntPtr.Zero, IntPtr.Zero);
};
this.ThreadExit += (s, e) =>
{
trayIcon.Dispose();
if (this.lastMenu != null)
{
this.lastMenu.Dispose();
}
};
}
示例7: ConnectStatus
public ConnectStatus(MainWindow window)
{
this.window = window;
icon = new NotifyIcon();
icon.Visible = true;
icon.DoubleClick += (sender, e) => {
window.WindowState = System.Windows.WindowState.Normal;
window.Activate();
};
var menu = new ContextMenu();
menu.MenuItems.Add(resources["AddRules"] as string, (sender, e) => {
Rules.OpenEditor(false);
});
menu.MenuItems.Add(resources["Exit"] as string, (sender, e) => {
System.Windows.Application.Current.Shutdown();
});
icon.ContextMenu = menu;
SetStatus(Status.Stopped, resources["NotConnected"] as string);
System.Windows.Application.Current.Exit += (sender, e) => {
icon.Dispose();
};
}
示例8: Application_Startup
private void Application_Startup(object sender, StartupEventArgs e)
{
//build the context menu
_trayContextMenu = new System.Windows.Forms.ContextMenu();
_trayContextMenu.MenuItems.Add(new System.Windows.Forms.MenuItem("E&xit", ContextMenuExit));
//setup the system tray icon
_trayIcon = new NotifyIcon();
_trayIcon.ContextMenu = _trayContextMenu;
_trayIcon.Icon = images.IDS04;
_trayIcon.Click += new EventHandler(TrayIconClick);
_trayIcon.Visible = true;
//host the service
ServiceHost host1 = new ServiceHost(typeof(CrossDomainService));
host1.Open();
ServiceHost host2 = new ServiceHost(typeof(BiometricsService));
host2.Open();
//display the main window
_mainWindow = new Main();
_mainWindow.Closing += new CancelEventHandler(MainWindowClosing);
_mainWindow.ShowDialog();
//cleanup
_trayContextMenu.Dispose();
_trayIcon.Dispose();
}
示例9: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
_tray = new NotifyIcon();
_tray.ContextMenuStrip = new ContextMenuStrip();
_tray.Click += new EventHandler(_tray_Click);
_tray.Icon = new System.Drawing.Icon(Properties.Resources.media_optical_cdrom, new System.Drawing.Size(32, 32));
_tray.Visible = true;
_tray.Text = "OpenTray v" + Assembly.GetAssembly(Type.GetType("OpenTray.Program")).GetName().Version;
// Add CDROM Drives
DriveInfo[] Drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in Drives)
{
if (drive.DriveType == DriveType.CDRom)
{
ToolStripMenuItem _drive = new ToolStripMenuItem();
_drive.Text = drive.Name;
_drive.Click += new EventHandler(_drive_Click);
_drive.Image = Properties.Resources.media_optical_audio_mount_3;
_tray.ContextMenuStrip.Items.Add(_drive);
}
}
// Add exit option
ToolStripMenuItem _exit = new ToolStripMenuItem("Exit");
_exit.Click += new EventHandler(_exit_Click);
_exit.Image = Properties.Resources.application_exit_3;
_tray.ContextMenuStrip.Items.Add(_exit);
Application.Run();
_tray.Dispose();
}
示例10: App
public App()
{
DIService.Initialize();
_globalData = DIService.GetSingleton<GlobalData>();
_notifyIcon = InitNotifyIcon();
Exit += (sender, args) => _notifyIcon.Dispose();
}
示例11: Snap
public Snap()
{
/// Setup default keybinds.
RegistryKey key_snap = Registry.CurrentUser.CreateSubKey(@"Software\xcap");
if (key_snap.GetValue("SNAP") == null)
key_snap.SetValue("SNAP", "+--~");
if (key_snap.GetValue("FULL") == null)
key_snap.SetValue("FULL", "+-+~");
if (key_snap.GetValue("URI") == null)
key_snap.SetValue("URI", Settings.ServerUrl.ToString());
if (key_snap.GetValue("OWN_SERV") == null)
key_snap.SetValue("OWN_SERV", Settings.UseOwnServer);
form = new DummyForm();
form1 = new DummyForm1();
Settings.RefreshKeyBinds();
GenerateIconList();
icon = new NotifyIcon();
icon.Text = "xcap";
icon.Icon = form.Icon;
icon.Visible = true;
icon.ContextMenu = new ContextMenu();
MenuItem options = new MenuItem("Options");
options.Click += (sender, e) =>
{
new Options().Show();
};
icon.ContextMenu.MenuItems.Add(options);
icon.ContextMenu.MenuItems.Add("Exit", (sender, e) =>
{
Application.Exit();
});
icon.DoubleClick += (sender, e) =>
{
Take();
};
Application.Run();
form.Dispose();
form1.Dispose();
Settings.ghk_Snap.Unregister();
Settings.ghk_Full.Unregister();
icon.Visible = false;
icon.Dispose();
}
示例12: ShowIcon
private static void ShowIcon()
{
NotifyIcon notifyIcon = new NotifyIcon
{
Text = "BacklightVisualizer",
Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("BacklightVisualizer.Icon.ico"))
};
ContextMenu menu = new ContextMenu();
menu.MenuItems.Add(new MenuItem("Exit", (sender, eventArgs) =>
{
notifyIcon.Visible = false;
notifyIcon.Dispose();
Application.Exit();
}));
notifyIcon.ContextMenu = menu;
notifyIcon.Visible = true;
}
示例13: addNotifyIcon
/// <summary>
/// add notification icon to system tray bar (near the clock)
/// quit option is available by default
/// </summary>
/// <param name="name">name displayed on mouse hover</param>
/// <param name="items">items to add to the context menu</param>
public static void addNotifyIcon(String name, MenuItem[] items)
{
_name = name;
notifyIcon = new System.Windows.Forms.NotifyIcon();
notifyIcon.Visible = true;
LoggerStatus_DelegateMethod(false); //set name and icon
ContextMenu contextMenu1 = new ContextMenu();
contextMenu1.MenuItems.AddRange(items);
contextMenu1.MenuItems.Add(new MenuItem("Quit", (s, e) =>
{
notifyIcon.Dispose();
foreach (ProcessThread thread in Process.GetCurrentProcess().Threads)
{
thread.Dispose();
}
Process.GetCurrentProcess().Kill();
}));
notifyIcon.ContextMenu = contextMenu1;
}
示例14: MainWindow
public MainWindow()
{
InitializeComponent();
ac = new Anniversary_container();
ac.loadDatas();
ni = new NotifyIcon();
ni.Icon = Properties.Resources.date_green;
ni.Visible = true;
ni.DoubleClick += ni_DoubleClick;
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(1, 0, 0);
timer.Tick += timer_Tick;
timer_Tick(this, EventArgs.Empty);
timer.Start();
mainWindow.Closing += (s1, e1) => { ni.Dispose(); };
mainWindow.StateChanged += mainWindow_StateChanged;
manageButton.Click += manageButton_Click;
updateWindow();
}
示例15: InitTray
/// <summary>
/// Инициализация иконки трея
/// </summary>
private void InitTray()
{
var notifyIcon = new NotifyIcon
{
Visible = true,
Icon = RapidMessenger.Properties.Resources.Icon,
ContextMenu = InitTrayContextMenu()
};
notifyIcon.DoubleClick += (sender, args) =>
{
var mainWindow = MainWindow;
if (mainWindow != null)
{
mainWindow.Show();
mainWindow.WindowState = WindowState.Normal;
mainWindow.Activate();
}
};
Exit += (sender, args) => notifyIcon.Dispose();
}