Skip to content

Commit

Permalink
[Settings > Screen ruler] Fix disabled state of infobar (#20184)
Browse files Browse the repository at this point in the history
* code changes

* fix typo

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

Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com>
  • Loading branch information
htcfreek and yuyoyuppe committed Aug 30, 2022
1 parent f39691c commit bc603f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Expand Up @@ -52,6 +52,7 @@ public bool IsEnabled
SendConfigMSG(outgoing.ToString());

NotifyPropertyChanged();
NotifyPropertyChanged(nameof(ShowContinuousCaptureWarning));
}
}
}
Expand All @@ -69,6 +70,7 @@ public bool ContinuousCapture
{
Settings.Properties.ContinuousCapture = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(ShowContinuousCaptureWarning));
}
}
}
Expand Down Expand Up @@ -162,9 +164,21 @@ public HotkeySettings ActivationShortcut
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; }
}
}
7 changes: 3 additions & 4 deletions src/settings-ui/Settings.UI/Views/MeasureToolPage.xaml
Expand Up @@ -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
Expand Down

0 comments on commit bc603f8

Please sign in to comment.