Use OnClick instead of Checked and Unchecked.

Checked and Unchecked are called at weird, unpredictable times by WPF, and saving
settings when they happen causes us to change the setting incorrectly.  OnClick is
only called when the user actually changes the value and not when internal WPF stuff
sets it, so it doesn't have this problem.
master
Glenn Maynard 6 years ago
parent bb3ee5a0c9
commit bd052f08ef
  1. 5
      smx-config/MainWindow.xaml.cs
  2. 9
      smx-config/Widgets.cs

@ -126,10 +126,7 @@ namespace smx_config
void CreateThresholdSliders()
{
// remove the threshold sliders from xaml, create them all here
//
// remove the AdvancedModeEnabled binding and ShouldBeDisplayed, handle that here
// by creating the ones we need
// Remove and recreate threshold sliders.
ThresholdSliderContainer.Children.Clear();
foreach(string sliderName in ThresholdSettings.thresholdSliderNames)
{

@ -296,15 +296,18 @@ namespace smx_config
return;
}
Checked += delegate(object sender, RoutedEventArgs e) { SaveToSettings(); };
Unchecked += delegate(object sender, RoutedEventArgs e) { SaveToSettings(); };
OnConfigChange onConfigChange;
onConfigChange = new OnConfigChange(this, delegate(LoadFromConfigDelegateArgs args) {
LoadFromSettings();
});
}
protected override void OnClick()
{
IsChecked = !IsChecked;
SaveToSettings();
}
private void LoadFromSettings()
{
if(Type == "inner-sensors")

Loading…
Cancel
Save