From 0f8cbf0f1a6bd00a28a6a5ab6a648c9971f60058 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Tue, 12 Dec 2023 18:04:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=90=E5=8F=96=E5=8B=BE=E9=80=89?= =?UTF-8?q?=E6=A1=86=E5=B7=A6=E5=8F=B3=E9=94=AE=E7=82=B9=E5=87=BB=E5=8D=95?= =?UTF-8?q?=E6=AC=A1=E6=89=A7=E8=A1=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/CheckBoxHelper.cs | 39 +++++++++++++++++++ .../FightSettingsUserControl.xaml.cs | 13 ++----- 2 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 src/MaaWpfGui/Helper/CheckBoxHelper.cs diff --git a/src/MaaWpfGui/Helper/CheckBoxHelper.cs b/src/MaaWpfGui/Helper/CheckBoxHelper.cs new file mode 100644 index 0000000000..d6082e7c50 --- /dev/null +++ b/src/MaaWpfGui/Helper/CheckBoxHelper.cs @@ -0,0 +1,39 @@ +// +// MaaWpfGui - A part of the MaaCoreArknights project +// Copyright (C) 2021 MistEO and Contributors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY +// + +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; + +namespace MaaWpfGui.Helper +{ + public static class CheckBoxHelper + { + public static void ToggleCheckBoxNullOnRightClick(object sender, MouseButtonEventArgs e) + { + if (e.ChangedButton != MouseButton.Right) + { + return; + } + + CheckBox checkBox = (CheckBox)sender; + checkBox.IsChecked = checkBox.IsChecked == null ? (bool?)false : null; + } + + public static void ToggleCheckBoxNullOnLeftClick(object sender, RoutedEventArgs e) + { + CheckBox checkBox = (CheckBox)sender; + checkBox.IsChecked = checkBox.IsChecked == true ? null : (bool?)false; + } + } +} diff --git a/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml.cs b/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml.cs index 354151ec3d..79452ec02e 100644 --- a/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml.cs +++ b/src/MaaWpfGui/Views/UserControl/FightSettingsUserControl.xaml.cs @@ -13,8 +13,8 @@ using System.Reflection; using System.Windows; -using System.Windows.Controls; using System.Windows.Input; +using MaaWpfGui.Helper; namespace MaaWpfGui.Views.UserControl { @@ -42,19 +42,12 @@ namespace MaaWpfGui.Views.UserControl private void ToggleCheckBoxNullOnRightClick(object sender, MouseButtonEventArgs e) { - if (e.ChangedButton != MouseButton.Right) - { - return; - } - - CheckBox checkBox = (CheckBox)sender; - checkBox.IsChecked = checkBox.IsChecked == null ? (bool?)false : null; + CheckBoxHelper.ToggleCheckBoxNullOnRightClick(sender, e); } private void ToggleCheckBoxNullOnLeftClick(object sender, RoutedEventArgs e) { - CheckBox checkBox = (CheckBox)sender; - checkBox.IsChecked = checkBox.IsChecked == true ? null : (bool?)false; + CheckBoxHelper.ToggleCheckBoxNullOnLeftClick(sender, e); } } }