[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
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()); SendConfigMSG(outgoing.ToString());
NotifyPropertyChanged(); NotifyPropertyChanged();
NotifyPropertyChanged(nameof(ShowContinuousCaptureWarning));
} }
} }
} }
@@ -69,6 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{ {
Settings.Properties.ContinuousCapture = value; Settings.Properties.ContinuousCapture = value;
NotifyPropertyChanged(); NotifyPropertyChanged();
NotifyPropertyChanged(nameof(ShowContinuousCaptureWarning));
} }
} }
} }
@@ -162,9 +164,21 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
public void NotifyPropertyChanged([CallerMemberName] string propertyName = null) public void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
{ {
OnPropertyChanged(propertyName); 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); SettingsUtils.SaveSettings(Settings.ToJsonString(), MeasureToolSettings.ModuleName);
} }
public bool ShowContinuousCaptureWarning
{
get => IsEnabled && ContinuousCapture;
}
private Func<string, int> SendConfigMSG { get; } private Func<string, int> SendConfigMSG { get; }
} }
} }

View File

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