예제 #1
0
        private static void StartMenu()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.AddMessageFilter(new ReadMessageFilter());

            menu = new SystemTrayMenu();
            Application.Run(menu);
        }
예제 #2
0
        private static void ServiceStatusTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var sc = new ServiceController(SERVICE_NAME);

            if (sc != null)
            {
                var status = sc.Status;

                if (status != ServiceStatus)
                {
                    // Update Menu Status Label
                    SystemTrayMenu.SetHeader(status.ToString());

                    // Set NotifyIcon Icon
                    if (status == ServiceControllerStatus.Running)
                    {
                        SystemTrayMenu.NotifyIcon.Icon = Properties.Resources.dataclient_status_running;
                    }
                    else
                    {
                        SystemTrayMenu.NotifyIcon.Icon = Properties.Resources.dataclient_status_stopped;
                    }

                    // Create Notification
                    if (status == ServiceControllerStatus.Running || status == ServiceControllerStatus.Stopped)
                    {
                        var notifyIcon = SystemTrayMenu.NotifyIcon;
                        notifyIcon.BalloonTipTitle = "TrakHound DataClient";
                        notifyIcon.BalloonTipText  = status.ToString();
                        notifyIcon.BalloonTipIcon  = ToolTipIcon.Info;
                        notifyIcon.ShowBalloonTip(5000);
                    }
                }

                ServiceStatus = status;
            }
        }