Skip to content

Commit

Permalink
Simplify checkbox logic
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanLua committed Jan 9, 2025
1 parent f71db44 commit f51bbcf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
6 changes: 2 additions & 4 deletions FluentAutoClicker/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@
<CheckBox
x:Name="ClickRepeatCheckBox"
x:Uid="ClickRepeatCheckBox"
Checked="ClickRepeatCheckBox_Checked"
Unchecked="ClickRepeatCheckBox_Unchecked" />
Click="CheckBox_Click" />
<NumberBox
x:Name="ClickRepeatAmount"
HorizontalAlignment="Left"
Expand All @@ -121,8 +120,7 @@
<CheckBox
x:Name="ClickOffsetCheckBox"
x:Uid="ClickOffsetCheckBox"
Checked="ClickOffsetCheckBox_Checked"
Unchecked="ClickOffsetCheckBox_Unchecked" />
Click="CheckBox_Click" />
<NumberBox
x:Name="ClickOffsetAmount"
HorizontalAlignment="Left"
Expand Down
30 changes: 11 additions & 19 deletions FluentAutoClicker/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void SetControlsEnabled(bool isEnabled)
HotkeyTextBlock.Foreground = Application.Current.Resources[brushKey] as Brush;
}

private int GetNumberBoxValue(NumberBox numberBox, int defaultValue)
private static int GetNumberBoxValue(NumberBox numberBox, int defaultValue)
{
if (!int.TryParse(numberBox.Value.ToString(CultureInfo.InvariantCulture), out int value))
{
Expand Down Expand Up @@ -168,23 +168,15 @@ private void StartToggleButton_OnUnchecked(object sender, RoutedEventArgs e)
SetControlsEnabled(true);
}

private void ClickRepeatCheckBox_Unchecked(object sender, RoutedEventArgs e)
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
ClickRepeatAmount.IsEnabled = false;
}

private void ClickRepeatCheckBox_Checked(object sender, RoutedEventArgs e)
{
ClickRepeatAmount.IsEnabled = true;
}

private void ClickOffsetCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
ClickOffsetAmount.IsEnabled = false;
}

private void ClickOffsetCheckBox_Checked(object sender, RoutedEventArgs e)
{
ClickOffsetAmount.IsEnabled = true;
if (sender.Equals(ClickRepeatCheckBox))
{
ClickRepeatAmount.IsEnabled = ClickRepeatCheckBox.IsChecked == true;
}
else if (sender.Equals(ClickOffsetCheckBox))
{
ClickOffsetAmount.IsEnabled = ClickOffsetCheckBox.IsChecked == true;
}
}
}
}

0 comments on commit f51bbcf

Please sign in to comment.