/// <summary> /// Loads shutdown actions from the settings. /// </summary> private void GetShutdownActionsFromSettings() { SystemStateDialogSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SystemStateDialogSettings>(); _shutdownItemList = settings.ShutdownItemList; // Add the SleepTimer, if the Element is missing in the current configuration bool foundSleepTimer = false; foreach (SystemStateItem item in _shutdownItemList) { if (item.Action == SystemStateAction.SleepTimer) { foundSleepTimer = true; break; } } if (foundSleepTimer == false) { // Add the SleepTimerItem after "Shutdown" SystemStateItem sleepTimerItem = new SystemStateItem(SystemStateAction.SleepTimer, true); int index = 0; foreach (SystemStateItem item in _shutdownItemList) { index++; if (item.Action == SystemStateAction.Shutdown) { break; } } _shutdownItemList.Insert(index, sleepTimerItem); } }
private void SetLastSleepTimerAction(SystemStateAction action) { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); SystemStateDialogSettings settings = settingsManager.Load <SystemStateDialogSettings>(); settings.LastSleepTimerAction = action; settingsManager.Save(settings); }
/// <summary> /// Saves the current state to the settings file. /// </summary> public void SaveSettings() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); SystemStateDialogSettings settings = settingsManager.Load <SystemStateDialogSettings>(); // Apply new shutdown item list settings.ShutdownItemList = _shutdownItemList; settingsManager.Save(settings); }
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(); }
/// <summary> /// Loads shutdown actions from the settings. /// </summary> private void GetShutdownActionsFromSettings() { SystemStateDialogSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SystemStateDialogSettings>(); _shutdownItemList = settings.ShutdownItemList; // Add the SleepTimer, if the Element is missing in the current configuration bool foundSleepTimer = false; foreach (SystemStateItem item in _shutdownItemList) { if (item.Action == SystemStateAction.SleepTimer) { foundSleepTimer = true; break; } } if (foundSleepTimer == false) { // Add the SleepTimerItem after "Shutdown" SystemStateItem sleepTimerItem = new SystemStateItem(SystemStateAction.SleepTimer, true); int index = 0; foreach (SystemStateItem item in _shutdownItemList) { index++; if (item.Action == SystemStateAction.Shutdown) { break; } } _shutdownItemList.Insert(index, sleepTimerItem); } // Check if there were new items added and append them to list var allShutdownItems = SystemStateDialogSettings.CreateDefaultShutdownMenu(); foreach (SystemStateItem item in allShutdownItems) { if (!_shutdownItemList.Exists(i => i.Action == item.Action)) { _shutdownItemList.Add(item); } } }
/// <summary> /// Saves the current state to the settings file. /// </summary> public void SaveSettings() { ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>(); SystemStateDialogSettings settings = settingsManager.Load <SystemStateDialogSettings>(); // Apply new shutdown item list settings.ShutdownItemList = _shutdownItemList; // Test the SleepTimer-MaxMinutes int _maxMinutes = 0; if (Int32.TryParse(MaxMinutes, out _maxMinutes)) { if (_maxMinutes > 0) { settings.MaxSleepTimeout = _maxMinutes; } } settingsManager.Save(settings); }
/// <summary> /// Loads SleepTimer-related configuration from the settings. /// </summary> private void GetSleepTimerConfigFromSettings() { SystemStateDialogSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SystemStateDialogSettings>(); MaxMinutes = settings.MaxSleepTimeout.ToString(); }
private void GetShutdownActionsFromSettings() { SystemStateDialogSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SystemStateDialogSettings>(); ShutdownItemList = settings.ShutdownItemList; }