private void RefreshControls() { highPerformanceToggle.CheckedChanged -= HighPerformanceToggle1_CheckedChanged; if (currentLastActivePowerPlan != NativeGUIDs.HIGH_PERFORMANCE_POWER_PLAN_GUID) { currentLastActivePowerPlan = PowerManager.GetActivePlan(); } highPerformanceToggle.Checked = PowerManager.GetActivePlan() == NativeGUIDs.HIGH_PERFORMANCE_POWER_PLAN_GUID; highPerformanceToggle.CheckedChanged += HighPerformanceToggle1_CheckedChanged; disableGameBarMetroToggle.CheckedChanged -= DisableGameBarMetroToggle_CheckedChanged; disableGameBarMetroToggle.Checked = !GameBar.IsEnabled(false); disableGameBarMetroToggle.CheckedChanged += DisableGameBarMetroToggle_CheckedChanged; disableFullScreenOptimizationsMetroToggle.CheckedChanged -= DisableFullScreenOptimizationsMetroToggle_CheckedChanged; disableFullScreenOptimizationsMetroToggle.Checked = !LeagueGameCompabilityFlagLayers.Instance.GetFullScreenOptimizationsFlag(false); disableFullScreenOptimizationsMetroToggle.CheckedChanged += DisableFullScreenOptimizationsMetroToggle_CheckedChanged; notificationsToggle.CheckedChanged -= NotificationsToggle_CheckedChanged; notificationsToggle.Checked = notification; Program.PlayNotiAllow = notification; Properties.Settings.Default.Notifications = notification; notificationsToggle.CheckedChanged += NotificationsToggle_CheckedChanged; ReadGameConfigData(false); }
private void DisableGameBarMetroToggle_CheckedChanged(object sender, EventArgs e) { logger.Debug("Disable Game Bar toggle has been checked: " + disableGameBarMetroToggle.Checked); ShowRegistryAgreement(); if (Settings.Default.RegistryAgreement) { try { if (!GameBar.Set(!disableGameBarMetroToggle.Checked, true)) { Program.PlayNoti(false); } } catch (Exception ex) { logger.Error(ex, Strings.exceptionThrown + " while setting game bar to: " + !disableGameBarMetroToggle.Checked); } } disableGameBarMetroToggle.CheckedChanged -= DisableGameBarMetroToggle_CheckedChanged; disableGameBarMetroToggle.Checked = !GameBar.IsEnabled(true); disableGameBarMetroToggle.CheckedChanged += DisableGameBarMetroToggle_CheckedChanged; }
private void MainWindow_Load(object sender, EventArgs e) { //Debug text update if (Program.DebugBuild) { Text = "LeagueFPSBoost β"; metroLabel9.Text += Environment.NewLine + "THIS IS BETA BUILD!"; aboutTXTDebug = metroLabel9.Text; } Program.DebuggerWatcher.DebuggerChanged += DebuggerChangedGUI; Program.DebuggerWatcher.DebuggerChecked += DebuggerChangedGUI; Program.DebuggerWatcher.CheckNow(); //Theme metroStyleManager1.Theme = Settings.Default.ThemeStyle; metroStyleManager1.Style = Settings.Default.ColorStyle; if (metroStyleManager1.Theme == MetroThemeStyle.Dark) { darkThemeToggle.Checked = true; } else { darkThemeToggle.Checked = false; } logger.Debug("Loaded style settings."); LeagueLogger.Okay("Loaded style settings."); //High PPP try { logger.Debug("Reading current active power plan."); currentLastActivePowerPlan = PowerManager.GetActivePlan(); logger.Debug($"Current active power plan: {currentLastActivePowerPlan} - {PowerManager.GetPlanName(currentLastActivePowerPlan)}"); highPerformanceToggle.CheckedChanged -= HighPerformanceToggle1_CheckedChanged; highPerformanceToggle.Checked = currentLastActivePowerPlan == NativeGUIDs.HIGH_PERFORMANCE_POWER_PLAN_GUID; highPerformanceToggle.CheckedChanged += HighPerformanceToggle1_CheckedChanged; logger.Debug("Loaded current active power plan."); } catch (Exception ex) { logger.Error(ex, Strings.exceptionThrown + " while reading active power plan: " + Environment.NewLine); } if (currentLastActivePowerPlan != Settings.Default.LastActivePowerPlan) { logger.Warn("Current active power plan and last active power plan don't match. Maybe program has closed incorrectly or plan was changed outside of program."); try { logger.Info("Trying to change power plan."); logger.Info($"Changing current power plan to last saved active power plan: {Settings.Default.LastActivePowerPlan} - {PowerManager.GetPlanName(Settings.Default.LastActivePowerPlan)}"); PowerManager.SetActivePlan(Settings.Default.LastActivePowerPlan); currentLastActivePowerPlan = PowerManager.GetActivePlan(); logger.Debug($"Power plan set to: {currentLastActivePowerPlan} - {PowerManager.GetPlanName(currentLastActivePowerPlan)}"); } catch (Exception ex) { logger.Error(ex, Strings.exceptionThrown + " while trying to change power plan to last active one: " + Environment.NewLine); } } SaveLastActivePowerPlan(currentLastActivePowerPlan); //Notification notificationsToggle.CheckedChanged -= NotificationsToggle_CheckedChanged; notification = Properties.Settings.Default.Notifications; notificationsToggle.Checked = notification; Program.PlayNotiAllow = notification; logger.Debug("Loaded notification settings."); LeagueLogger.Okay("Loaded notification settings."); notificationsToggle.CheckedChanged -= NotificationsToggle_CheckedChanged; disableGameBarMetroToggle.CheckedChanged -= DisableGameBarMetroToggle_CheckedChanged; disableFullScreenOptimizationsMetroToggle.CheckedChanged -= DisableFullScreenOptimizationsMetroToggle_CheckedChanged; if (Environment.OSVersion.Version.Major != 10) { logger.Debug("OS major version is not 10. Disabling game bar and fullscropt toggle."); disableGameBarMetroToggle.Enabled = false; metroLabel8.Enabled = false; disableFullScreenOptimizationsMetroToggle.Enabled = false; metroLabel7.Enabled = false; } disableGameBarMetroToggle.Checked = !GameBar.IsEnabled(); disableFullScreenOptimizationsMetroToggle.Checked = !LeagueGameCompabilityFlagLayers.Instance.GetFullScreenOptimizationsFlag(); disableGameBarMetroToggle.CheckedChanged += DisableGameBarMetroToggle_CheckedChanged; disableFullScreenOptimizationsMetroToggle.CheckedChanged += DisableFullScreenOptimizationsMetroToggle_CheckedChanged; metroToggleProcessPriority.CheckedChanged -= MetroToggleProcessPriority_CheckedChanged; metroToggleProcessPriority.Enabled = metroLabelManageProcPriority.Enabled = metroToggleProcessPriority.Checked = false; //Watcher Task.Factory.StartNew(() => { logger.Debug("Starting process watcher for first time."); var wmierror = !LeaguePriority.InitAndStartWatcher(); if (wmierror) { metroToggleProcessPriority.Enabled = metroLabelManageProcPriority.Enabled = metroToggleProcessPriority.Checked = false; return; } metroToggleProcessPriority.Checked = LeaguePriority.ProcessWatcherEnabled; logger.Debug("Checking the saved state of process watcher enabled setting."); if (!Settings.Default.ProcessWatcherEnable) { try { logger.Debug("Trying to disable process watcher because its disabled in settings."); LeaguePriority.StopProcessWatcher(); metroToggleProcessPriority.Checked = LeaguePriority.ProcessWatcherEnabled; logger.Debug("Disabling process watcher completed successfully."); } catch (Exception ex) { logger.Error(ex, Strings.exceptionThrown + " while trying to stop process watcher: " + Environment.NewLine); metroToggleProcessPriority.Checked = false; } } else { try { logger.Debug("Trying to enable process watcher because its enabled in settings."); LeaguePriority.StartProcessWatcher(); metroToggleProcessPriority.Checked = LeaguePriority.ProcessWatcherEnabled; logger.Debug("Enabling process watcher completed successfully."); } catch (Exception ex) { logger.Error(ex, Strings.exceptionThrown + " while trying to stop process watcher: " + Environment.NewLine); try { LeaguePriority.StopProcessWatcher(); } catch { } metroToggleProcessPriority.Checked = false; } } metroToggleProcessPriority.Enabled = metroLabelManageProcPriority.Enabled = true; metroToggleProcessPriority.CheckedChanged += MetroToggleProcessPriority_CheckedChanged; }); //Ini-Praser ReadGameConfigData(); Loaded = true; logger.Debug("Main window has been loaded."); LeagueLogger.Okay("Main window loaded."); Program.MainWindowLoaded = true; if (Program.FirstRun.Value) { UpdaterActionsSettings.Default.Reset(); UpdaterActionsSettings.Default.Save(); UpdaterMessageBoxSettings.Default.Reset(); UpdaterMessageBoxSettings.Default.Save(); logger.Debug("Reseted updater actions and message box settings to their default values."); Task.Run(new Action(FirstRunDonationMessageBox)); } UpdateManager.InitAndCheckForUpdates(); BringFormToFront(); }