mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-27 10:15:50 +08:00
346 lines
20 KiB
XML
346 lines
20 KiB
XML
<UserControl x:Class="BetterGenshinImpact.View.Pages.GearTaskListPage"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:pages="clr-namespace:BetterGenshinImpact.ViewModel.Pages"
|
|
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
|
xmlns:component="clr-namespace:BetterGenshinImpact.ViewModel.Pages.Component"
|
|
xmlns:dd="urn:gong-wpf-dragdrop"
|
|
xmlns:behavior="clr-namespace:BetterGenshinImpact.View.Behavior"
|
|
xmlns:local="clr-namespace:BetterGenshinImpact.View.Pages.Component"
|
|
d:DataContext="{d:DesignInstance Type=pages:GearTaskListPageViewModel}"
|
|
d:DesignHeight="850"
|
|
d:DesignWidth="1200"
|
|
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
|
|
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
|
FontFamily="{StaticResource TextThemeFontFamily}"
|
|
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
|
mc:Ignorable="d">
|
|
|
|
<UserControl.Resources>
|
|
<!-- 任务定义项模板 -->
|
|
<DataTemplate x:Key="TaskDefinitionItemTemplate" DataType="{x:Type component:GearTaskDefinitionViewModel}">
|
|
<Border Background="{DynamicResource CardBackground}"
|
|
BorderBrush="{DynamicResource CardBorderBrush}"
|
|
BorderThickness="1"
|
|
CornerRadius="4"
|
|
Margin="2"
|
|
Padding="8">
|
|
<Border.Style>
|
|
<Style TargetType="Border">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding IsSelected}" Value="True">
|
|
<Setter Property="Background" Value="{DynamicResource AccentFillColorDefaultBrush}" />
|
|
<Setter Property="BorderBrush" Value="{DynamicResource AccentFillColorDefaultBrush}" />
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</Border.Style>
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<ui:TextBlock Grid.Row="0"
|
|
FontWeight="SemiBold"
|
|
Text="{Binding Name}"
|
|
TextTrimming="CharacterEllipsis" />
|
|
|
|
<ui:TextBlock Grid.Row="1"
|
|
Margin="0,4,0,0"
|
|
FontSize="12"
|
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
|
Text="{Binding Description}"
|
|
TextTrimming="CharacterEllipsis"
|
|
TextWrapping="NoWrap"
|
|
HorizontalAlignment="Left"
|
|
MaxWidth="280"
|
|
MaxHeight="40" />
|
|
|
|
<StackPanel Grid.Row="2"
|
|
Margin="0,4,0,0"
|
|
Orientation="Horizontal">
|
|
<ui:TextBlock FontSize="10"
|
|
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
|
|
Text="{Binding ModifiedTime, StringFormat='修改: {0:MM-dd HH:mm}'}" />
|
|
</StackPanel>
|
|
</Grid>
|
|
</Border>
|
|
</DataTemplate>
|
|
|
|
<!-- 右键菜单 -->
|
|
<ContextMenu x:Key="TaskNodeContextMenu">
|
|
<MenuItem Header="添加JS脚本" Command="{Binding AddTaskNodeCommand}" CommandParameter="Javascript">
|
|
<MenuItem.Icon>
|
|
<ui:SymbolIcon Symbol="Add24" />
|
|
</MenuItem.Icon>
|
|
</MenuItem>
|
|
<MenuItem Header="添加地图追踪任务" Command="{Binding AddTaskNodeCommand}" CommandParameter="Pathing">
|
|
<MenuItem.Icon>
|
|
<ui:SymbolIcon Symbol="Add24" />
|
|
</MenuItem.Icon>
|
|
</MenuItem>
|
|
<MenuItem Header="添加键鼠脚本" Command="{Binding AddTaskNodeCommand}" CommandParameter="KeyMouse">
|
|
<MenuItem.Icon>
|
|
<ui:SymbolIcon Symbol="Add24" />
|
|
</MenuItem.Icon>
|
|
</MenuItem>
|
|
<MenuItem Header="添加Shell" Command="{Binding AddTaskNodeCommand}" CommandParameter="Shell">
|
|
<MenuItem.Icon>
|
|
<ui:SymbolIcon Symbol="Add24" />
|
|
</MenuItem.Icon>
|
|
</MenuItem>
|
|
<MenuItem Header="添加C#方法" Command="{Binding AddTaskNodeCommand}" CommandParameter="CSharp">
|
|
<MenuItem.Icon>
|
|
<ui:SymbolIcon Symbol="Add24" />
|
|
</MenuItem.Icon>
|
|
</MenuItem>
|
|
<Separator />
|
|
<MenuItem Header="添加任务组" Command="{Binding AddTaskGroupCommand}">
|
|
<MenuItem.Icon>
|
|
<ui:SymbolIcon Symbol="Folder24" />
|
|
</MenuItem.Icon>
|
|
</MenuItem>
|
|
<Separator />
|
|
<MenuItem Header="删除" Command="{Binding DeleteTaskNodeCommand}"
|
|
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}">
|
|
<MenuItem.Icon>
|
|
<ui:SymbolIcon Symbol="Delete24" />
|
|
</MenuItem.Icon>
|
|
</MenuItem>
|
|
</ContextMenu>
|
|
</UserControl.Resources>
|
|
|
|
<Grid Margin="16">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="300" />
|
|
<ColumnDefinition Width="8" />
|
|
<ColumnDefinition Width="*" />
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<!-- 左侧:任务定义列表 -->
|
|
<Grid Grid.Column="0">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="*" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<ui:TextBlock Grid.Row="0"
|
|
Margin="0,0,0,8"
|
|
FontSize="16"
|
|
FontWeight="SemiBold"
|
|
Text="任务定义列表" />
|
|
|
|
<!-- 左侧工具栏 -->
|
|
<StackPanel Grid.Row="1"
|
|
Margin="0,0,0,8"
|
|
Orientation="Horizontal">
|
|
<ui:Button Command="{Binding AddTaskDefinitionCommand}"
|
|
Content="新建"
|
|
Icon="{ui:SymbolIcon Add24}"
|
|
Margin="0,0,4,0" />
|
|
<ui:Button Command="{Binding ExecuteSelectedTaskDefinitionCommand}"
|
|
Content="执行任务组"
|
|
Icon="{ui:SymbolIcon Play24}"
|
|
Margin="0,0,4,0" />
|
|
</StackPanel>
|
|
|
|
<!-- 任务定义列表 -->
|
|
<ui:Border Grid.Row="2"
|
|
Background="{DynamicResource CardBackground}"
|
|
BorderBrush="{DynamicResource CardBorderBrush}"
|
|
BorderThickness="1"
|
|
CornerRadius="{DynamicResource ControlCornerRadius}">
|
|
<ListBox ItemsSource="{Binding TaskDefinitions}"
|
|
SelectedItem="{Binding SelectedTaskDefinition}"
|
|
ItemTemplate="{StaticResource TaskDefinitionItemTemplate}"
|
|
Background="Transparent"
|
|
BorderThickness="0"
|
|
dd:DragDrop.IsDragSource="True"
|
|
dd:DragDrop.IsDropTarget="True"
|
|
dd:DragDrop.DropHandler="{Binding}"
|
|
dd:DragDrop.UseDefaultDragAdorner="True"
|
|
Padding="4">
|
|
<ListBox.ContextMenu>
|
|
<ContextMenu>
|
|
<MenuItem Header="新增任务定义"
|
|
Command="{Binding AddTaskDefinitionCommand}"
|
|
Icon="{ui:SymbolIcon Add24}" />
|
|
<MenuItem Header="执行选中任务组"
|
|
Command="{Binding ExecuteTaskDefinitionCommand}"
|
|
CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}"
|
|
Icon="{ui:SymbolIcon Play24}" />
|
|
<Separator />
|
|
<MenuItem Header="编辑选中项"
|
|
Command="{Binding EditSelectedTaskDefinitionCommand}"
|
|
Icon="{ui:SymbolIcon Edit24}" />
|
|
<MenuItem Header="删除选中项"
|
|
Command="{Binding DeleteSelectedTaskDefinitionCommand}"
|
|
Icon="{ui:SymbolIcon Delete24}" />
|
|
</ContextMenu>
|
|
</ListBox.ContextMenu>
|
|
<ListBox.ItemContainerStyle>
|
|
<Style TargetType="ListBoxItem">
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
|
<Setter Property="Padding" Value="0" />
|
|
<Setter Property="Margin" Value="0" />
|
|
<Setter Property="Background" Value="Transparent" />
|
|
<Setter Property="BorderThickness" Value="0" />
|
|
|
|
<Style.Triggers>
|
|
<Trigger Property="IsSelected" Value="True">
|
|
<Setter Property="Background" Value="Transparent" />
|
|
</Trigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</ListBox.ItemContainerStyle>
|
|
<b:Interaction.Triggers>
|
|
<b:EventTrigger EventName="SelectionChanged">
|
|
<b:InvokeCommandAction Command="{Binding SelectTaskDefinitionCommand}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=ListBox}}" />
|
|
</b:EventTrigger>
|
|
</b:Interaction.Triggers>
|
|
</ListBox>
|
|
</ui:Border>
|
|
</Grid>
|
|
|
|
<!-- 分隔线 -->
|
|
<GridSplitter Grid.Column="1"
|
|
HorizontalAlignment="Stretch"
|
|
Background="Transparent" />
|
|
|
|
<!-- 右侧:任务详情 -->
|
|
<Grid Grid.Column="2">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="*" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<ui:TextBlock Grid.Row="0"
|
|
Margin="0,0,0,8"
|
|
FontSize="16"
|
|
FontWeight="SemiBold"
|
|
Text="{Binding SelectedTaskDefinition.Name, StringFormat='任务详情 - {0}', FallbackValue='任务详情'}" />
|
|
|
|
<!-- 右侧工具栏 -->
|
|
<StackPanel Grid.Row="1"
|
|
Margin="0,0,0,8"
|
|
Orientation="Horizontal">
|
|
<ui:DropDownButton Content="添加任务" Icon="{ui:SymbolIcon Add24}" Margin="0,0,10,0">
|
|
<ui:DropDownButton.Flyout>
|
|
<ContextMenu>
|
|
<MenuItem Header="JS脚本" Command="{Binding AddTaskNodeCommand}" CommandParameter="Javascript" />
|
|
<MenuItem Header="地图追踪任务" Command="{Binding AddTaskNodeCommand}" CommandParameter="Pathing" />
|
|
<MenuItem Header="键鼠脚本" Command="{Binding AddTaskNodeCommand}" CommandParameter="KeyMouse" />
|
|
<MenuItem Header="Shell" Command="{Binding AddTaskNodeCommand}" CommandParameter="Shell" />
|
|
<MenuItem Header="C#方法" Command="{Binding AddTaskNodeCommand}" CommandParameter="CSharp" />
|
|
</ContextMenu>
|
|
</ui:DropDownButton.Flyout>
|
|
</ui:DropDownButton>
|
|
<ui:Button Command="{Binding AddTaskGroupCommand}"
|
|
Content="添加组"
|
|
Icon="{ui:SymbolIcon Folder24}"
|
|
Margin="0,0,4,0" />
|
|
</StackPanel>
|
|
|
|
<!-- 任务树 -->
|
|
<ui:Border Grid.Row="2"
|
|
Background="{DynamicResource CardBackground}"
|
|
BorderBrush="{DynamicResource CardBorderBrush}"
|
|
BorderThickness="1"
|
|
CornerRadius="{DynamicResource ControlCornerRadius}">
|
|
<Grid Margin="4">
|
|
<ui:Grid ColumnDefinitions="*,120,80,100,20" Visibility="Hidden">
|
|
<Grid x:Name="TreeColumnName" Grid.Column="0" />
|
|
<Grid x:Name="TreeColumnType" Grid.Column="1" />
|
|
<Grid x:Name="TreeColumnEnabled" Grid.Column="2" />
|
|
<Grid x:Name="TreeColumnActions" Grid.Column="3" />
|
|
<Grid x:Name="TreeColumnSpace" Grid.Column="3" />
|
|
</ui:Grid>
|
|
|
|
<ui:TreeListView BorderThickness="0"
|
|
ItemsSource="{Binding CurrentTaskTreeRoot.Children}"
|
|
SelectedItem="{Binding SelectedTaskNode, Mode=TwoWay}"
|
|
dd:DragDrop.IsDragSource="True"
|
|
dd:DragDrop.IsDropTarget="True"
|
|
dd:DragDrop.DropHandler="{x:Static local:GearTaskDragDropHandler.Instance}"
|
|
dd:DragDrop.UseDefaultDragAdorner="True"
|
|
dd:DragDrop.UseDefaultEffectDataTemplate="True"
|
|
ContextMenu="{StaticResource TaskNodeContextMenu}"
|
|
Visibility="{Binding SelectedTaskDefinition, Converter={StaticResource NullToVisibilityConverter}}">
|
|
<ui:TreeListView.ItemContainerStyle>
|
|
<Style TargetType="ui:TreeListViewItem" BasedOn="{StaticResource DefaultTreeListViewItemStyle}">
|
|
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
|
|
</Style>
|
|
</ui:TreeListView.ItemContainerStyle>
|
|
<ui:TreeListView.Columns>
|
|
<GridViewColumnCollection>
|
|
<ui:GridViewColumn Width="{Binding ActualWidth, ElementName=TreeColumnName}" Header="任务名称">
|
|
<ui:GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<ui:TreeRowExpander Content="{Binding Name}">
|
|
</ui:TreeRowExpander>
|
|
</DataTemplate>
|
|
</ui:GridViewColumn.CellTemplate>
|
|
</ui:GridViewColumn>
|
|
<ui:GridViewColumn Width="{Binding ActualWidth, ElementName=TreeColumnType}" Header="任务类型">
|
|
<ui:GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<ui:TextBlock Text="{Binding TaskType}"
|
|
VerticalAlignment="Center"
|
|
Visibility="{Binding IsDirectory, Converter={StaticResource BooleanToVisibilityRevertConverter}}" />
|
|
</DataTemplate>
|
|
</ui:GridViewColumn.CellTemplate>
|
|
</ui:GridViewColumn>
|
|
<ui:GridViewColumn Width="{Binding ActualWidth, ElementName=TreeColumnEnabled}" Header="启用">
|
|
<ui:GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<CheckBox IsChecked="{Binding IsEnabled}"
|
|
HorizontalAlignment="Center"
|
|
VerticalAlignment="Center" />
|
|
</DataTemplate>
|
|
</ui:GridViewColumn.CellTemplate>
|
|
</ui:GridViewColumn>
|
|
<ui:GridViewColumn Width="{Binding ActualWidth, ElementName=TreeColumnActions}" Header="操作">
|
|
<ui:GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
|
<ui:Button Command="{Binding DataContext.DeleteTaskNodeCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
|
CommandParameter="{Binding}"
|
|
Icon="{ui:SymbolIcon Delete24}"
|
|
Appearance="Transparent"
|
|
Padding="4"
|
|
ToolTip="删除" />
|
|
</StackPanel>
|
|
</DataTemplate>
|
|
</ui:GridViewColumn.CellTemplate>
|
|
</ui:GridViewColumn>
|
|
</GridViewColumnCollection>
|
|
</ui:TreeListView.Columns>
|
|
<ui:TreeListView.ItemTemplate>
|
|
<HierarchicalDataTemplate ItemsSource="{Binding Children}" />
|
|
</ui:TreeListView.ItemTemplate>
|
|
</ui:TreeListView>
|
|
|
|
<!-- 无选中任务定义时的提示 -->
|
|
<StackPanel HorizontalAlignment="Center"
|
|
VerticalAlignment="Center"
|
|
Visibility="{Binding SelectedTaskDefinition, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Invert}">
|
|
<ui:SymbolIcon Symbol="Settings24" FontSize="48" Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
|
<TextBlock Text="请选择一个任务定义进行配置"
|
|
FontSize="16"
|
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
|
HorizontalAlignment="Center"
|
|
Margin="0,16,0,0" />
|
|
</StackPanel>
|
|
</Grid>
|
|
</ui:Border>
|
|
</Grid>
|
|
</Grid>
|
|
</UserControl>
|