Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust slider bounds for day/night temperature dynamically, based on the current values #312

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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