void menuItem_Click(object sender, ToolStripItemClickedEventArgs e) { ToolStripItem menuItem = e.ClickedItem; if (menuItem == menuItem1) { if (mousePointerThread != null) { mousePointerThread.Abort(); } keyCheckHook_temp.unhook(); notifyIcon.Dispose(); myWindow.Close(); System.Windows.Application.Current.Shutdown(); } else if (menuItem == menuItem2) { // Minimize or Restore the Window if (myWindow.WindowState == System.Windows.WindowState.Normal) { myWindow.WindowState = System.Windows.WindowState.Minimized; myWindow.Visibility = System.Windows.Visibility.Hidden; menuItem2.Text = "Restore"; } else { myWindow.Show(); myWindow.WindowState = System.Windows.WindowState.Normal; menuItem2.Text = "Minimize"; } } }
private void InitialTray() { if (notifyIcon != null) { notifyIcon.Dispose(); } //设置托盘的各个属性 Forms.NotifyIcon notifyIcon1 = new Forms.NotifyIcon(); notifyIcon = notifyIcon1; notifyIcon.BalloonTipText = "程序隐藏至托盘..."; notifyIcon.Text = "歌词音乐工具by gxh"; System.Drawing.Icon icon = ResourcesResx.icon.Icon1; notifyIcon.Icon = icon; notifyIcon.Visible = true; notifyIcon.ShowBalloonTip(2000); notifyIcon.MouseClick += new Forms.MouseEventHandler(NotifyIcon_MouseClick); ////设置菜单项 //System.Windows.Forms.MenuItem menu1 = new System.Windows.Forms.MenuItem("test"); Forms.MenuItem active = new Forms.MenuItem("Active"); active.Click += new EventHandler(ActiveWindow); //System.Windows.Forms.MenuItem menu = new Forms.MenuItem("菜单", new System.Windows.Forms.MenuItem[] {/*menu1, menu2*/ }); //退出菜单项 Forms.MenuItem exit = new Forms.MenuItem("Exit"); exit.Click += new EventHandler(Exit_Click); //关联托盘控件 System.Windows.Forms.MenuItem[] childen = new Forms.MenuItem[] { active, exit }; notifyIcon.ContextMenu = new Forms.ContextMenu(childen); }
private void exit_Click(object sender, EventArgs e) { if (System.Windows.MessageBox.Show("确定要关闭吗?", "退出", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { notifyIcon.Dispose(); System.Windows.Application.Current.Shutdown(); } }
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(); } } }
protected override void OnVisualParentChanged(DependencyObject oldParent) { base.OnVisualParentChanged(oldParent); var window = Window.GetWindow(this); if (window != null) { window.Closed += (s, a) => _trayIcon.Dispose(); } }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); m_trayIcon.Dispose(); }
void shutdownServer() { isAppExiting = true; try { this.Close(); } catch (Exception e) { } TippuTrayNotify.Visible = false; TippuTrayNotify.Dispose(); }
//Functions related with IconTray protected override void OnClosing(CancelEventArgs e) { if (fMonoFramework) { base.OnClosing(e); return; } if (!fInstClose) { e.Cancel = true; this.Hide(); if (!fOneShot) { AppNotifyIcon.ShowBalloonTip(3000); fOneShot = true; } } else { NotifyMenu.Dispose(); AppNotifyIcon.Dispose(); } }
public void Dispose() { _exitMenuItem.Click -= ExitOnClick; _openUrlMenuItem.Click -= OpenUrlOnClick; _notifyIcon.DoubleClick -= NotifyIconOnDoubleClick; _notifyIcon?.Dispose(); }
// Not doing this will leave the icon after app closure protected override void OnClosing(CancelEventArgs e) { if (_notifyIcon != null) { _notifyIcon.Dispose(); } }
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); }
public void BalloonTip(string title, string message, int timeToShow, bool clickable) { //ni.BalloonTipTitle = title; //ni.BalloonTipText = message; //ni.Visible = true; //ni.ShowBalloonTip(timeToShow); //ni.BalloonTipClicked += new EventHandler(notifyIcon_BalloonTipClicked); //ni.BalloonTipIcon = ToolTipIcon.Error; var notification = new System.Windows.Forms.NotifyIcon() { Visible = true, Icon = System.Drawing.Icon.ExtractAssociatedIcon(appIcon), //optional - BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info, BalloonTipTitle = title, BalloonTipText = message }; //Display for 5 seconds. notification.ShowBalloonTip(timeToShow); //Click event handler notification.BalloonTipClicked += new EventHandler(notifyIcon_BalloonTipClicked); // This will let the balloon close after it's 5 second timeout // for demonstration purposes. Comment this out to see what happens // when dispose is called while a balloon is still visible. //Thread.Sleep(10000); // The notification should be disposed when you don't need it anymore, // but doing so will immediately close the balloon if it's visible. notification.Dispose(); }
protected override void OnExit(ExitEventArgs e) { // Shut down threads ProcessManager.Stop(); InputMapper.Stop(); ControllerManager.Stop(); Overlay.Stop(); // Save settings WoWmapper.Properties.Settings.Default.Save(); try { // Dispose mutex _mutex?.ReleaseMutex(); _mutex?.Dispose(); } catch { } _notifyIcon.Visible = false; _notifyIcon.Dispose(); // Exit application base.OnExit(e); }
private WinForms::ContextMenuStrip InitMenu() { WinForms::ContextMenuStrip contextMenu = new WinForms::ContextMenuStrip(); void MenuShow_Click(object Sender, EventArgs e) { notifierWindow.RestoreWindowState(); } void MenuClose_Click(object Sender, EventArgs e) { // Dispose and close the window which exits the app notifierWindow.Close(); contextMenu.Dispose(); trayIcon.Dispose(); Environment.Exit(0); } void MenuConsole_Click(object Sender, EventArgs e) { Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WFN.exe")); } void MenuShowActivity_Click(object Sender, EventArgs e) { App.GetActivityWindow().Show(); } contextMenu.Items.Add(Messages.NotifierTrayIcon_ShowNotifier, null, MenuShow_Click); contextMenu.Items.Add(Messages.NotifierTrayIcon_OpenConsole, null, MenuConsole_Click); contextMenu.Items.Add(Messages.NotifierTrayIcon_ShowActivityWindow, null, MenuShowActivity_Click); contextMenu.Items.Add(Messages.NotifierTrayIcon_DiscardAndClose, null, MenuClose_Click); return(contextMenu); }
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(); }
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(); } }; }
public void Sync() { this.fileSystemWatcher.EnableRaisingEvents = false; System.Threading.Thread.Sleep(500 + randomizer.Next(500, 1000) + randomizer.Next(500, 1500)); try { var db = new PwDatabase(); db.Open(this.database.IOConnectionInfo, this.database.MasterKey, new NullStatusLogger()); this.database.MergeIn(db, PwMergeMethod.Synchronize); db.Close(); AutoSyncExt.host.MainWindow.RefreshEntriesList(); } catch (Exception e) { this.database.Modified = true; var notification = new System.Windows.Forms.NotifyIcon() { Visible = true, Icon = System.Drawing.SystemIcons.Information, BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Warning, BalloonTipTitle = "KeePass.AutoSync", BalloonTipText = "Database: " + this.database.IOConnectionInfo.Path + Environment.NewLine + Environment.NewLine + e.Message, }; notification.ShowBalloonTip(5000); Thread.Sleep(10000); notification.Dispose(); } this.fileSystemWatcher.EnableRaisingEvents = true; }
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(); }; }
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(); }; }
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(); }
public void DisposeAndExit() { _backup.Dispose(); _trayIcon.Click -= TrayIconClick; _trayIcon.Dispose(); Shutdown(); }
private void ExitApplication() { _isExit = true; MainWindow.Close(); _notifyIcon.Dispose(); _notifyIcon = null; }
protected virtual void Dispose(bool all) { if (all) { _notifyIcon.Dispose(); } }
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(); }
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(); }
private void notify() { int start = (int)startNo.Value; int end = (int)endNo.Value; end = end == 0 ? lstVocabulary.Count : end; List <Vocabulary> lstLearning = lstVocabulary.GetRange(start, end - start); for (int i = 0; i <= nmFrequency.Value; i++) { foreach (Vocabulary vocabulary in lstLearning) { StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendLine(vocabulary.word); strBuilder.AppendLine("* " + vocabulary.translation); strBuilder.AppendLine("* " + vocabulary.translationVerb); strBuilder.AppendLine("* " + vocabulary.inOtherword); string balloon = strBuilder.ToString(); var notification = new System.Windows.Forms.NotifyIcon() { Visible = true, Icon = System.Drawing.SystemIcons.Information, BalloonTipText = balloon, }; notification.ShowBalloonTip(5000); Thread.Sleep(10000); notification.Dispose(); } ; } }
static void Main(string[] args) { string[] ports = SerialPort.GetPortNames(); string port_list = ""; foreach (string port in ports) { port_list += (port + "\n"); } var notification = new System.Windows.Forms.NotifyIcon() { Visible = true, Icon = System.Drawing.SystemIcons.Information, BalloonTipIcon = ToolTipIcon.None, // Setting this property results in a process GUID appearing at the bottom of the balloontip BalloonTipTitle = "Serial Ports Found:", BalloonTipText = port_list, }; //notification.BalloonTipClicked += new EventHandler(notifyIcon_BaloonTipClicked); notification.ShowBalloonTip(5000); notification.Dispose(); //Process.Start(@"C:\Program Files\PuTTY\putty.exe"); }
/// <summary> /// Dispose of all resources in an orderly fashion. /// </summary> public override void Dispose() { if (aboutBox != null) { aboutBox.Dispose(); aboutBox = null; } if (tracker != null) { tracker.Dispose(); tracker = null; } if (librarian != null) { librarian.CollectionChanged -= DoTaskCollectionChanged; librarian.Dispose(); librarian = null; } if (controller != null) { controller.LyricsProgressReport -= DoLyricsProgressReport; controller.LyricsUpdated -= DoLyricsUpdated; controller.Quiting -= DoQuiting; controller.TrackPlaying -= DoTrackPlaying; controller.TrackStopped -= DoTrackStopped; // if running from IDE force iTunes to shutdown, force COM detach. Poking around // in the debugger tends to destabalize the COM interface so we shut it down when // invoked from the Debugger to avoid any confusion. controller.Dispose(System.Diagnostics.Debugger.IsAttached); controller = null; } if (manager != null) { manager.KeyPressed -= ExecuteHotKeyAction; manager.Dispose(); manager = null; } if (trayIcon != null) { trayIcon.ContextMenu.Popup -= SetMenuItemStates; trayIcon.ContextMenu.Dispose(); trayIcon.ContextMenu = null; trayIcon.MouseDown -= DoTrayIconMouseDown; trayIcon.Dispose(); trayIcon = null; } base.Dispose(); isDisposed = true; }
static void Main() { Composer.Init(); Settings.LoadConfig(); Settings.LoadSequences(); KeyboardHook.Init(); Settings.StartWatchConfigFile(); try { WinForms.Application.EnableVisualStyles(); WinForms.Application.SetCompatibleTextRenderingDefault(false); m_control = new RemoteControl(); m_control.DisableEvent += OnDisableEvent; m_control.ExitEvent += OnExitEvent; m_control.TriggerDisableEvent(); m_tray_icon = new WinForms.NotifyIcon { Visible = true, Icon = Properties.Resources.IconNormal, ContextMenu = new WinForms.ContextMenu(new[] { new WinForms.MenuItem("WinCompose") { Enabled = false }, new WinForms.MenuItem("-"), new WinForms.MenuItem(i18n.Text.ShowSequences, ShowSequencesClicked), new WinForms.MenuItem(i18n.Text.ShowOptions, ShowOptionsClicked), /* Keep a reference on this entry */ m_disable_item = new WinForms.MenuItem(i18n.Text.Disable, DisableClicked), new WinForms.MenuItem(i18n.Text.About, AboutClicked), new WinForms.MenuItem("-"), new WinForms.MenuItem(i18n.Text.Restart, RestartClicked), new WinForms.MenuItem(i18n.Text.Exit, OnExitEvent), }) }; m_tray_icon.DoubleClick += NotifyiconDoubleclicked; Composer.Changed += ComposerStateChanged; WinForms.Application.Run(); m_tray_icon.Dispose(); } finally { Composer.Changed -= ComposerStateChanged; m_control.DisableEvent -= OnDisableEvent; m_control.ExitEvent -= OnExitEvent; Settings.StopWatchConfigFile(); KeyboardHook.Fini(); Settings.SaveConfig(); Composer.Fini(); } }
public void Close() { log.Info("Closing TrayIcon"); notify.Visible = false; notify.Icon = null; notify.Dispose(); }
private void RemoveIcon() { if (ni != null) { ni.Dispose(); ni = null; } }
static public void Close() { if (ni != null) { ni.Visible = false; ni.Dispose(); } }
public void ExitApplication() { _isExit = true; MainWindow.Close(); _notifyIcon.Visible = false; _notifyIcon.Dispose(); _notifyIcon = null; }
private void ExitApplication() { _isExit = true; MainWindow?.Close(); _notifyIcon.Dispose(); _notifyIcon = null; Current.Shutdown(0); }
protected override void OnExit(ExitEventArgs e) { ips?.Dispose(); iss?.Dispose(); ni?.Dispose(); base.OnExit(e); }
protected override void OnExit(ExitEventArgs e) { _notifyIcon.Dispose(); _timerViewModel.Dispose(); _timerStore.Dispose(); base.OnExit(e); }
public App() { DIService.Initialize(); _globalData = DIService.GetSingleton<GlobalData>(); _notifyIcon = InitNotifyIcon(); Exit += (sender, args) => _notifyIcon.Dispose(); }
public static void RemoveIcon() { if (Notify != null) { Notify.Visible = false; Notify.Dispose(); } }
private void menuItem1_Click(object sender, EventArgs e) { if (kinectRegion.KinectSensor != null) { kinectRegion.KinectSensor.Stop(); } notifyIcon.Dispose(); System.Windows.Application.Current.Shutdown(); }
/// <summary> /// メインウィンドウのステート変更イベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_StateChanged(object sender, EventArgs e) { // 最小化時にタスクバーから消し、アイコン化する if (WindowState == WindowState.Minimized) { ShowInTaskbar = false; if (notifyIcon == null) { var icon = App.GetResourceStream(new Uri("Images/icon.ico", UriKind.Relative)).Stream; var menu = new Forms.ContextMenuStrip(); menu.Items.Add(new Forms.ToolStripMenuItem("表示サイズ自動切り替え", null, (s, ev) => { if (s is Forms.ToolStripMenuItem item) { item.Checked = !item.Checked; var vm = DataContext as MainViewModel; if (vm != null) { vm.IsCheckedAutoSwitch = item.Checked; } } })); menu.Items.Add(new Forms.ToolStripSeparator()); menu.Items.Add(new Forms.ToolStripMenuItem("終了", null, (s, ev) => { App.Current.Shutdown(); })); notifyIcon = new Forms.NotifyIcon { Visible = true, Icon = new System.Drawing.Icon(icon), Text = "UmaFull", ContextMenuStrip = menu }; notifyIcon.MouseClick += (s, ev) => { if (ev.Button == Forms.MouseButtons.Left) { WindowState = WindowState.Normal; Activate(); } }; } } else if (WindowState == WindowState.Normal) { // サイズ復元時にアイコン化を解除してタスクバーの表示を再開します if (notifyIcon != null) { notifyIcon.Dispose(); notifyIcon = null; } ShowInTaskbar = true; } }
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(); }
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; }
/// <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; }
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(); }
/// <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(); }
private void TrayServiceThreadStart() { notifyIcon = new NotifyIcon(); notifyIcon.Icon = CommonResources.Resources2011.Icon; notifyIcon.Visible = true; var menu = new ContextMenu(); menu.MenuItems.Add( "Force GC", (s, e) => GC.Collect(3, GCCollectionMode.Forced)); menu.MenuItems.Add( "Quit", (s, e) => daemonService.Shutdown()); notifyIcon.ContextMenu = menu; daemonService.ShuttingDown += (sender, args) => { notifyIcon.Visible = false; notifyIcon.Dispose(); }; Application.Run(); }
/// <summary> /// Dispose inner NotifyIcon instance /// </summary> /// <param name="icon">inner NotifyIcon instance</param> protected internal virtual void DisposeTray(NotifyIcon icon) { if (null != icon) icon.Dispose(); }
/// <summary> /// Disposes the trayicon. /// </summary> /// <param name="trayicon">The trayicon.</param> /// <remarks>Documented by Dev02, 2007-11-21</remarks> private void TrayIconDispose(NotifyIcon trayicon) { if (trayicon != null) { trayicon.Icon = null; trayicon.Visible = false; trayicon.Dispose(); } return; }
static void Main(string[] args) { string pluginsFolder; // =============================================== // Configuração para iniciar junto ao sistema. // =============================================== RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); registryKey.DeleteValue(Application.ProductName, false); registryKey.SetValue(Application.ProductName, "\"" + Application.ExecutablePath.ToString() + "\""); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); pluginsFolder = Settings.Default.PluginFolder; PluginManager plgManager = new PluginManager(); pluginsList = plgManager.FindPlugins(pluginsFolder); // =============================================== // Criação do ícone // =============================================== MainMenu = new ContextMenu(); NotifyIcon notifyIcon = new NotifyIcon() { Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath), Text = Settings.Default.CurrentDirectory, ContextMenu = CreateMenus(), Visible = true }; // =============================================== // Inicia a aplicação. // =============================================== try { Application.Run(); } finally { notifyIcon.Visible = false; notifyIcon.Dispose(); } }
public NotificationController(MainWindow window) { this.window = window; icon = new NotifyIcon(); icon.Visible = true; icon.DoubleClick += (sender, e) => { window.WindowState = System.Windows.WindowState.Normal; window.Activate(); }; icon.BalloonTipClicked += (sender, e) => { window.WindowState = System.Windows.WindowState.Normal; window.Activate(); }; var menu = new ContextMenu(); // Add Rules menu.MenuItems.Add(resources["AddRules"] as string, (sender, e) => { Rules.OpenEditor(false); }); // Proxy Type menu.MenuItems.Add(window.proxyTypeContextMenu); // Proxy Mode var proxyModeNormalItem = new MenuItem(resources["Normal"] as string); var proxyModeForwardAllItem=new MenuItem(resources["ForwardAll"] as string); var proxyModeCheckSwitcher = new Action(() => { proxyModeNormalItem.Checked = !settings.ForwardAll; proxyModeForwardAllItem.Checked = settings.ForwardAll; }); proxyModeCheckSwitcher(); settings.PropertyChanged += (sender, e) => { if (e.PropertyName == "ForwardAll") { proxyModeCheckSwitcher(); } }; proxyModeNormalItem.Click += (sender, e) => { if (settings.ForwardAll) { settings.ForwardAll = false; } }; proxyModeForwardAllItem.Click += (sender, e) => { if (!settings.ForwardAll) { settings.ForwardAll = true; } }; proxyModeNormalItem.RadioCheck = true; proxyModeForwardAllItem.RadioCheck = true; var proxyModeMenuItem = new MenuItem(resources["ProxyMode"] as string, new MenuItem[]{ proxyModeNormalItem, proxyModeForwardAllItem }); menu.MenuItems.Add(proxyModeMenuItem); // Profiles menu.MenuItems.Add(window.profileContextMenu); // Restart Application menu.MenuItems.Add(resources["Restart_Text"] as string, (sender, e) => { Process.Start(System.Windows.Forms.Application.ExecutablePath, "restart"); App.Current.Shutdown(); }); // Exit menu.MenuItems.Add(resources["Exit"] as string, (sender, e) => { System.Windows.Application.Current.Shutdown(); }); // End icon.ContextMenu = menu; SetStatus(settings.ProxyType, Status.Stopped, resources["NotConnected"] as string); System.Windows.Application.Current.Exit += (sender, e) => { icon.Dispose(); }; }
static void Main() { // Do this before Composer.Init() because of the Disabled setting Settings.LoadConfig(); Composer.Init(); Settings.LoadSequences(); KeyboardHook.Init(); Updater.Init(); Settings.StartWatchConfigFile(); try { WinForms.Application.EnableVisualStyles(); WinForms.Application.SetCompatibleTextRenderingDefault(false); m_control = new RemoteControl(); m_control.DisableEvent += OnDisableEvent; m_control.DisableEvent += SysTrayUpdateCallback; m_control.ExitEvent += OnExitEvent; m_control.TriggerDisableEvent(); m_tray_icon = new WinForms.NotifyIcon { Visible = true, //Icon = GetCurrentIcon(), //Text = GetCurrentToolTip(), ContextMenu = new WinForms.ContextMenu(new[] { new TitleMenuItem(), new WinForms.MenuItem("-"), new WinForms.MenuItem(i18n.Text.ShowSequences, ShowSequencesClicked), new WinForms.MenuItem(i18n.Text.ShowOptions, ShowOptionsClicked), m_help_item = /* Keep a reference on this entry */ new WinForms.MenuItem(i18n.Text.Help, new[] { new WinForms.MenuItem(i18n.Text.About, AboutClicked), new WinForms.MenuItem(i18n.Text.VisitWebsite, delegate(object o, EventArgs e) { System.Diagnostics.Process.Start("http://wincompose.info/"); }), m_download_item = /* Keep a reference on this entry */ new WinForms.MenuItem("", DownloadClicked) { Visible = false }, }), new WinForms.MenuItem("-"), m_disable_item = /* Keep a reference on this entry */ new WinForms.MenuItem(i18n.Text.Disable, DisableClicked), new WinForms.MenuItem(i18n.Text.Restart, RestartClicked), new WinForms.MenuItem(i18n.Text.Exit, OnExitEvent), }) }; m_tray_icon.DoubleClick += NotifyiconDoubleclicked; Composer.Changed += SysTrayUpdateCallback; Updater.Changed += SysTrayUpdateCallback; SysTrayUpdateCallback(null, new EventArgs()); Updater.Changed += UpdaterStateChanged; UpdaterStateChanged(null, new EventArgs()); WinForms.Application.Run(); m_tray_icon.Dispose(); } finally { Composer.Changed -= SysTrayUpdateCallback; Updater.Changed -= SysTrayUpdateCallback; Updater.Changed -= UpdaterStateChanged; m_control.DisableEvent -= OnDisableEvent; m_control.ExitEvent -= OnExitEvent; Settings.StopWatchConfigFile(); Updater.Fini(); KeyboardHook.Fini(); Settings.SaveConfig(); Composer.Fini(); Updater.Fini(); } }
static void Main(string[] args) { if (PriorProcess() != null) { MessageBox.Show("打印辅助系统已经启动"); return;// only one instance } Directory.SetCurrentDirectory(Path.GetDirectoryName((String)Application.ExecutablePath)); if (Configure_Check() == false) return; if (CheckUpdate() == true) { if(StartAutoUpdate() == true) return; //exit the program and update } if (StartApp() == true) { checkandCreateStartup(); checkAndCreateShortcut(); mNotify = new NotifyIcon(); mNotify.Icon = Resource.trayicon; mNotify.Text = "车道加油辅助v1.1"; mNotify.Visible = true; PrepareUpload(); mTimer = new Timer(); mTimer.Interval = 10000; //execute the task per 10sec mTimer.Tick += MTimer_Tick; mTimer.Start(); Application.Run(); mNotify.Visible = false; mNotify.Dispose(); } }
public static void Main() { var iconPath = Path.Combine(Application.StartupPath, "csFiler.ico"); using (var icon = new Icon(iconPath)) using (var commandMenu = new ToolStripMenuItem("コマンド入力")) using (var exitMenuItem = new ToolStripMenuItem("終了")) using (var contextMenu = new ContextMenuStrip()) using (var taskTray = new NotifyIcon()) using (var hotKeyLoop = new HotKeyMessageLoop()) { taskTray.Icon = icon; taskTray.Text = "csFiler"; taskTray.ContextMenuStrip = contextMenu; var openCommand = new HotKey( new Action(() => { var window = new FilerWindow(); window.WindowStartupLocation = Wpf.WindowStartupLocation.CenterScreen; window.Show(); }), Key.V, ModifierKeys.Windows); hotKeyLoop.Add(openCommand); contextMenu.Items.AddRange( new ToolStripItem [] { commandMenu, exitMenuItem, }); contextMenu.Click += (sender, e) => openCommand.Action.Invoke(); exitMenuItem.Click += (sender, e) => Wpf.Application.Current.Shutdown(); var application = new Wpf.Application() { ShutdownMode = Wpf.ShutdownMode.OnExplicitShutdown, }; application.DispatcherUnhandledException += (sender, e) => { MessageBox.Show( string.Concat("想定外のエラーが発生しました。", Environment.NewLine, e.Exception.Message), "csFiler"); e.Handled = true; }; application.Exit += (sender, e) => { hotKeyLoop.Dispose(); taskTray.Dispose(); contextMenu.Dispose(); exitMenuItem.Dispose(); commandMenu.Dispose(); icon.Dispose(); }; taskTray.Visible = true; application.Run(); } }
public App() { _trayIcon = CreateTrayIcon(); _trayIcon.DoubleClick += TrayIconDoubleClick; Exit += (sender, args) => _trayIcon.Dispose(); }
private static void Main(string[] args) { _connectionFailures = 0; _configFile = DefaultConfigFile; if (args.Length > 0) { try { if (ProcessCommandLine(args)) return; } catch (CommandExecutionException ex) { MessageBox.Show(ex.Message, "Translator", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (CommandStructureException ex) { MessageBox.Show(ex.Message, "Translator", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Translator - Error processing command line", MessageBoxButtons.OK, MessageBoxIcon.Error); } } // Check for multiple instances. if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length != 1) { CopyDataWM.SendCopyDataMessage(Common.CmdPrefixShowTrayIcon); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); IrssLog.LogLevel = IrssLog.Level.Debug; IrssLog.Open("Translator.log"); Application.ThreadException += Application_ThreadException; // Initialize Variable List. _variables = new VariableList(); // Load configuration ... _config = Configuration.Load(_configFile); if (_config == null) { IrssLog.Warn("Failed to load configuration file ({0}), creating new configuration", _configFile); _config = new Configuration(); } // Adjust process priority ... AdjustPriority(_config.ProcessPriority); //foreach (ProgramSettings progSettings in _config.Programs) //{ // AppProfile profile = new AppProfile(); // profile.Name = progSettings.Name; // profile.MatchType = AppProfile.DetectionMethod.Executable; // profile.MatchParameters = progSettings.FileName; // profile.ButtonMappings.AddRange(progSettings.ButtonMappings); // AppProfile.Save(profile, "C:\\" + profile.Name + ".xml"); //} // Setup notify icon ... _container = new Container(); _notifyIcon = new NotifyIcon(_container); _notifyIcon.ContextMenuStrip = new ContextMenuStrip(); _notifyIcon.Icon = Resources.Icon16Connecting; _notifyIcon.Text = "Translator - Connecting ..."; _notifyIcon.DoubleClick += ClickSetup; _notifyIcon.Visible = !_config.HideTrayIcon; // Setup the main form ... _mainForm = new MainForm(); // Start server communications ... bool clientStarted = false; IPAddress serverIP = Network.GetIPFromName(_config.ServerHost); IPEndPoint endPoint = new IPEndPoint(serverIP, Server.DefaultPort); try { clientStarted = StartClient(endPoint); } catch (Exception ex) { IrssLog.Error(ex); clientStarted = false; } if (clientStarted) { // Setup event notification ... SystemEvents.SessionEnding += SystemEvents_SessionEnding; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; try { _copyDataWM = new CopyDataWM(); _copyDataWM.Start(); } catch (Win32Exception ex) { IrssLog.Error("Error enabling CopyData messages: {0}", ex.ToString()); } Application.Run(); if (_copyDataWM != null) { _copyDataWM.Dispose(); _copyDataWM = null; } SystemEvents.SessionEnding -= SystemEvents_SessionEnding; SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged; StopClient(); } else { MessageBox.Show("Failed to start IR Server communications, refer to log file for more details.", "Translator - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); _inConfiguration = true; _mainForm.ShowDialog(); _inConfiguration = false; } // Dispose NotifyIcon ... _notifyIcon.Visible = false; _notifyIcon.Dispose(); _notifyIcon = null; // Dispose Container ... _container.Dispose(); _container = null; Application.ThreadException -= Application_ThreadException; IrssLog.Close(); }
private void useTrayIcon() { var trayIcon = new System.Windows.Forms.NotifyIcon(); trayIcon.Text = "Instant Rice Messenger"; trayIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().Location); trayIcon.ContextMenu = new ContextMenu(new MenuItem[] { new MenuItem("E&xit", (sender, e) => { saveConfig(); trayIcon.Visible = false; trayIcon.Dispose(); trayIcon = null; Close(); System.Windows.Application.Current.Shutdown(); })}); trayIcon.Visible = true; trayIcon.DoubleClick += (sender, e) => { WindowState = WindowState.Normal; eventWindowChanged(sender, e); }; StateChanged += eventWindowChanged; Closing += new System.ComponentModel.CancelEventHandler((sender, e) => { e.Cancel = true; WindowState = WindowState.Minimized; }); }
public void WI(string line, bool notiFy = true) { if (string.IsNullOrEmpty(line)) return; var text = string.Format("[{0}] {1}.", DateTime.UtcNow.ToString("MM/dd/yyyy hh:mm:ss.fff"), line); Console.WriteLine(text); wr.WriteLine(text); wr.Flush(); Trace.TraceInformation(text); Trace.Flush(); if (notiFy) { NotifyIcon noty = new NotifyIcon(); noty.Icon = SystemIcons.Information; noty.Visible = true; noty.ShowBalloonTip(5000, Program.AppName, line, ToolTipIcon.Info); noty.Dispose(); } }
private void InitTrayIcon() { ContextMenuStrip menu = new ContextMenuStrip(); menu.Items.AddRange(new ToolStripItem[] { new ToolStripMenuItem("Show log", null, (q, w) => Process.Start(Settings.LogFile)), new ToolStripMenuItem("Clear log", null, (q, w) => File.Delete(Settings.LogFile)), new ToolStripMenuItem("Open app location", null, (q, w) => Process.Start(Path.GetDirectoryName(Application.ExecutablePath))), new ToolStripMenuItem("Exit", null, (q, w) => Application.Exit()) }); _icon = new NotifyIcon() { Icon = Properties.Resources.synchronize, Text = AppName, ContextMenuStrip = menu, Visible = true }; _icon.MouseClick += (obj, args) => { if (args.Button == MouseButtons.Left) Process.Start(Settings.LogFile); }; Application.ApplicationExit += (obj, args) => { _icon.Dispose(); menu.Dispose(); }; }
static void Main() { // Do this before Composer.Init() because of the Disabled setting Settings.LoadConfig(); Composer.Init(); Settings.LoadSequences(); Updater.Init(); Settings.StartWatchConfigFile(); try { WinForms.Application.EnableVisualStyles(); WinForms.Application.SetCompatibleTextRenderingDefault(false); // Must call this after SetCompatibleTextRenderingDefault() // because it uses a WinForms timer which seems to open a // hidden window. The reason we use a WinForms timer is so that // the hook is installed from the main thread. KeyboardHook.Init(); m_control = new RemoteControl(); m_control.DisableEvent += OnDisableEvent; m_control.DisableEvent += SysTrayUpdateCallback; m_control.ExitEvent += OnExitEvent; m_control.TriggerDisableEvent(); m_tray_icon = new WinForms.NotifyIcon { Visible = true, ContextMenu = new WinForms.ContextMenu(new[] { new CustomMenuItem { Enabled = false, Text = "WinCompose", Scale = 1.05f, Bold = true, Gradient = true, MenuIcon = GetIcon(0), }, new WinForms.MenuItem("-"), new WinForms.MenuItem(i18n.Text.ShowSequences, ShowSequencesClicked), new WinForms.MenuItem(i18n.Text.ShowOptions, ShowOptionsClicked), m_help_item = /* Keep a reference on this entry */ new CustomMenuItem() { Text = i18n.Text.Help }, new WinForms.MenuItem("-"), m_disable_item = /* Keep a reference on this entry */ new WinForms.MenuItem(i18n.Text.Disable, DisableClicked), new WinForms.MenuItem(i18n.Text.Restart, RestartClicked), new WinForms.MenuItem(i18n.Text.Exit, OnExitEvent), }) }; m_tray_icon.DoubleClick += NotifyiconDoubleclicked; m_help_item.MenuItems.AddRange(new[] { new WinForms.MenuItem(i18n.Text.About, AboutClicked), new WinForms.MenuItem(i18n.Text.VisitWebsite, delegate(object o, EventArgs e) { System.Diagnostics.Process.Start("http://wincompose.info/"); }), m_download_item = /* Keep a reference on this entry */ new WinForms.MenuItem("", DownloadClicked) { Visible = false }, }); SysTray.AlwaysShow("wincompose[.]exe"); Composer.Changed += SysTrayUpdateCallback; Updater.Changed += SysTrayUpdateCallback; SysTrayUpdateCallback(null, new EventArgs()); Updater.Changed += UpdaterStateChanged; UpdaterStateChanged(null, new EventArgs()); WinForms.Application.Run(); m_tray_icon.Dispose(); } finally { Composer.Changed -= SysTrayUpdateCallback; Updater.Changed -= SysTrayUpdateCallback; Updater.Changed -= UpdaterStateChanged; m_control.DisableEvent -= OnDisableEvent; m_control.ExitEvent -= OnExitEvent; Settings.StopWatchConfigFile(); Updater.Fini(); KeyboardHook.Fini(); Settings.SaveConfig(); Composer.Fini(); Updater.Fini(); } }
private void Main_Resize(object sender, EventArgs e) { if (WindowState == FormWindowState.Minimized) { Visible = false; NotifyIcon ni = new NotifyIcon(); ni.Click += new EventHandler((s, ev) => { ni.Dispose(); Visible = true; WindowState = FormWindowState.Normal; }); ni.Icon = Icon; ni.Visible = true; } }