Skip to content

Commit

Permalink
Add "disable until sunrise" option
Browse files Browse the repository at this point in the history
Closes #108
  • Loading branch information
Tyrrrz committed Nov 4, 2019
1 parent f2b7f08 commit 3ad0fac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LightBulb/ViewModels/RootViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ public void DisableTemporarily(TimeSpan duration)
IsEnabled = false;
}

public void DisableTemporarilyUntilSunrise()
{
// Use real time here instead of Instant, because that's what the user likely wants
var timeUntilSunrise = DateTimeOffset.Now.NextTimeOfDay(ActualSunriseEndTime) - DateTimeOffset.Now;
DisableTemporarily(timeUntilSunrise);
}

public void Toggle() => IsEnabled = !IsEnabled;

public void EnableCyclePreview() => IsCyclePreviewEnabled = true;
Expand Down
1 change: 1 addition & 0 deletions LightBulb/Views/RootView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<MenuItem.Icon>
<materialDesign:PackIcon Kind="PowerSettings" />
</MenuItem.Icon>
<MenuItem Command="{s:Action DisableTemporarilyUntilSunrise}" Header="Until sunrise" />
<MenuItem Command="{s:Action DisableTemporarily}" Header="1 day">
<MenuItem.CommandParameter>
<system:TimeSpan>24:0:0</system:TimeSpan>
Expand Down

0 comments on commit 3ad0fac

Please sign in to comment.