public SettingsManager() { _bluetooth = new BluetoothSettings(); _gps = new GpsSettings(); _mobileData = new MobileDataSettings(); _wifi = new WifiSettings(); }
private void RestorePreviousSettings() { if (_settingsState.HasValue) { IBluetoothSettings bluetooth = _settingsManager.Bluetooth; bluetooth.IsEnabled = _settingsState.Value.IsBluetoothEnabled; IGpsSettings gps = _settingsManager.Gps; gps.IsEnabled = _settingsState.Value.IsGpsEnabled; IMobileDataSettings mobileData = _settingsManager.MobileData; mobileData.IsEnabled = _settingsState.Value.IsMobileDataEnabled; IWifiSettings wifi = _settingsManager.Wifi; wifi.IsEnabled = _settingsState.Value.IsWifiEnabled; } }
private void SetNewSettings() { IBluetoothSettings bluetooth = _settingsManager.Bluetooth; bluetooth.IsEnabled = false; IGpsSettings gps = _settingsManager.Gps; gps.IsEnabled = true; IMobileDataSettings mobileData = _settingsManager.MobileData; mobileData.IsEnabled = true; IWifiSettings wifi = _settingsManager.Wifi; wifi.IsEnabled = false; }
private void SaveExistingSettings() { IBluetoothSettings bluetooth = _settingsManager.Bluetooth; bool wasBluetoothEnabled = bluetooth.IsEnabled; IGpsSettings gps = _settingsManager.Gps; bool wasGpsEnabled = gps.IsEnabled; IMobileDataSettings mobileData = _settingsManager.MobileData; bool wasMobileDataEnabled = mobileData.IsEnabled; IWifiSettings wifi = _settingsManager.Wifi; bool wasWifiEnabled = wifi.IsEnabled; _settingsState = new SettingsState { IsBluetoothEnabled = wasBluetoothEnabled, IsGpsEnabled = wasGpsEnabled, IsMobileDataEnabled = wasMobileDataEnabled, IsWifiEnabled = wasWifiEnabled }; }
static void Main(string[] args) { IApplicationController applicationController = new ApplicationController(); ISettingsManager settingsManager = new SettingsManager(); // // Save old settings // IBluetoothSettings bluetooth = settingsManager.Bluetooth; bool wasBluetoothEnabled = bluetooth.IsEnabled; IGpsSettings gps = settingsManager.Gps; bool wasGpsEnabled = gps.IsEnabled; IMobileDataSettings mobileData = settingsManager.MobileData; bool wasMobileDataEnabled = mobileData.IsEnabled; IWifiSettings wifi = settingsManager.Wifi; bool wasWifiEnabled = wifi.IsEnabled; // // Set settings for Long Walk // bluetooth.IsEnabled = false; gps.IsEnabled = false; mobileData.IsEnabled = true; wifi.IsEnabled = false; // // Start applications for Long Walk // string musicAppName = "Dotify"; string trackerAppName = "Exomondo"; bool wasMusicRunning = applicationController.Start(musicAppName); applicationController.Start(trackerAppName); // // Long Walk..................... // Console.WriteLine($"{Environment.NewLine}Long Walk beginning... :-)"); Thread.Sleep(5000); Console.WriteLine($"Long Walk ended :-){Environment.NewLine}"); // // Shutdown applications // if (wasMusicRunning == false) { applicationController.Stop(musicAppName); } applicationController.Stop(trackerAppName); // // Revert settings back to old values before Long Walk // bluetooth.IsEnabled = wasBluetoothEnabled; gps.IsEnabled = wasGpsEnabled; mobileData.IsEnabled = wasMobileDataEnabled; wifi.IsEnabled = wasWifiEnabled; }