コード例 #1
0
        private static void OnExit(object sender, EventArgs e)
        {
            LOG.Info("Exiting Application");
            // Clear tray icon on close
            if (TrayIcon != null)
            {
                TrayIcon.Visible = false;
            }

            // Send clear priority
            if (ProtoClient.Initialized)
            {
                TerminateScreenCapture();
                ProtoClient.TryClearPriority(SettingsManager.HyperionMessagePriority);
                DisconnectProtoClient();
            }

            if (SettingsManager.ApiEnabled)
            {
                _apiServer.StopServer();
            }

            // Unregister various event handlers
            SystemEvents.PowerModeChanged -= PowerModeChanged;
            SystemEvents.SessionSwitch    -= SessionSwitched;
            LOG.Info("Exit cleanup complete");
            Environment.Exit(0);
        }
コード例 #2
0
        private static void ExecuteToggleCaptureCommand(CaptureCommand command)
        {
            try
            {
                switch (command)
                {
                case CaptureCommand.ON:
                    TrayIcon.Icon   = Resources.Hyperion_enabled;
                    TrayIcon.Text   = AppConstants.TRAY_ICON_MSG_CAPTURE_ENABLED;
                    _captureEnabled = true;
                    _captureThread  = new Thread(TryStartCapture)
                    {
                        IsBackground = true
                    };
                    _captureThread.Start();
                    break;

                case CaptureCommand.OFF:
                    TrayIcon.Icon = Resources.Hyperion_disabled;
                    TrayIcon.Text = AppConstants.TRAY_ICON_MSG_CAPTURE_DISABLED;
                    TerminateScreenCapture();
                    ProtoClient.TryClearPriority(SettingsManager.HyperionMessagePriority);
                    DisconnectProtoClient();
                    break;

                default:
                    throw new NotImplementedException($"The capture command {command} is not supported");
                }
                LOG.Info($"Toggle capture command {command} completed");
            }
            finally
            {
                _captureToggleInProgress = false;
                LOG.Info("Toggle capture lock unset");
            }
        }