Skip to content

Commit

Permalink
Temporarily detach value listeners. (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszCichecki authored Nov 9, 2023
1 parent 115bbb3 commit 7971907
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,14 @@
Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_LongTermPL}"
Margin="0,0,0,8"
Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_LongTermPL_Description}"
Unit="W"
ValueChanged="CpuLongTermPowerLimitSlider_ValueChanged" />
Unit="W" />

<godMode:GodModeValueControl
x:Name="_cpuShortTermPowerLimitControl"
Title="{x:Static resources:Resource.GodModeSettingsWindow_CPU_ShortTermPL}"
Margin="0,0,0,8"
Description="{x:Static resources:Resource.GodModeSettingsWindow_CPU_ShortTermPL_Description}"
Unit="W"
ValueChanged="CpuShortTermPowerLimitSlider_ValueChanged" />
Unit="W" />

<godMode:GodModeValueControl
x:Name="_cpuPeakPowerLimitControl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ private async Task<bool> ApplyAsync()

private async Task SetStateAsync(GodModeState state)
{
_cpuLongTermPowerLimitControl.ValueChanged -= CpuLongTermPowerLimitSlider_ValueChanged;
_cpuShortTermPowerLimitControl.ValueChanged -= CpuShortTermPowerLimitSlider_ValueChanged;

var activePresetId = state.ActivePresetId;
var preset = state.Presets[activePresetId];

Expand All @@ -160,7 +163,6 @@ private async Task SetStateAsync(GodModeState state)
_addPresetsButton.IsEnabled = state.Presets.Count < 5;
_deletePresetsButton.IsEnabled = state.Presets.Count > 1;


_cpuLongTermPowerLimitControl.Set(preset.CPULongTermPowerLimit);
_cpuShortTermPowerLimitControl.Set(preset.CPUShortTermPowerLimit);
_cpuPeakPowerLimitControl.Set(preset.CPUPeakPowerLimit);
Expand Down Expand Up @@ -246,6 +248,9 @@ private async Task SetStateAsync(GodModeState state)
_fanSectionTitle.Visibility = fanSectionVisible ? Visibility.Visible : Visibility.Collapsed;
_advancedSectionTitle.Visibility = advancedSectionVisible ? Visibility.Visible : Visibility.Collapsed;
_advancedSectionMessage.Visibility = advancedSectionVisible ? Visibility.Visible : Visibility.Collapsed;

_cpuLongTermPowerLimitControl.ValueChanged += CpuLongTermPowerLimitSlider_ValueChanged;
_cpuShortTermPowerLimitControl.ValueChanged += CpuShortTermPowerLimitSlider_ValueChanged;
}

private async void SetDefaults(GodModeDefaults defaults)
Expand Down

0 comments on commit 7971907

Please sign in to comment.