Пример #1
0
 void trayIcon_ControlPanel_Click(object sender, EventArgs e)
 {
     controlWindow.Show();
     if (popupDial.IsVisible)
     {
         popupDial.Hide(); // Prevent dial from appearing
     }
 }
Пример #2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            this.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;

            TryLoadController();

            // Attach event handlers
            controller.ConnectNotification    += OnControllerConnected;
            controller.DisconnectNotification += OnControllerDisconnected;

            viewModel = new ViewModel();

            controlWindow = new ControlWindow(viewModel);
            popupDial     = new PopupDial(viewModel);

            LoadEngines(controlWindow);

            #if DEBUG
            controlWindow.Show();
            #endif

            updateTimer          = new Timer(UPDATE_INTERVAL);
            updateTimer.Elapsed += updateTimer_Elapsed;
            updateTimer.Enabled  = controller.Connected;

            connectTimer          = new Timer(CONNECT_INTERVAL);
            connectTimer.Elapsed += connectTimer_Elapsed;
            connectTimer.Enabled  = !controller.Connected;

            ///// Tray Icon & Tray Menu /////

            trayIcon      = new WinForms.NotifyIcon();
            trayIcon.Text = "HexLight Controller";
            trayIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(
                System.Reflection.Assembly.GetEntryAssembly().ManifestModule.Name);
            trayIcon.Click  += trayIcon_Click;
            trayIcon.Visible = true;

            trayIcon.ContextMenu = new WinForms.ContextMenu(new[] {
                new WinForms.MenuItem("Control Panel", trayIcon_ControlPanel_Click),
                new WinForms.MenuItem("Settings", trayIcon_Settings_Click),
                new WinForms.MenuItem("Exit", trayIcon_Exit_Click),
            });
        }