diff --git a/HandheldCompanion/Managers/PerformanceManager.cs b/HandheldCompanion/Managers/PerformanceManager.cs index f5480eb99..1c2608213 100644 --- a/HandheldCompanion/Managers/PerformanceManager.cs +++ b/HandheldCompanion/Managers/PerformanceManager.cs @@ -2,15 +2,12 @@ using HandheldCompanion.Processors; using HandheldCompanion.Utils; using HandheldCompanion.Views; -using HandheldCompanion.Views.Pages; -using Microsoft.Win32; using RTSSSharedMemoryNET; using System; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Timers; -using System.Windows.Forms; using Timer = System.Timers.Timer; namespace HandheldCompanion.Managers; @@ -102,9 +99,6 @@ public PerformanceManager() autoWatchdog = new Timer { Interval = INTERVAL_AUTO, AutoReset = true, Enabled = false }; autoWatchdog.Elapsed += AutoTDPWatchdog_Elapsed; - // Monitor Power Status - SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; - ProfileManager.Applied += ProfileManager_Applied; ProfileManager.Discarded += ProfileManager_Discarded; @@ -121,11 +115,6 @@ public PerformanceManager() MaxDegreeOfParallelism = Convert.ToInt32(Environment.ProcessorCount / 2); } - private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) - { - ProfilesPage.RequestUpdate(); - } - private void SettingsManagerOnSettingValueChanged(string name, object value) { switch (name) @@ -151,16 +140,10 @@ private void ProfileManager_Applied(Profile profile, ProfileUpdateSource source) // apply profile defined TDP if (profile.TDPOverrideEnabled && profile.TDPOverrideValues is not null) { - double[] TDPOverrideValues; - // Check if using TDP on Battery & is not Plugged in - bool PluggedInStatus = SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online; - if (profile.TDPOnBatteryEnabled && profile.TDPOnBatteryValues is not null && !PluggedInStatus) TDPOverrideValues = profile.TDPOnBatteryValues; - else TDPOverrideValues = profile.TDPOverrideValues; - if (!profile.AutoTDPEnabled) { // Manual TDP is set, use it and set max limit - RequestTDP(TDPOverrideValues); + RequestTDP(profile.TDPOverrideValues); StartTDPWatchdog(); AutoTDPMax = SettingsManager.GetInt("ConfigurableTDPOverrideUp"); } @@ -168,7 +151,7 @@ private void ProfileManager_Applied(Profile profile, ProfileUpdateSource source) { // Both manual TDP and AutoTDP are on, // use manual slider as the max limit for AutoTDP - AutoTDPMax = TDPOverrideValues[0]; + AutoTDPMax = profile.TDPOverrideValues[0]; StopTDPWatchdog(true); } } diff --git a/HandheldCompanion/Misc/Profile.cs b/HandheldCompanion/Misc/Profile.cs index fa37addc6..9fcd34dad 100644 --- a/HandheldCompanion/Misc/Profile.cs +++ b/HandheldCompanion/Misc/Profile.cs @@ -123,8 +123,6 @@ public Profile(string path) : this() // power public bool TDPOverrideEnabled { get; set; } public double[] TDPOverrideValues { get; set; } - public bool TDPOnBatteryEnabled { get; set; } - public double[] TDPOnBatteryValues { get; set; } public bool GPUOverrideEnabled { get; set; } public double GPUOverrideValue { get; set; } diff --git a/HandheldCompanion/Properties/Resources.Designer.cs b/HandheldCompanion/Properties/Resources.Designer.cs index baaf7f709..9bcd89f4c 100644 --- a/HandheldCompanion/Properties/Resources.Designer.cs +++ b/HandheldCompanion/Properties/Resources.Designer.cs @@ -4986,24 +4986,6 @@ public static string ProfilesPage_SustainedPowerDesc { } } - /// - /// Looks up a localized string similar to TDP settings On Battery. - /// - public static string ProfilesPage_TDPOnBattery { - get { - return ResourceManager.GetString("ProfilesPage_TDPOnBattery", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using seperated TDP settings when On Battery. - /// - public static string ProfilesPage_TDPOnBatteryDesc { - get { - return ResourceManager.GetString("ProfilesPage_TDPOnBatteryDesc", resourceCulture); - } - } - /// /// Looks up a localized string similar to Thermal Power (TDP) limit. /// diff --git a/HandheldCompanion/Properties/Resources.resx b/HandheldCompanion/Properties/Resources.resx index f87ba6584..647981f7e 100644 --- a/HandheldCompanion/Properties/Resources.resx +++ b/HandheldCompanion/Properties/Resources.resx @@ -2357,10 +2357,4 @@ with motion input enabled, use selected button(s) to disable motion. Make this the default layout - - TDP settings On Battery - - - Using seperated TDP settings when On Battery - \ No newline at end of file diff --git a/HandheldCompanion/Views/Pages/ProfilesPage.xaml b/HandheldCompanion/Views/Pages/ProfilesPage.xaml index 5d356660f..f3b3e67f6 100644 --- a/HandheldCompanion/Views/Pages/ProfilesPage.xaml +++ b/HandheldCompanion/Views/Pages/ProfilesPage.xaml @@ -657,68 +657,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - e) - { - if (!TDPOnBatterySlider.IsInitialized) - return; - - // wait until lock is released - if (updateLock) - return; - - selectedProfile.TDPOnBatteryValues = new double[3] - { - (int)TDPOnBatterySlider.Value, - (int)TDPOnBatterySlider.Value, - (int)TDPOnBatterySlider.Value - }; - RequestUpdate(); - } - private void FramerateToggle_Toggled(object sender, RoutedEventArgs e) { // UI thread (async) diff --git a/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml b/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml index 946d768bd..a412bb363 100644 --- a/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml +++ b/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml @@ -231,68 +231,9 @@ TickPlacement="BottomRight" ValueChanged="TDPSlider_ValueChanged" /> - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs b/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs index 7a1410c17..cb02f5b9d 100644 --- a/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs +++ b/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs @@ -11,8 +11,6 @@ using System.Timers; using System.Windows; using System.Windows.Controls; -using Microsoft.Win32; - using Page = System.Windows.Controls.Page; namespace HandheldCompanion.Views.QuickPages; @@ -262,7 +260,6 @@ public void SubmitProfile(ProfileUpdateSource source = ProfileUpdateSource.Quick private void HotkeysManager_CommandExecuted(string listener) { // UI thread (async) - bool PluggedInStatus = System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == System.Windows.Forms.PowerLineStatus.Online; Application.Current.Dispatcher.BeginInvoke(() => { switch (listener) @@ -271,16 +268,16 @@ private void HotkeysManager_CommandExecuted(string listener) { if (currentProfile is null || !currentProfile.TDPOverrideEnabled) return; - if(!PluggedInStatus && currentProfile.TDPOnBatteryEnabled) TDPOnBatterySlider.Value++; - else TDPSlider.Value++; + + TDPSlider.Value++; } break; case "decreaseTDP": { if (currentProfile is null || !currentProfile.TDPOverrideEnabled) return; - if (!PluggedInStatus && currentProfile.TDPOnBatteryEnabled) TDPOnBatterySlider.Value--; - else TDPSlider.Value--; + + TDPSlider.Value--; } break; } @@ -299,7 +296,6 @@ public void SettingsManager_SettingValueChanged(string name, object value) using (new ScopedLock(updateLock)) { TDPSlider.Minimum = (double)value; - TDPOnBatterySlider.Minimum = (double)value; } } break; @@ -308,7 +304,6 @@ public void SettingsManager_SettingValueChanged(string name, object value) using (new ScopedLock(updateLock)) { TDPSlider.Maximum = (double)value; - TDPOnBatterySlider.Maximum = (double)value; } } break; @@ -391,13 +386,6 @@ private void ProfileApplied(Profile profile, ProfileUpdateSource source) : MainWindow.CurrentDevice.nTDP; TDPSlider.Value = TDP[(int)PowerType.Slow]; - // TDP On Battery - TDPOnBatteryToggle.IsOn = currentProfile.TDPOnBatteryEnabled; - var TDPOnBattery = currentProfile.TDPOnBatteryValues is not null - ? currentProfile.TDPOnBatteryValues - : MainWindow.CurrentDevice.nTDP; - TDPOnBatterySlider.Value = TDPOnBattery[(int)PowerType.Slow]; - // GPU GPUToggle.IsOn = currentProfile.GPUOverrideEnabled; GPUSlider.Value = currentProfile.GPUOverrideValue != 0 ? currentProfile.GPUOverrideValue : 255 * 50; @@ -499,7 +487,6 @@ private void CreateProfile() currentProfile.Layout = (ProfileManager.GetProfileWithDefaultLayout()?.Layout ?? LayoutTemplate.DefaultLayout.Layout).Clone() as Layout; currentProfile.LayoutTitle = LayoutTemplate.DesktopLayout.Name; currentProfile.TDPOverrideValues = MainWindow.CurrentDevice.nTDP; - currentProfile.TDPOnBatteryValues = MainWindow.CurrentDevice.nTDP; // if an update is pending, execute it and stop timer if (UpdateTimer.Enabled) @@ -601,34 +588,6 @@ private void TDPSlider_ValueChanged(object sender, RoutedPropertyChangedEventArg }; RequestUpdate(); } - private void TDPOnBatteryToggle_Toggled(object sender, RoutedEventArgs e) - { - if (currentProfile is null) - return; - - if (updateLock) - return; - - currentProfile.TDPOnBatteryEnabled = TDPOnBatteryToggle.IsOn; - RequestUpdate(); - } - - private void TDPOnBatterySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) - { - if (currentProfile is null) - return; - - if (updateLock) - return; - - currentProfile.TDPOnBatteryValues = new double[3] - { - (int)TDPOnBatterySlider.Value, - (int)TDPOnBatterySlider.Value, - (int)TDPOnBatterySlider.Value - }; - RequestUpdate(); - } private void AutoTDPToggle_Toggled(object sender, RoutedEventArgs e) {