Skip to content

Commit

Permalink
Adjust slider bounds for day/night temperature dynamically, based on …
Browse files Browse the repository at this point in the history
…the current values (#312)
  • Loading branch information
Tyrrrz authored May 31, 2024
1 parent 6c7d8bc commit 5d72dd6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LightBulb/Behaviors/LostFocusUpdateBindingBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void OnLostFocus(object? sender, RoutedEventArgs e)

private void OnBindingValueChanged()
{
if (AssociatedObject != null)
if (AssociatedObject is not null)
AssociatedObject.Text = Text;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ namespace LightBulb.ViewModels.Components.Settings;
public class GeneralSettingsTabViewModel(SettingsService settingsService)
: SettingsTabViewModelBase(settingsService, 0, "General")
{
// This value is used for slider bounds, but it's not an actual restriction
public double RecommendedMaximumDayTemperature => Math.Max(6600, DayTemperature);

// This value is used for slider bounds, but it's not an actual restriction
public double RecommendedMinimumDayTemperature => Math.Min(2500, DayTemperature);

public double DayTemperature
{
get => SettingsService.DayConfiguration.Temperature;
Expand All @@ -26,6 +32,12 @@ public double DayTemperature
}
}

// This value is used for slider bounds, but it's not an actual restriction
public double RecommendedMaximumNightTemperature => Math.Max(6600, NightTemperature);

// This value is used for slider bounds, but it's not an actual restriction
public double RecommendedMinimumNightTemperature => Math.Min(2500, NightTemperature);

public double NightTemperature
{
get => SettingsService.NightConfiguration.Temperature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
Margin="0,12,0,0"
IsSnapToTickEnabled="True"
LargeChange="500"
Maximum="6600"
Minimum="2500"
Maximum="{Binding RecommendedMaximumDayTemperature}"
Minimum="{Binding RecommendedMinimumDayTemperature}"
SmallChange="100"
TickFrequency="20"
Value="{Binding DayTemperature}" />
Expand All @@ -47,8 +47,8 @@
Margin="0,12,0,0"
IsSnapToTickEnabled="True"
LargeChange="500"
Maximum="6600"
Minimum="2500"
Maximum="{Binding RecommendedMaximumNightTemperature}"
Minimum="{Binding RecommendedMinimumNightTemperature}"
SmallChange="100"
TickFrequency="20"
Value="{Binding NightTemperature}" />
Expand Down

0 comments on commit 5d72dd6

Please sign in to comment.