Beispiel #1
0
        public static void Load()
        {
            try
            {
                //engine
                Constants.ENGINE_ENABLED  = Convert.ToBoolean(SettingsDAC.Get("ENGINE_ENABLED"));
                Constants.ENGINE_INTERVAL = Convert.ToInt32(SettingsDAC.Get("ENGINE_INTERVAL"));
                Constants.APP_USAGE_COUNT = Convert.ToInt32(SettingsDAC.Get("APP_USAGE_COUNT"));
                SettingsDAC.Set("APP_USAGE_COUNT", (Constants.APP_USAGE_COUNT + 1).ToString());

                //weather
                Constants.WEATHER_READ_INTERVAL       = Convert.ToInt32(SettingsDAC.Get("WEATHER_READ_INTERVAL"));
                Constants.TEMPERATURE_ALERT_THRESHOLD = Convert.ToDouble(SettingsDAC.Get("TEMPERATURE_ALERT_THRESHOLD"));

                //location
                Constants.VISITED_DISTANCE_THRESHOLD   = Convert.ToDouble(SettingsDAC.Get("VISITED_DISTANCE_THRESHOLD"));
                Constants.LEFT_FROM_DURATION_THRESHOLD = Convert.ToInt32(SettingsDAC.Get("LEFT_FROM_DURATION_THRESHOLD"));
                Constants.CAR_SERVICE_INTERVAL         = Convert.ToInt32(SettingsDAC.Get("CAR_SERVICE_INTERVAL"));
                Constants.MAX_GYM_VACATION             = Convert.ToInt32(SettingsDAC.Get("MAX_GYM_VACATION"));

                //network
                Constants.NEWS_EMAIL         = SettingsDAC.Get("NEWS_EMAIL");
                Constants.NEWS_READ_INTERVAL = Convert.ToInt32(SettingsDAC.Get("NEWS_READ_INTERVAL"));
                Constants.NEWS_PROVIDERS     = SettingsDAC.Get("NEWS_PROVIDERS");
                Constants.NEWS_TOPICS        = SettingsDAC.Get("NEWS_TOPICS");
                Constants.NEWS_PEOPLE        = SettingsDAC.Get("NEWS_PEOPLE");

                //social
                Constants.GTALK_ENABLED                = Convert.ToBoolean(SettingsDAC.Get("GTALK_ENABLED"));
                Constants.GTALK_USERNAME               = SettingsDAC.Get("GTALK_USERNAME");
                Constants.GTALK_PWD                    = SettingsDAC.Get("GTALK_PWD");
                Constants.SKYPE_ENABLED                = Convert.ToBoolean(SettingsDAC.Get("SKYPE_ENABLED"));
                Constants.MEETING_AUTOREPLY_MESSAGE    = SettingsDAC.Get("MEETING_AUTOREPLY_MESSAGE");
                Constants.BATTERYLOW_AUTOREPLY_MESSAGE = SettingsDAC.Get("BATTERYLOW_AUTOREPLY_MESSAGE");
                Constants.BATTERY_WARNING_THRESHOLD    = Convert.ToInt32(SettingsDAC.Get("BATTERY_WARNING_THRESHOLD"));

                //lifestyle
                Constants.MEETING_ALERT_HOUR         = SettingsDAC.Get("MEETING_ALERT_HOUR");
                Constants.TIMESHEET_ALERT_HOUR       = SettingsDAC.Get("TIMESHEET_ALERT_HOUR");
                Constants.WEEKLY_SUMMARY_ALERT_DAY   = SettingsDAC.Get("WEEKLY_SUMMARY_ALERT_DAY");
                Constants.WEEKLY_SUMMARY_ALERT_HOUR  = SettingsDAC.Get("WEEKLY_SUMMARY_ALERT_HOUR");
                Constants.APP_TO_LAUNCH_ON_SHAKE     = SettingsDAC.Get("APP_TO_LAUNCH_ON_SHAKE");
                Constants.APP_TO_LAUNCH_ON_LANDSCAPE = SettingsDAC.Get("APP_TO_LAUNCH_ON_LANDSCAPE");
                Constants.DROPBOX_DOCUMENTS          = SettingsDAC.Get("DROPBOX_DOCUMENTS");

                //load known-locations
                KnownLocations.Load();
                LocationHelper.LoadHistory();
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }
        }
Beispiel #2
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SaveButton.IsEnabled = false;

                //engine
                Constants.ENGINE_INTERVAL = (int)EngineIntervalUpDown.Value;

                //weather
                Constants.WEATHER_READ_INTERVAL       = (int)WeatherReadIntervalUpDown.Value;
                Constants.TEMPERATURE_ALERT_THRESHOLD = (double)TemperatureAlertThresholdUpDown.Value;

                //location
                Constants.VISITED_DISTANCE_THRESHOLD   = (double)VisitedDistanceThresholdUpDown.Value;
                Constants.LEFT_FROM_DURATION_THRESHOLD = (int)LeftFromDurationUpDown.Value;
                Constants.CAR_SERVICE_INTERVAL         = (int)CarServiceIntervalUpDown.Value;
                Constants.MAX_GYM_VACATION             = (int)MaxGymVacationUpDown.Value;

                //network
                Constants.NEWS_EMAIL         = NewsEmailTextBox.Text;
                Constants.NEWS_READ_INTERVAL = (int)NewsReadIntervalUpDown.Value;
                Constants.NEWS_TOPICS        = NewsTopicsTextBox.Text;
                Constants.NEWS_PEOPLE        = NewsPeopleTextBox.Text;

                List <string> providers = new List <string>();
                if ((bool)MSTopCheckBox.IsChecked)
                {
                    providers.Add(Constants.MS_TOP);
                }
                if ((bool)GoogleTechCheckBox.IsChecked)
                {
                    providers.Add(Constants.GOOGLE_TECH);
                }
                if ((bool)YahooTechCheckBox.IsChecked)
                {
                    providers.Add(Constants.YAHOO_TECH);
                }
                if ((bool)BbcTechCheckBox.IsChecked)
                {
                    providers.Add(Constants.BBC_TECH);
                }
                Constants.NEWS_PROVIDERS = string.Join(";", providers);

                //social
                Constants.GTALK_ENABLED                = (bool)GTalkCheckBox.IsChecked;
                Constants.GTALK_USERNAME               = GTalkEmailTextBox.Text;
                Constants.GTALK_PWD                    = new SimpleAES().EncryptToString(GTalkPwdTextBox.Password);
                Constants.SKYPE_ENABLED                = (bool)SkypeCheckBox.IsChecked;
                Constants.MEETING_AUTOREPLY_MESSAGE    = MeetingAutoReplyTextBox.Text;
                Constants.BATTERYLOW_AUTOREPLY_MESSAGE = BatteryLowAutoReplyTextBox.Text;
                Constants.BATTERY_WARNING_THRESHOLD    = (int)BatteryWarningThresholdUpDown.Value;

                //lifestyle
                Constants.MEETING_ALERT_HOUR         = MeetingAlertHourComboBox.SelectedItem.ToString();
                Constants.TIMESHEET_ALERT_HOUR       = TimeSheetAlertHourComboBox.SelectedItem.ToString();
                Constants.WEEKLY_SUMMARY_ALERT_DAY   = WeeklySummaryDayOfWeekComboBox.SelectedItem.ToString();
                Constants.WEEKLY_SUMMARY_ALERT_HOUR  = WeeklySummaryAlertHourComboBox.SelectedItem.ToString();
                Constants.APP_TO_LAUNCH_ON_SHAKE     = LaunchOnShakeComboBox.SelectedItem.ToString();
                Constants.APP_TO_LAUNCH_ON_LANDSCAPE = LaunchOnLandscapeComboBox.SelectedItem.ToString();

                List <string> docTypes = new List <string>();
                if ((bool)WordCheckBox.IsChecked)
                {
                    docTypes.Add(Constants.WORD);
                }
                if ((bool)ExcelCheckBox.IsChecked)
                {
                    docTypes.Add(Constants.EXCEL);
                }
                if ((bool)PowerPointCheckBox.IsChecked)
                {
                    docTypes.Add(Constants.POWERPOINT);
                }
                Constants.DROPBOX_DOCUMENTS = string.Join(";", docTypes);

                bool restartSuccessful = false;
                Task.Run(() =>
                {
                    //engine
                    SettingsDAC.Set("ENGINE_ENABLED", Constants.ENGINE_ENABLED.ToString());
                    SettingsDAC.Set("ENGINE_INTERVAL", Constants.ENGINE_INTERVAL.ToString());

                    //weather
                    SettingsDAC.Set("WEATHER_READ_INTERVAL", Constants.WEATHER_READ_INTERVAL.ToString());
                    SettingsDAC.Set("TEMPERATURE_ALERT_THRESHOLD", Constants.TEMPERATURE_ALERT_THRESHOLD.ToString());

                    //location
                    SettingsDAC.Set("VISITED_DISTANCE_THRESHOLD", Constants.VISITED_DISTANCE_THRESHOLD.ToString());
                    SettingsDAC.Set("LEFT_FROM_DURATION_THRESHOLD", Constants.LEFT_FROM_DURATION_THRESHOLD.ToString());
                    SettingsDAC.Set("CAR_SERVICE_INTERVAL", Constants.CAR_SERVICE_INTERVAL.ToString());
                    SettingsDAC.Set("MAX_GYM_VACATION", Constants.MAX_GYM_VACATION.ToString());

                    //network
                    SettingsDAC.Set("NEWS_EMAIL", Constants.NEWS_EMAIL);
                    SettingsDAC.Set("NEWS_READ_INTERVAL", Constants.NEWS_READ_INTERVAL.ToString());
                    SettingsDAC.Set("NEWS_TOPICS", Constants.NEWS_TOPICS);
                    SettingsDAC.Set("NEWS_PEOPLE", Constants.NEWS_PEOPLE);
                    SettingsDAC.Set("NEWS_PROVIDERS", Constants.NEWS_PROVIDERS);

                    //social
                    SettingsDAC.Set("GTALK_ENABLED", Constants.GTALK_ENABLED.ToString());
                    SettingsDAC.Set("GTALK_USERNAME", Constants.GTALK_USERNAME);
                    SettingsDAC.Set("GTALK_PWD", Constants.GTALK_PWD);
                    SettingsDAC.Set("SKYPE_ENABLED", Constants.SKYPE_ENABLED.ToString());
                    SettingsDAC.Set("MEETING_AUTOREPLY_MESSAGE", Constants.MEETING_AUTOREPLY_MESSAGE);
                    SettingsDAC.Set("BATTERYLOW_AUTOREPLY_MESSAGE", Constants.BATTERYLOW_AUTOREPLY_MESSAGE);
                    SettingsDAC.Set("BATTERY_WARNING_THRESHOLD", Constants.BATTERY_WARNING_THRESHOLD.ToString());

                    //lifestyle
                    SettingsDAC.Set("MEETING_ALERT_HOUR", Constants.MEETING_ALERT_HOUR);
                    SettingsDAC.Set("TIMESHEET_ALERT_HOUR", Constants.TIMESHEET_ALERT_HOUR);
                    SettingsDAC.Set("WEEKLY_SUMMARY_ALERT_DAY", Constants.WEEKLY_SUMMARY_ALERT_DAY);
                    SettingsDAC.Set("WEEKLY_SUMMARY_ALERT_HOUR", Constants.WEEKLY_SUMMARY_ALERT_HOUR);
                    SettingsDAC.Set("APP_TO_LAUNCH_ON_SHAKE", Constants.APP_TO_LAUNCH_ON_SHAKE);
                    SettingsDAC.Set("APP_TO_LAUNCH_ON_LANDSCAPE", Constants.APP_TO_LAUNCH_ON_LANDSCAPE);
                    SettingsDAC.Set("DROPBOX_DOCUMENTS", Constants.DROPBOX_DOCUMENTS);

                    //save locations
                    KnownLocations.Save();

                    //restart engine
                    //Engine.Instance.Stop();
                    //await Engine.Instance.Start();
                    restartSuccessful = true;
                    //Log.Write("Engine Restarted");
                });
                Log.Write("Settings Saved Successfully");

                string statusMessage = string.Empty;
                if (restartSuccessful)
                {
                    statusMessage += "Settings saved successfully!";
                }
                else
                {
                    statusMessage = "Settings saved, but unable to restart the Engine. You have to do it manually, in order for new settings to take effect.";
                }
                MessageBox.Show(statusMessage, Constants.APP_ID, MessageBoxButton.OK, MessageBoxImage.Information);

                Engine.Instance.Stop();
                Engine.Instance.Start();
                SaveButton.IsEnabled = true;
            }
            catch (Exception exception)
            {
                Log.Error(exception);
                MessageBox.Show("Error: " + exception.Message, Constants.APP_ID, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }