public static void ResetAllProfiles(MainWindow configurator, string selectedProfiles) { //create a background worker var backgroundReset = new BackgroundWorker(); backgroundReset.DoWork += (s, ea) => Thread.Sleep(TimeSpan.FromSeconds(0)); //define work to be done backgroundReset.RunWorkerCompleted += (s, ea) => { if (selectedProfiles.Contains("Clock")) { DefaultClockConfig(); } if (selectedProfiles.Contains("1")) { DefaultProfile1Config(); } if (selectedProfiles.Contains("2")) { DefaultProfile2Config(); } if (selectedProfiles.Contains("3")) { DefaultProfile3Config(); } if (selectedProfiles.Contains("All")) { DefaultClockConfig(); DefaultProfile1Config(); DefaultProfile2Config(); DefaultProfile3Config(); DefaultDeviceStateConfig(); DeviceChoice deviceChoice = new DeviceChoice(); deviceChoice.Show(); configurator.Close(); } //reload saved values configurator.ReloadExt(); SettingsConfigurator.RestartSDM(); }; //start the background worker backgroundReset.RunWorkerAsync(); }
//profile switcher private void Profiles_DropDownClosed(object sender, EventArgs e) { //save selected profile to config currentProfile = Profiles.Text; string selectedProfile = "selectedProfile" + " " + currentProfile; List <string> configValueList = new List <string> { selectedProfile }; ThreadManager.DoSaveInBackground(configValueList, "mainconfig", this); //display settings based on profile selected PrepValueDisplay(currentProfile); //display notification Brush selectedColor = Brushes.DarkCyan; string statusText = "Loaded " + currentProfile; ThreadManager.DoStatusInBackground(selectedColor, statusText, "", this); SettingsConfigurator.RestartSDM(); }
private void ButtonSave_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { //disable button while saving values ButtonSave.IsEnabled = false; //set lists depending on device List <string> configValueList; //grab values used by both standard and mini configs string formattedValue = new string(BrightnessPercent.Content.ToString().Where(char.IsDigit).ToArray()); string displayBrightness = "displayBrightness" + " " + formattedValue; string headerFontSize1 = "headerFontSize_1" + " " + HeaderFontSize1.Text; string headerFontSize2 = "headerFontSize_2" + " " + HeaderFontSize2.Text; string valuesFontSize = "valuesFontSize" + " " + ValuesFontSize.Text; string headerFontType1 = "headerFontType_1" + " " + HeaderFontType1.SelectedValue.ToString(); string headerFontType2 = "headerFontType_2" + " " + HeaderFontType2.SelectedValue.ToString(); string valuesFontType = "valuesFontType" + " " + ValuesFontType.SelectedValue.ToString(); string headerfontColor1 = "headerfontColor_1" + " " + HeaderFontColor1.SelectedValue.ToString(); string headerfontColor2 = "headerfontColor_2" + " " + HeaderFontColor2.SelectedValue.ToString(); string valuesFontColor = "valuesFontColor" + " " + ValuesFontColor.SelectedValue.ToString(); string backgroundColor = "backgroundColor" + " " + BackgroundFillColor.SelectedValue.ToString(); string valuesFontPosition = "valuesFontPosition" + " " + ValuePosition.Text; string headerfont1Position = "headerFontPosition_1" + " " + Header1Position.Text; string headerfont2Position = "headerFontPosition_2" + " " + Header2Position.Text; //grab values used for mini config if (IsMiniFps.Visibility == Visibility.Visible) { string isFpsShown; if (IsMiniFps.IsChecked == true) { isFpsShown = "showFpsCounter" + " " + "True"; } else { isFpsShown = "showFpsCounter" + " " + "False"; } //store all mini values to pass to DoSaveInBackground() List <string> configMiniValueList = new List <string> { isFpsShown }; //send list to be processed in background threads ThreadManager.DoSaveInBackground(configMiniValueList, "miniconfig", this); //store all values to pass to DoSaveInBackground() configValueList = new List <string> { displayBrightness, headerFontSize1, headerFontSize2, valuesFontSize, headerFontType1, headerFontType2, valuesFontType, headerfontColor1, headerfontColor2, valuesFontColor, valuesFontPosition, headerfont1Position, headerfont2Position, backgroundColor, }; } else { //grab values used for standard config string animationFramerate = "animationFramerate" + " " + AnimFramerate.Text; string framesToProcess = "framesToProcess" + " " + FrameTotal.Text; string animationEnabled; if (EnableAnim.IsChecked == true) { animationEnabled = "animationEnabled" + " " + "True"; } else { animationEnabled = "animationEnabled" + " " + "False"; } string imageName = "imageName" + " " + StaticImages.SelectedValue.ToString(); string animName = "animName" + " " + Animations.SelectedValue.ToString(); //store all values to pass to DoSaveInBackground() configValueList = new List <string> { displayBrightness, headerFontSize1, headerFontSize2, valuesFontSize, animationFramerate, framesToProcess, animationEnabled, imageName, animName, headerFontType1, headerFontType2, valuesFontType, headerfontColor1, headerfontColor2, valuesFontColor, valuesFontPosition, headerfont1Position, headerfont2Position, backgroundColor, }; } //clock settings string timeFont = "timeFontType" + " " + TimeFontType.SelectedValue.ToString(); string colonFont = "colonFontType" + " " + ColonFontType.SelectedValue.ToString(); string dateFont = "dateFontType" + " " + DateFontType.SelectedValue.ToString(); string timeFontSize = "timeFontSize" + " " + TimeFontSize.Text; string colonFontSize = "colonFontSize" + " " + ColonFontSize.Text; string dateFontSize = "dateFontSize" + " " + DateFontSize.Text; string timeFontColor = "timeFontColor" + " " + TimeFontColor.SelectedValue.ToString(); string colonFontColor = "colonFontColor" + " " + ColonFontColor.SelectedValue.ToString(); string dateFontColor = "dateFontColor" + " " + DateFontColor.SelectedValue.ToString(); string timePosition = "timeFontPosition" + " " + TimePosition.Text; string colonPosition = "colonFontPosition" + " " + ColonPosition.Text; string datePosition = "dateFontPosition" + " " + DatePosition.Text; string isCompact; string isDateShown; if (IsCompact.IsChecked == true) { isCompact = "compactView" + " " + "True"; } else { isCompact = "compactView" + " " + "False"; } if (IsDateShown.IsChecked == true) { isDateShown = "showDate" + " " + "True"; } else { isDateShown = "showDate" + " " + "False"; } //store all clock values to pass to DoSaveInBackground() List <string> clockValueList = new List <string> { timeFont, colonFont, dateFont, timeFontSize, colonFontSize, dateFontSize, timeFontColor, colonFontColor, dateFontColor, timePosition, colonPosition, datePosition, isCompact, isDateShown }; //send lists to be processed in background threads ThreadManager.DoSaveInBackground(configValueList, "mainconfig", this); ThreadManager.DoSaveInBackground(clockValueList, "clockconfig", this); //display notification Brush selectedColor = Brushes.Green; string statusText = "Settings Saved"; ThreadManager.DoStatusInBackground(selectedColor, statusText, "Save", this); SettingsConfigurator.RestartSDM(); }
private void PrepValueDisplay(string currentProfile) { SettingsConfigurator.LoadValues(currentProfile); DisplayValues(currentProfile); }