mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
manual boxes should be working
This commit is contained in:
@@ -202,6 +202,7 @@
|
|||||||
x:Uid="LightSwitch_LocationDialog"
|
x:Uid="LightSwitch_LocationDialog"
|
||||||
IsPrimaryButtonEnabled="False"
|
IsPrimaryButtonEnabled="False"
|
||||||
IsSecondaryButtonEnabled="True"
|
IsSecondaryButtonEnabled="True"
|
||||||
|
Opened="LocationDialog_Opened"
|
||||||
PrimaryButtonClick="LocationDialog_PrimaryButtonClick"
|
PrimaryButtonClick="LocationDialog_PrimaryButtonClick"
|
||||||
PrimaryButtonStyle="{StaticResource AccentButtonStyle}">
|
PrimaryButtonStyle="{StaticResource AccentButtonStyle}">
|
||||||
<Grid RowSpacing="16">
|
<Grid RowSpacing="16">
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
private readonly DispatcherQueue _dispatcherQueue;
|
private readonly DispatcherQueue _dispatcherQueue;
|
||||||
private bool _suppressViewModelUpdates;
|
private bool _suppressViewModelUpdates;
|
||||||
private bool _suppressLatLonChange = true;
|
private bool _suppressLatLonChange = true;
|
||||||
|
private bool _latLoaded;
|
||||||
|
private bool _lonLoaded;
|
||||||
|
|
||||||
private LightSwitchViewModel ViewModel { get; set; }
|
private LightSwitchViewModel ViewModel { get; set; }
|
||||||
|
|
||||||
@@ -174,6 +176,13 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
ViewModel.Longitude = longitude.ToString(CultureInfo.InvariantCulture);
|
ViewModel.Longitude = longitude.ToString(CultureInfo.InvariantCulture);
|
||||||
ViewModel.SyncButtonInformation = $"{ViewModel.Latitude}<7D>, {ViewModel.Longitude}<7D>";
|
ViewModel.SyncButtonInformation = $"{ViewModel.Latitude}<7D>, {ViewModel.Longitude}<7D>";
|
||||||
|
|
||||||
|
var result = SunCalc.CalculateSunriseSunset(latitude, longitude, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
|
||||||
|
|
||||||
|
// Temporarily display these preview times
|
||||||
|
ViewModel.LightTime = (result.SunriseHour * 60) + result.SunriseMinute;
|
||||||
|
ViewModel.DarkTime = (result.SunsetHour * 60) + result.SunsetMinute;
|
||||||
|
|
||||||
|
// Show the panel with these values
|
||||||
LocationResultPanel.Visibility = Visibility.Visible;
|
LocationResultPanel.Visibility = Visibility.Visible;
|
||||||
if (LocationDialog != null)
|
if (LocationDialog != null)
|
||||||
{
|
{
|
||||||
@@ -183,18 +192,41 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
|||||||
|
|
||||||
private void LocationDialog_PrimaryButtonClick(object sender, ContentDialogButtonClickEventArgs args)
|
private void LocationDialog_PrimaryButtonClick(object sender, ContentDialogButtonClickEventArgs args)
|
||||||
{
|
{
|
||||||
if (ViewModel.ScheduleMode == "SunriseToSunsetUser")
|
/* if (ViewModel.ScheduleMode == "SunriseToSunsetUser")
|
||||||
{
|
{
|
||||||
ViewModel.SyncButtonInformation = ViewModel.SelectedCity.City;
|
ViewModel.SyncButtonInformation = ViewModel.SelectedCity.City;
|
||||||
}
|
}
|
||||||
else if (ViewModel.ScheduleMode == "SunriseToSunsetGeo")
|
else if (ViewModel.ScheduleMode == "SunriseToSunsetGeo")
|
||||||
{
|
{
|
||||||
ViewModel.SyncButtonInformation = $"{ViewModel.Latitude}<7D>, {ViewModel.Longitude}<7D>";
|
ViewModel.SyncButtonInformation = $"{ViewModel.Latitude}<7D>, {ViewModel.Longitude}<7D>";
|
||||||
}
|
} */
|
||||||
|
|
||||||
SunriseModeChartState();
|
SunriseModeChartState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LocationDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args)
|
||||||
|
{
|
||||||
|
LatitudeBox.Loaded += LatLonBox_Loaded;
|
||||||
|
LongitudeBox.Loaded += LatLonBox_Loaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LatLonBox_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender as NumberBox == LatitudeBox)
|
||||||
|
{
|
||||||
|
_latLoaded = true;
|
||||||
|
}
|
||||||
|
else if (sender as NumberBox == LongitudeBox)
|
||||||
|
{
|
||||||
|
_lonLoaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_latLoaded && _lonLoaded)
|
||||||
|
{
|
||||||
|
_suppressLatLonChange = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_suppressViewModelUpdates)
|
if (_suppressViewModelUpdates)
|
||||||
|
|||||||
Reference in New Issue
Block a user