Example #1
0
 public SettingsManager()
 {
     _bluetooth  = new BluetoothSettings();
     _gps        = new GpsSettings();
     _mobileData = new MobileDataSettings();
     _wifi       = new WifiSettings();
 }
Example #2
0
        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;
            }
        }
Example #3
0
        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;
        }
Example #4
0
        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
            };
        }
Example #5
0
        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;
        }