diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml
index a44d482a04..e1d6d8013c 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/LightSwitchPage.xaml
@@ -112,8 +112,8 @@
@@ -121,8 +121,8 @@
diff --git a/src/settings-ui/Settings.UI/ViewModels/LightSwitchViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/LightSwitchViewModel.cs
index 05aec49c9a..6d3c83c8ba 100644
--- a/src/settings-ui/Settings.UI/ViewModels/LightSwitchViewModel.cs
+++ b/src/settings-ui/Settings.UI/ViewModels/LightSwitchViewModel.cs
@@ -232,6 +232,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
NotifyPropertyChanged();
OnPropertyChanged(nameof(LightTimeTimeSpan));
+ OnPropertyChanged(nameof(SunriseOffsetMin));
+ OnPropertyChanged(nameof(SunsetOffsetMin));
if (ScheduleMode == "SunsetToSunrise")
{
@@ -252,6 +254,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
NotifyPropertyChanged();
OnPropertyChanged(nameof(DarkTimeTimeSpan));
+ OnPropertyChanged(nameof(SunriseOffsetMax));
+ OnPropertyChanged(nameof(SunsetOffsetMax));
if (ScheduleMode == "SunsetToSunrise")
{
@@ -270,6 +274,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
ModuleSettings.Properties.SunriseOffset.Value = value;
OnPropertyChanged(nameof(LightTimeTimeSpan));
+ OnPropertyChanged(nameof(SunsetOffsetMin));
}
}
}
@@ -283,10 +288,49 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
ModuleSettings.Properties.SunsetOffset.Value = value;
OnPropertyChanged(nameof(DarkTimeTimeSpan));
+ OnPropertyChanged(nameof(SunriseOffsetMax));
}
}
}
+ public int SunriseOffsetMin
+ {
+ get
+ {
+ // Minimum: don't let adjusted sunrise go before 00:00
+ return -LightTime;
+ }
+ }
+
+ public int SunriseOffsetMax
+ {
+ get
+ {
+ // Maximum: adjusted sunrise must stay before adjusted sunset
+ int adjustedSunset = DarkTime + SunsetOffset;
+ return Math.Max(0, adjustedSunset - LightTime - 1);
+ }
+ }
+
+ public int SunsetOffsetMin
+ {
+ get
+ {
+ // Minimum: adjusted sunset must stay after adjusted sunrise
+ int adjustedSunrise = LightTime + SunriseOffset;
+ return Math.Min(0, adjustedSunrise - DarkTime + 1);
+ }
+ }
+
+ public int SunsetOffsetMax
+ {
+ get
+ {
+ // Maximum: don't let adjusted sunset go past 23:59 (1439 minutes)
+ return 1439 - DarkTime;
+ }
+ }
+
// === Computed projections (OneWay bindings only) ===
public TimeSpan LightTimeTimeSpan
{