mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
feat: 提取勾选框左右键点击单次执行逻辑
This commit is contained in:
39
src/MaaWpfGui/Helper/CheckBoxHelper.cs
Normal file
39
src/MaaWpfGui/Helper/CheckBoxHelper.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
// <copyright file="CheckBoxHelper.cs" company="MaaAssistantArknights">
|
||||
// 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
|
||||
// </copyright>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user