[Settings > Screen ruler] Fix disabled state of infobar (#20184)

* code changes

* fix typo

* Update src/settings-ui/Settings.UI.Library/ViewModels/MeasureToolViewModel.cs

Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
This commit is contained in:
Heiko 2022-08-30 23:35:34 +02:00 committed by GitHub
parent f39691cdbc
commit bc603f88ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -52,6 +52,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
SendConfigMSG(outgoing.ToString());
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(ShowContinuousCaptureWarning));
}
}
}
@ -69,6 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
Settings.Properties.ContinuousCapture = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(ShowContinuousCaptureWarning));
}
}
}
@ -162,9 +164,21 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
public void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
{
OnPropertyChanged(propertyName);
if (propertyName == nameof(ShowContinuousCaptureWarning))
{
// Don't trigger a settings update if the changed property is for visual notification.
return;
}
SettingsUtils.SaveSettings(Settings.ToJsonString(), MeasureToolSettings.ModuleName);
}
public bool ShowContinuousCaptureWarning
{
get => IsEnabled && ContinuousCapture;
}
private Func<string, int> SendConfigMSG { get; }
}
}

View File

@ -46,10 +46,9 @@
<muxc:InfoBar
Severity="Warning"
x:Uid="MeasureTool_ContinuousCapture_Information"
IsOpen="True"
IsTabStop="True"
IsClosable="False"
Visibility="{Binding Mode=OneWay, Path=ContinuousCapture, Converter={StaticResource BoolToVisibilityConverter}}" />
IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.ShowContinuousCaptureWarning}"
IsTabStop="{x:Bind Mode=OneWay, Path=ViewModel.ShowContinuousCaptureWarning}"
IsClosable="False" />
<controls:Setting x:Uid="MeasureTool_PerColorChannelEdgeDetection" Icon="&#xE7FB;">
<controls:Setting.ActionContent>
<ToggleSwitch