feat: 基建列表增加 全/反选 按钮,列表区域可响应滚动

fix #10102
This commit is contained in:
uye
2024-08-06 00:59:40 +08:00
parent 96fdcb55d2
commit 2829a5701d
3 changed files with 67 additions and 1 deletions

View File

@@ -1476,6 +1476,26 @@ namespace MaaWpfGui.ViewModels.UI
return (from item in InfrastItemViewModels where item.IsChecked select item.OriginalName).ToList();
}
// UI 绑定的方法
// ReSharper disable once UnusedMember.Global
public void InfrastItemSelectedAll()
{
foreach (var item in InfrastItemViewModels)
{
item.IsChecked = true;
}
}
// UI 绑定的方法
// ReSharper disable once UnusedMember.Global
public void InfrastItemUnselectedAll()
{
foreach (var item in InfrastItemViewModels)
{
item.IsChecked = false;
}
}
/// <summary>
/// 实时更新基建换班顺序
/// </summary>

View File

@@ -115,11 +115,37 @@
<StackPanel Orientation="Horizontal">
<!--<maa:TextBlock Text="{Binding ID}" />
<maa:TextBlock Text=". " />-->
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsChecked}" />
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsCheckedWithNull}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.Resources>
<Style BasedOn="{StaticResource {x:Type ListBox}}" TargetType="{x:Type ListBox}">
<EventSetter Event="PreviewMouseWheel" Handler="ListBox_PreviewMouseWheel" />
</Style>
</ListBox.Resources>
</ListBox>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button
Height="30"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Command="{s:Action InfrastItemSelectedAll}"
Content="{DynamicResource SelectAll}"
IsEnabled="{Binding Idle}" />
<Button
Grid.Column="1"
Height="30"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Command="{s:Action InfrastItemUnselectedAll}"
Content="{DynamicResource Clear}"
IsEnabled="{Binding Idle}" />
</Grid>
</StackPanel>
<!-- 开自定义基建计划时,放在常规设置的部分 -->

View File

@@ -11,6 +11,10 @@
// but WITHOUT ANY WARRANTY
// </copyright>
using System.Windows.Input;
using System.Windows;
using System.Windows.Controls;
namespace MaaWpfGui.Views.UserControl
{
/// <summary>
@@ -25,5 +29,21 @@ namespace MaaWpfGui.Views.UserControl
{
InitializeComponent();
}
private void ListBox_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Handled)
{
return;
}
e.Handled = true;
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
{
RoutedEvent = UIElement.MouseWheelEvent
};
var parent = ((Control)sender).Parent as UIElement;
parent?.RaiseEvent(eventArg);
}
}
}