Skip to content

Commit

Permalink
(GH-3843) Codacy/PR Quality Review
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Jun 15, 2020
1 parent a57bd6a commit 99e8ba7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/MahApps.Metro/Controls/NumericUpDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ private static void OnIsReadOnlyPropertyChanged(DependencyObject dependencyObjec
{
if (dependencyObject is NumericUpDown numericUpDown)
{
numericUpDown.ToggleReadOnlyMode(isReadOnly || !numericUpDown.InterceptManualEnter);
numericUpDown.ToggleReadOnlyMode(isReadOnly || numericUpDown.InterceptManualEnter == false);
}
}
}
Expand Down Expand Up @@ -338,7 +338,7 @@ private static void OnInterceptManualEnterPropertyChanged(DependencyObject depen
{
if (dependencyObject is NumericUpDown numericUpDown)
{
numericUpDown.ToggleReadOnlyMode(!interceptManualEnter || numericUpDown.IsReadOnly);
numericUpDown.ToggleReadOnlyMode(interceptManualEnter == false || numericUpDown.IsReadOnly);
}
}
}
Expand Down Expand Up @@ -726,12 +726,11 @@ public static readonly DependencyProperty SnapToMultipleOfIntervalProperty

private static void OnSnapToMultipleOfIntervalPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue != e.NewValue && d is NumericUpDown numericUpDown)
if (e.OldValue != e.NewValue && e.NewValue is bool snap && d is NumericUpDown numericUpDown)
{
var value = numericUpDown.Value.GetValueOrDefault();

if (e.NewValue is bool snap && snap && Math.Abs(numericUpDown.Interval) > 0)
if (snap && Math.Abs(numericUpDown.Interval) > 0)
{
var value = numericUpDown.Value.GetValueOrDefault();
numericUpDown.Value = Math.Round(value / numericUpDown.Interval) * numericUpDown.Interval;
}
}
Expand Down Expand Up @@ -827,7 +826,7 @@ public override void OnApplyTemplate()
throw new InvalidOperationException($"You have missed to specify {PART_NumericUp}, {PART_NumericDown} or {PART_TextBox} in your template!");
}

this.ToggleReadOnlyMode(this.IsReadOnly || !this.InterceptManualEnter);
this.ToggleReadOnlyMode(this.IsReadOnly || this.InterceptManualEnter == false);

this.repeatUp.Click += (o, e) =>
{
Expand Down

0 comments on commit 99e8ba7

Please sign in to comment.