public static 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.MinimizeMP: ServiceRegistration.Get <IScreenControl>().Minimize(); return; } }
public static string GetResourceIdentifierForMenuItem(SystemStateAction systemStateAction, bool timerActive = false) { switch (systemStateAction) { case SystemStateAction.Suspend: return(RES_SYSTEM_SUSPEND_MENU_ITEM); case SystemStateAction.Hibernate: return(RES_SYSTEM_HIBERNATE_MENU_ITEM); case SystemStateAction.Shutdown: return(RES_SYSTEM_SHUTDOWN_MENU_ITEM); case SystemStateAction.Logoff: return(RES_SYSTEM_LOGOFF_MENU_ITEM); case SystemStateAction.Restart: return(RES_SYSTEM_RESTART_MENU_ITEM); case SystemStateAction.SleepTimer: return(timerActive ? RES_SYSTEM_SLEEPTIMER_STOP_MENU_ITEM : RES_SYSTEM_SLEEPTIMER_CFG_MENU_ITEM); case SystemStateAction.CloseMP: return(RES_MEDIAPORTAL_SHUTDOWN_MENU_ITEM); case SystemStateAction.MinimizeMP: return(RES_MEDIAPORTAL_MINIMIZE_MENU_ITEM); default: return(string.Empty); } }
private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { // update if (System.Threading.Monitor.TryEnter(_syncObject) == false) { return; } try { if (!_actSystemState.HasValue && _needConfigRead) { _needConfigRead = false; GetShutdownActionsFromSettings(); } UpdateButtonEnabled(); if (_actSystemState.HasValue) { // calculate Remaining Minutes TimeSpan ts = DateTime.Now - _startTime; int minutes = (int)ts.TotalMinutes; int rMin = InitialMinutes - minutes; if (RemainingMinutes != rMin) { RemainingMinutes = rMin; } ILocalization localization = ServiceRegistration.Get <ILocalization>(); string actionString = localization.ToString(Consts.GetResourceIdentifierForMenuItem(_actSystemState.Value)); string res = localization.ToString((RemainingMinutes <= 1) ? "[SleepTimer.ShutdownTextSingle]" : "[SleepTimer.ShutdownTextMulti]", actionString, RemainingMinutes); if (res != ShutdownText) { ShutdownText = res; } if (RemainingMinutes <= 0) { // finished, stop SleepTimer and do the action SystemStateAction toDo = _actSystemState.Value; Stop(); DoAction(toDo); } } else { ShutdownText = string.Empty; RemainingMinutes = 0; } } finally { System.Threading.Monitor.Exit(_syncObject); } }
private void SetLastSleepTimerAction(SystemStateAction action) { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); SystemStateDialogSettings settings = settingsManager.Load <SystemStateDialogSettings>(); settings.LastSleepTimerAction = action; settingsManager.Save(settings); }
protected void DoAction(SystemStateAction action) { // I don't like this way, but I need it... DoClose(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.MinimizeMP: ServiceRegistration.Get <IScreenControl>().Minimize(); return; case SystemStateAction.RestartMP: ServiceRegistration.Get <IScreenControl>().Restart(); 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) { ServiceRegistration.Get <IWorkflowManager>().NavigatePop(1); ServiceRegistration.Get <IWorkflowManager>().NavigatePush( Consts.WF_STATE_ID_SLEEP_TIMER_DIALOG); } else { stm.Stop(); UpdateShutdownItems(); } return; } }
protected void DoClose(SystemStateAction action) { switch(action) { case SystemStateAction.SleepTimer: return; default: ServiceRegistration.Get<IScreenManager>().CloseTopmostDialog(); return; } }
protected void DoClose(SystemStateAction action) { switch (action) { case SystemStateAction.SleepTimer: return; default: ServiceRegistration.Get <IScreenManager>().CloseTopmostDialog(); return; } }
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; } }
public static 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; } }
private bool TryGetAction(ListItem item, out SystemStateAction action) { action = SystemStateAction.Suspend; if (item == null) return false; object oIndex; if (item.AdditionalProperties.TryGetValue(Consts.KEY_INDEX, out oIndex)) { int? i = oIndex as int?; if (i.HasValue) { action = ShutdownItemList[i.Value].Action; return true; } } return false; }
private void GetShutdownActionsFromSettings() { SystemStateDialogSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SystemStateDialogSettings>(); PosibleShutdownModes = new List <SystemStateAction>(); List <SystemStateItem> lst = settings.ShutdownItemList; for (int i = 0; i < lst.Count; i++) { if (lst[i].Enabled == false) { continue; } switch (lst[i].Action) { case SystemStateAction.Shutdown: case SystemStateAction.Suspend: case SystemStateAction.Hibernate: PosibleShutdownModes.Add(lst[i].Action); break; } } // at least, one element is needed if (PosibleShutdownModes.Count == 0) { PosibleShutdownModes.Add(SystemStateAction.Shutdown); } // read the max sleeptime if (settings.MaxSleepTimeout.HasValue) { _maxSleepTimeInMinutes = settings.MaxSleepTimeout.Value; } // read the last action if (settings.LastSleepTimerAction.HasValue) { _wantedSystemState = settings.LastSleepTimerAction.Value; } UpdateButtonEnabled(); }
private bool TryGetAction(ListItem item, out SystemStateAction action) { action = SystemStateAction.Suspend; if (item == null) { return(false); } object oIndex; if (item.AdditionalProperties.TryGetValue(Consts.KEY_INDEX, out oIndex)) { int?i = oIndex as int?; if (i.HasValue) { action = ShutdownItemList[i.Value].Action; return(true); } } return(false); }
/// <summary> /// Provides a callable method for the skin to change the action of the sleeptimer. /// </summary> public void Select() { if (_actSystemState.HasValue) { return; } int index = 0; for (int i = 0; i < PosibleShutdownModes.Count; i++) { if (PosibleShutdownModes[i] == _wantedSystemState) { index = i; break; } } index = (index + 1) % PosibleShutdownModes.Count; _wantedSystemState = PosibleShutdownModes[index]; SetLastSleepTimerAction(_wantedSystemState); // update Buttontext & Buttonstates UpdateButtonEnabled(); }
public static string GetResourceIdentifierForMenuItem(SystemStateAction systemStateAction, bool timerActive = false) { switch (systemStateAction) { case SystemStateAction.Suspend: return RES_SYSTEM_SUSPEND_MENU_ITEM; case SystemStateAction.Hibernate: return RES_SYSTEM_HIBERNATE_MENU_ITEM; case SystemStateAction.Shutdown: return RES_SYSTEM_SHUTDOWN_MENU_ITEM; case SystemStateAction.Logoff: return RES_SYSTEM_LOGOFF_MENU_ITEM; case SystemStateAction.Restart: return RES_SYSTEM_RESTART_MENU_ITEM; case SystemStateAction.SleepTimer: return timerActive ? RES_SYSTEM_SLEEPTIMER_STOP_MENU_ITEM : RES_SYSTEM_SLEEPTIMER_CFG_MENU_ITEM; case SystemStateAction.CloseMP: return RES_MEDIAPORTAL_SHUTDOWN_MENU_ITEM; case SystemStateAction.MinimizeMP: return RES_MEDIAPORTAL_MINIMIZE_MENU_ITEM; default: return string.Empty; } }
internal SystemStateItem(SystemStateAction action, bool enabled) { Action = action; Enabled = enabled; }
/// <summary> /// Provides a callable method for the skin to change the action of the sleeptimer. /// </summary> public void Select() { if (_actSystemState.HasValue) return; int index = 0; for (int i = 0; i < PosibleShutdownModes.Count; i++) { if (PosibleShutdownModes[i] == _wantedSystemState) { index = i; break; } } index = (index + 1) % PosibleShutdownModes.Count; _wantedSystemState = PosibleShutdownModes[index]; SetLastSleepTimerAction(_wantedSystemState); // update Buttontext & Buttonstates UpdateButtonEnabled(); }
public static 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; } }
private void GetShutdownActionsFromSettings() { SystemStateDialogSettings settings = ServiceRegistration.Get<ISettingsManager>().Load<SystemStateDialogSettings>(); PosibleShutdownModes = new List<SystemStateAction>(); List<SystemStateItem> lst = settings.ShutdownItemList; for (int i = 0; i < lst.Count; i++) { if (lst[i].Enabled == false) continue; switch (lst[i].Action) { case SystemStateAction.Shutdown: case SystemStateAction.Suspend: case SystemStateAction.Hibernate: PosibleShutdownModes.Add(lst[i].Action); break; } } // at least, one element is needed if (PosibleShutdownModes.Count == 0) PosibleShutdownModes.Add(SystemStateAction.Shutdown); // read the max sleeptime if (settings.MaxSleepTimeout.HasValue) _maxSleepTimeInMinutes = settings.MaxSleepTimeout.Value; // read the last action if (settings.LastSleepTimerAction.HasValue) _wantedSystemState = settings.LastSleepTimerAction.Value; UpdateButtonEnabled(); }
protected void DoAction(SystemStateAction action) { // I don't like this way, but I need it... DoClose(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.MinimizeMP: ServiceRegistration.Get<IScreenControl>().Minimize(); return; case SystemStateAction.SleepTimer: Models.SleepTimerModel stm = ServiceRegistration.Get<IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as Models.SleepTimerModel; if (stm == null || stm.IsSleepTimerActive == false) { ServiceRegistration.Get<IWorkflowManager>().NavigatePop(1); ServiceRegistration.Get<IWorkflowManager>().NavigatePush( Consts.WF_STATE_ID_SLEEP_TIMER_DIALOG); } else { stm.Stop(); UpdateShutdownItems(); } return; } }
private void SetLastSleepTimerAction(SystemStateAction action) { ISettingsManager settingsManager = ServiceRegistration.Get<ISettingsManager>(); SystemStateDialogSettings settings = settingsManager.Load<SystemStateDialogSettings>(); settings.LastSleepTimerAction = action; settingsManager.Save(settings); }
public static 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.MinimizeMP: ServiceRegistration.Get<IScreenControl>().Minimize(); return; } }