Ejemplo n.º 1
0
        private void Logout()
        {
            _usageChecker.Dispose();
            _usageChecker = null;

            SetLoginPanel();
            _statusPanelController.ResetIcon();
        }
Ejemplo n.º 2
0
        public override NSApplicationTerminateReply ApplicationShouldTerminate(NSApplication sender)
        {
            // Clean up all of the panels, and disposable resources
            if (_usageChecker != null)
            {
                _usageChecker.Dispose();
                _usageChecker = null;
            }

            if (_statusPanelController != null)
            {
                _statusPanelController.Dispose();
                _statusPanelController = null;
            }

            return NSApplicationTerminateReply.Now;
        }
Ejemplo n.º 3
0
        public override NSApplicationTerminateReply ApplicationShouldTerminate(NSApplication sender)
        {
            // Clean up all of the panels, and disposable resources
            if (_usageChecker != null)
            {
                _usageChecker.Dispose();
                _usageChecker = null;
            }

            if (_statusPanelController != null)
            {
                _statusPanelController.Dispose();
                _statusPanelController = null;
            }

            return(NSApplicationTerminateReply.Now);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Panel to display should be the usage status
        /// </summary>
        private void SetStatusPanel()
        {
            var hashCode = SettingsManager.GetSetting(SettingsManager.KeyHashCode);

            if (string.IsNullOrWhiteSpace(hashCode))
            {
                SetLoginPanel();
            }

            // Since this is init, we may have a different hash code, so create a new usage checker
            // TODO: Ideally UsageChecker needs to be refactored out and put into the UsagePanel
            if (_usageChecker != null)
            {
                _usageChecker.Dispose();
            }

            _usageChecker = new UsageChecker(hashCode);

            // Instantiate the usage panel and hook up the neccessary events
            var panelController = new UsagePanelController();

            panelController.RefreshButtonClicked += (sender, e) => _usageChecker.UpdateUsageInformation();
            panelController.QuitButtonClicked    += (sender, e) => NSApplication.SharedApplication.Terminate(sender as UsagePanelController);
            panelController.LogoutButtonClicked  += (sender, e) => Logout();

            // Whenever the usage checker gets a new value, update the UI
            _usageChecker.UsageUpdated += (sender, e) =>
            {
                if (e.UsageInformation != null)
                {
                    panelController.UpdateUsage(e.UsageInformation);
                }
            };

            if (_statusPanelController != null)
            {
                _statusPanelController.PanelController = panelController;
            }
            else
            {
                _statusPanelController = new StatusPanelController(panelController);
            }
        }
Ejemplo n.º 5
0
        private void Logout()
        {
            _usageChecker.Dispose();
            _usageChecker = null;

            SetLoginPanel();
            _statusPanelController.ResetIcon();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Panel to display should be the usage status
        /// </summary>
        private void SetStatusPanel()
        {
            var hashCode = SettingsManager.GetSetting(SettingsManager.KeyHashCode);

            if (string.IsNullOrWhiteSpace(hashCode))
                SetLoginPanel();

            // Since this is init, we may have a different hash code, so create a new usage checker
            // TODO: Ideally UsageChecker needs to be refactored out and put into the UsagePanel
            if (_usageChecker != null)
                _usageChecker.Dispose();

            _usageChecker = new UsageChecker(hashCode);

            // Instantiate the usage panel and hook up the neccessary events
            var panelController = new UsagePanelController();

            panelController.RefreshButtonClicked += (sender, e) => _usageChecker.UpdateUsageInformation();
            panelController.QuitButtonClicked += (sender, e) => NSApplication.SharedApplication.Terminate(sender as UsagePanelController);
            panelController.LogoutButtonClicked += (sender, e) => Logout();

            // Whenever the usage checker gets a new value, update the UI
            _usageChecker.UsageUpdated += (sender, e) =>
            {
                if (e.UsageInformation != null)
                    panelController.UpdateUsage(e.UsageInformation);
            };

            if (_statusPanelController != null)
                _statusPanelController.PanelController = panelController;
            else
                _statusPanelController = new StatusPanelController(panelController);
        }