-
Notifications
You must be signed in to change notification settings - Fork 7.5k
[Light Switch] Enter latitude and longitude manually in Sunrise to sunset mode #43276
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
Changes from 13 commits
b745f61
b3e09e6
be87a44
814eb78
3b1dfeb
e8ee996
26b22b5
fd99820
e749f21
b71140e
ac0b56a
eec7940
d172c21
da0fe7a
5cf0b4d
55f28f8
48ddffa
89d58aa
95b9236
bd73f4a
62ea01e
29de283
64dafdc
ae2f817
b01c819
c0bc441
7bb7d92
0d52787
a19de59
eb41e17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,6 @@ | |||||||||||||
| using System.IO; | ||||||||||||||
| using System.IO.Abstractions; | ||||||||||||||
| using System.Linq; | ||||||||||||||
| using System.Threading.Tasks; | ||||||||||||||
| using ManagedCommon; | ||||||||||||||
| using Microsoft.PowerToys.Settings.UI.Helpers; | ||||||||||||||
| using Microsoft.PowerToys.Settings.UI.Library; | ||||||||||||||
|
|
@@ -37,6 +36,8 @@ public sealed partial class LightSwitchPage : Page | |||||||||||||
| private readonly IFileSystem _fileSystem; | ||||||||||||||
| private readonly IFileSystemWatcher _fileSystemWatcher; | ||||||||||||||
| private readonly DispatcherQueue _dispatcherQueue; | ||||||||||||||
| private bool _suppressViewModelUpdates; | ||||||||||||||
| private bool _suppressLatLonChange; | ||||||||||||||
Jaylyn-Barbee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| private LightSwitchViewModel ViewModel { get; set; } | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -89,11 +90,14 @@ private void LightSwitchPage_Loaded(object sender, RoutedEventArgs e) | |||||||||||||
| ViewModel.InitializeScheduleMode(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private async Task GetGeoLocation() | ||||||||||||||
| private async void GetGeoLocation_Click(object sender, RoutedEventArgs e) | ||||||||||||||
Jaylyn-Barbee marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| { | ||||||||||||||
| LatitudeBox.IsEnabled = false; | ||||||||||||||
| LongitudeBox.IsEnabled = false; | ||||||||||||||
| SyncButton.IsEnabled = false; | ||||||||||||||
Jaylyn-Barbee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| SyncLoader.IsActive = true; | ||||||||||||||
| SyncLoader.Visibility = Visibility.Visible; | ||||||||||||||
| LocationResultPanel.Visibility = Visibility.Collapsed; | ||||||||||||||
|
|
||||||||||||||
| try | ||||||||||||||
| { | ||||||||||||||
|
||||||||||||||
|
|
@@ -111,16 +115,6 @@ private async Task GetGeoLocation() | |||||||||||||
|
|
||||||||||||||
| double latitude = Math.Round(pos.Coordinate.Point.Position.Latitude); | ||||||||||||||
| double longitude = Math.Round(pos.Coordinate.Point.Position.Longitude); | ||||||||||||||
|
Comment on lines
121
to
122
|
||||||||||||||
|
|
||||||||||||||
| SunTimes result = SunCalc.CalculateSunriseSunset( | ||||||||||||||
| latitude, | ||||||||||||||
| longitude, | ||||||||||||||
| DateTime.Now.Year, | ||||||||||||||
| DateTime.Now.Month, | ||||||||||||||
| DateTime.Now.Day); | ||||||||||||||
|
|
||||||||||||||
| ViewModel.LightTime = (result.SunriseHour * 60) + result.SunriseMinute; | ||||||||||||||
| ViewModel.DarkTime = (result.SunsetHour * 60) + result.SunsetMinute; | ||||||||||||||
| ViewModel.Latitude = latitude.ToString(CultureInfo.InvariantCulture); | ||||||||||||||
| ViewModel.Longitude = longitude.ToString(CultureInfo.InvariantCulture); | ||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| // Calculate and set sunrise/sunset times for the detected location | |
| var sunTimes = SunTimeHelper.GetSunTimes(latitude, longitude, DateTime.Now); | |
| ViewModel.LightTime = sunTimes.Sunrise; | |
| ViewModel.DarkTime = sunTimes.Sunset; |
Uh oh!
There was an error while loading. Please reload this page.