private void AppComboBox_DropDownClosed(object sender, EventArgs e) { if (AppComboBox.SelectedIndex.Equals(0)) { Properties.Settings.Default.AppThemeChange = 0; try { regEditHandler.SwitchThemeBasedOnTime(); } catch { } } if (AppComboBox.SelectedIndex.Equals(1)) { Properties.Settings.Default.AppThemeChange = 1; regEditHandler.SetAppTheme(1); } if (AppComboBox.SelectedIndex.Equals(2)) { Properties.Settings.Default.AppThemeChange = 2; regEditHandler.SetAppTheme(0); } }
//open wallpaper configuration private void BGWinButton_Click(object sender, RoutedEventArgs e) { DesktopBGui BGui = new DesktopBGui(); BGui.ShowDialog(); if (BGui.saved == true) { ButtonDisableTheme_Click(this, e); regEditHandler.SwitchThemeBasedOnTime(); } ShowDeskBGStatus(); }
private void ApplyButton_Click(object sender, RoutedEventArgs e) { int darkStart; int darkStartMinutes; int lightStart; int lightStartMinutes; //get values from TextBox try { darkStart = int.Parse(darkStartBox.Text); darkStartMinutes = int.Parse(DarkStartMinutesBox.Text); lightStart = int.Parse(lightStartBox.Text); lightStartMinutes = int.Parse(LightStartMinutesBox.Text); } catch { userFeedback.Text = Properties.Resources.errorNumberInput; return; } //check values from TextBox if (!Properties.Settings.Default.AlterTime) { if (darkStart >= 24) { darkStart = 23; darkStartMinutes = 59; } if (lightStart >= darkStart) { lightStart = darkStart - 3; } if (lightStart < 0) { lightStart = 6; darkStart = 17; } } else { if (darkStart >= 12) { darkStart = 11; darkStartMinutes = 59; } if (lightStart >= 13) { lightStart = 12; } } if (lightStartMinutes > 59) { lightStartMinutes = 59; } if (darkStartMinutes > 59) { darkStartMinutes = 59; } darkStartBox.Text = Convert.ToString(darkStart); lightStartBox.Text = Convert.ToString(lightStart); LightStartMinutesBox.Text = Convert.ToString(lightStartMinutes); DarkStartMinutesBox.Text = Convert.ToString(darkStartMinutes); try { if (Properties.Settings.Default.AlterTime) { darkStart += 12; } taskShedHandler.CreateTask(darkStart, darkStartMinutes, lightStart, lightStartMinutes); } catch (Exception ex) { userFeedback.Text = Properties.Resources.msgErrorOcc; string error = Properties.Resources.errorThemeApply + "\n\n Error ocurred in: taskShedHandler.CreateTask()" + "\n\n" + ex.Message; MsgBox msg = new MsgBox(error, Properties.Resources.errorOcurredTitle, "error", "yesno") { Owner = GetWindow(this) }; msg.ShowDialog(); var result = msg.DialogResult; if (result == true) { System.Diagnostics.Process.Start("https://github.com/Armin2208/Windows-Auto-Night-Mode/issues/44"); } return; } try { regEditHandler.SwitchThemeBasedOnTime(); } catch (Exception ex) { userFeedback.Text = Properties.Resources.msgErrorOcc; string error = Properties.Resources.errorThemeApply + "\n\n Error ocurred in: regEditHandler.SwitchThemeBasedOnTime()" + "\n\n" + ex.Message; MsgBox msg = new MsgBox(error, Properties.Resources.errorOcurredTitle, "error", "yesno") { Owner = GetWindow(this) }; msg.ShowDialog(); var result = msg.DialogResult; if (result == true) { System.Diagnostics.Process.Start("https://github.com/Armin2208/Windows-Auto-Night-Mode/issues/44"); } return; } try { regEditHandler.AddAutoStart(); } catch (Exception ex) { userFeedback.Text = Properties.Resources.msgErrorOcc; string error = Properties.Resources.errorThemeApply + "\n\n Error ocurred in: regEditHandler.AddAutoStart()" + "\n\n" + ex.Message; MsgBox msg = new MsgBox(error, Properties.Resources.errorOcurredTitle, "error", "yesno") { Owner = GetWindow(this) }; msg.ShowDialog(); var result = msg.DialogResult; if (result == true) { System.Diagnostics.Process.Start("https://github.com/Armin2208/Windows-Auto-Night-Mode/issues/44"); } return; } try { if (Properties.Settings.Default.BackgroundUpdate) { taskShedHandler.CreateAppUpdaterTask(); } } catch (Exception ex) { userFeedback.Text = Properties.Resources.msgErrorOcc; string error = Properties.Resources.errorThemeApply + "\n\n Error ocurred in: taskShedHandler.CreateAppUpdaterTask()" + "\n\n" + ex.Message; MsgBox msg = new MsgBox(error, Properties.Resources.errorOcurredTitle, "error", "yesno") { Owner = GetWindow(this) }; msg.ShowDialog(); var result = msg.DialogResult; if (result == true) { System.Diagnostics.Process.Start("https://github.com/Armin2208/Windows-Auto-Night-Mode/issues/44"); } return; } try { if (Properties.Settings.Default.connectedStandby) { taskShedHandler.CreateConnectedStandbyTask(); } } catch (Exception ex) { userFeedback.Text = Properties.Resources.msgErrorOcc; string error = Properties.Resources.errorThemeApply + "\n\n Error ocurred in: taskShedHandler.CreateConnectedStandbyTask()" + "\n\n" + ex.Message; MsgBox msg = new MsgBox(error, Properties.Resources.errorOcurredTitle, "error", "yesno") { Owner = GetWindow(this) }; msg.ShowDialog(); var result = msg.DialogResult; if (result == true) { System.Diagnostics.Process.Start("https://github.com/Armin2208/Windows-Auto-Night-Mode/issues/44"); } } applyButton.IsEnabled = false; if (PowerManager.EnergySaverStatus == EnergySaverStatus.On) { userFeedback.Text = Properties.Resources.msgChangesSaved + "\n\n" + Properties.Resources.msgBatterySaver; applyButton.IsEnabled = true; } else { userFeedback.Text = Properties.Resources.msgChangesSaved;//changes were saved! } }
private async void Application_Startup(object sender, StartupEventArgs e) { //handle command line arguments if (e.Args.Length > 0) { string[] args = Environment.GetCommandLineArgs(); foreach (var value in args) { if (value == "/switch") { RegeditHandler regEditHandler = new RegeditHandler(); regEditHandler.SwitchThemeBasedOnTime(); } else if (value == "/swap") { RegeditHandler regEditHandler = new RegeditHandler(); if (regEditHandler.AppsUseLightTheme()) { regEditHandler.ThemeToDark(); } else { regEditHandler.ThemeToLight(); } } else if (value == "/dark") { RegeditHandler regEditHandler = new RegeditHandler(); regEditHandler.ThemeToDark(); } else if (value == "/light") { RegeditHandler regEditHandler = new RegeditHandler(); regEditHandler.ThemeToLight(); } else if (value == "/update") { Updater updater = new Updater(); updater.CheckNewVersion(); } else if (value == "/location") { LocationHandler locationHandler = new LocationHandler(); await locationHandler.SetLocationSilent(); } else if (value == "/removeTask") { TaskShedHandler taskShedHandler = new TaskShedHandler(); taskShedHandler.RemoveTask(); } else if (value == "/removeAutostart") { RegeditHandler regEditHandler = new RegeditHandler(); regEditHandler.RemoveAutoStart(); } } Shutdown(); } else { MainWindow mainWin = new MainWindow(); mainWin.Show(); } }