trying to fix infinite settings updates

This commit is contained in:
Jaylyn Barbee
2025-11-05 11:05:56 -05:00
parent 26b22b566a
commit fd99820026
2 changed files with 9 additions and 2 deletions

View File

@@ -258,7 +258,6 @@
x:Uid="LightSwitch_LatitudeBox"
Maximum="90"
Minimum="-90"
PlaceholderText="52"
Text="{x:Bind ViewModel.Latitude, Mode=TwoWay}"
ValueChanged="LatLonBox_ValueChanged" />
<NumberBox
@@ -267,7 +266,6 @@
Grid.Column="1"
Maximum="180"
Minimum="-180"
PlaceholderText="6"
Text="{x:Bind ViewModel.Longitude, Mode=TwoWay}"
ValueChanged="LatLonBox_ValueChanged" />
<Button

View File

@@ -157,6 +157,15 @@ namespace Microsoft.PowerToys.Settings.UI.Views
double lat = (double)LatitudeBox.Value;
double lon = (double)LongitudeBox.Value;
double.TryParse(ViewModel.Latitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double currentLat);
double.TryParse(ViewModel.Longitude, NumberStyles.Float, CultureInfo.InvariantCulture, out double currentLon);
// If the new values are the same as the current ones (within tolerance), do nothing
if (Math.Abs(lat - currentLat) < 0.0001 && Math.Abs(lon - currentLon) < 0.0001)
{
return;
}
// Optional: Validate ranges
if (lat < -90 || lat > 90 || lon < -180 || lon > 180)
{