Esempio n. 1
0
        private static void StartMenu()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.AddMessageFilter(new ReadMessageFilter());

            menu = new SystemTrayMenu();
            Application.Run(menu);
        }
Esempio n. 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.analyticsserver_status_running;
                    }
                    else
                    {
                        SystemTrayMenu.NotifyIcon.Icon = Properties.Resources.analyticsserver_status_stopped;
                    }

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

                ServiceStatus = status;
            }
        }