コード例 #1
0
        protected void UpdateMenuItems()
        {
            _menuItems.Clear();
            List <SystemStateItem> shutdownItems = _settings.Settings.ShutdownItemList;

            if (shutdownItems != null)
            {
                bool            timerActive = false;
                SleepTimerModel stm         = ServiceRegistration.Get <IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as SleepTimerModel;
                if (stm != null && stm.IsSleepTimerActive)
                {
                    timerActive = true;
                }

                foreach (SystemStateItem shutdownItem in shutdownItems)
                {
                    if (!shutdownItem.Enabled)
                    {
                        continue;
                    }
                    ListItem item = new ListItem(Consts.KEY_NAME, Consts.GetResourceIdentifierForMenuItem(shutdownItem.Action, timerActive));
                    item.AdditionalProperties[KEY_SHUTDOWN_ACTION] = shutdownItem.Action;
                    item.Command = new MethodDelegateCommand(() => SelectItem(item));
                    _menuItems.Add(item);
                }
            }
            _menuItems.FireChange();
        }
コード例 #2
0
        protected void DoAction(SystemStateAction action)
        {
            switch (action)
            {
            case SystemStateAction.Suspend:
                ServiceRegistration.Get <ISystemStateService>().Suspend();
                return;

            case SystemStateAction.Hibernate:
                ServiceRegistration.Get <ISystemStateService>().Hibernate();
                return;

            case SystemStateAction.Shutdown:
                ServiceRegistration.Get <ISystemStateService>().Shutdown();
                return;

            case SystemStateAction.Restart:
                ServiceRegistration.Get <ISystemStateService>().Restart();
                return;

            case SystemStateAction.Logoff:
                ServiceRegistration.Get <ISystemStateService>().Logoff();
                return;

            case SystemStateAction.CloseMP:
                ServiceRegistration.Get <IScreenControl>().Shutdown();
                return;

            case SystemStateAction.RestartMP:
                ServiceRegistration.Get <IScreenControl>().Restart();
                return;

            case SystemStateAction.MinimizeMP:
                ServiceRegistration.Get <IScreenControl>().Minimize();
                return;

            case SystemStateAction.SleepTimer:
                SleepTimerModel stm = ServiceRegistration.Get <IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as SleepTimerModel;
                if (stm == null || stm.IsSleepTimerActive == false)
                {
                    CloseMenu();
                    ServiceRegistration.Get <IWorkflowManager>().NavigatePush(Consts.WF_STATE_ID_SLEEP_TIMER_DIALOG);
                }
                else
                {
                    stm.Stop();
                }
                _needsUpdate = true;
                break;
            }
        }