124 lines
6.5 KiB
XML
124 lines
6.5 KiB
XML
<UserControl x:Class="BOB.Views.StepsManager"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:dd="urn:gong-wpf-dragdrop"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
|
xmlns:local="clr-namespace:BOB.Views"
|
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
|
xmlns:prism="http://prismlibrary.com/"
|
|
prism:ViewModelLocator.AutoWireViewModel="True"
|
|
d:DesignHeight="450"
|
|
d:DesignWidth="800"
|
|
mc:Ignorable="d">
|
|
<Grid>
|
|
<GroupBox Header="{Binding Title}">
|
|
<DataGrid x:Name="ProgramDataGrid"
|
|
AutoGenerateColumns="False"
|
|
Background="Transparent"
|
|
CanUserAddRows="False"
|
|
CanUserSortColumns="False"
|
|
ItemsSource="{Binding Program.StepCollection}"
|
|
SelectedItem="{Binding SelectedStep, Mode=TwoWay}"
|
|
SelectionMode="Extended"
|
|
SelectionUnit="FullRow">
|
|
|
|
<!-- 行样式 -->
|
|
<DataGrid.RowStyle>
|
|
<Style TargetType="DataGridRow">
|
|
<Setter Property="Background"
|
|
Value="Transparent" />
|
|
<Setter Property="Foreground"
|
|
Value="Black" />
|
|
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding Result}"
|
|
Value="0">
|
|
<Setter Property="Background"
|
|
Value="DodgerBlue" />
|
|
<Setter Property="Foreground"
|
|
Value="White" />
|
|
</DataTrigger>
|
|
|
|
<DataTrigger Binding="{Binding Result}"
|
|
Value="1">
|
|
<Setter Property="Background"
|
|
Value="LimeGreen" />
|
|
<Setter Property="Foreground"
|
|
Value="White" />
|
|
</DataTrigger>
|
|
|
|
<DataTrigger Binding="{Binding Result}"
|
|
Value="2">
|
|
<Setter Property="Background"
|
|
Value="Red" />
|
|
<Setter Property="Foreground"
|
|
Value="White" />
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</DataGrid.RowStyle>
|
|
|
|
<!-- 列 -->
|
|
<DataGrid.Columns>
|
|
<DataGridCheckBoxColumn Width="58"
|
|
Binding="{Binding IsUsed, UpdateSourceTrigger=PropertyChanged}"
|
|
Header="启用" />
|
|
<DataGridTextColumn Binding="{Binding Index}"
|
|
Header="序号"
|
|
IsReadOnly="True" />
|
|
<DataGridTextColumn Binding="{Binding Name}"
|
|
Header="名称"
|
|
IsReadOnly="True" />
|
|
<DataGridTextColumn Binding="{Binding StepType}"
|
|
Header="类型"
|
|
IsReadOnly="True" />
|
|
<DataGridTextColumn Binding="{Binding Method.FullName}"
|
|
Header="指令类型"
|
|
IsReadOnly="True" />
|
|
<DataGridTextColumn Binding="{Binding Method.Name}"
|
|
Header="指令"
|
|
IsReadOnly="True" />
|
|
<DataGridTextColumn Binding="{Binding OKExpression}"
|
|
Header="合格条件"
|
|
IsReadOnly="True" />
|
|
<DataGridTextColumn Binding="{Binding RunTime}"
|
|
Header="耗时(ms)"
|
|
IsReadOnly="True" />
|
|
<DataGridTextColumn Binding="{Binding Result}"
|
|
Header="结果"
|
|
IsReadOnly="True" />
|
|
<DataGridTextColumn Binding="{Binding Description}"
|
|
Header="备注" />
|
|
</DataGrid.Columns>
|
|
|
|
<!-- ContextMenu MVVM化 -->
|
|
<DataGrid.ContextMenu>
|
|
<ContextMenu>
|
|
<MenuItem Header="编辑"
|
|
Command="{Binding DataContext.EditStepCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" />
|
|
<MenuItem Header="复制"
|
|
Command="{Binding DataContext.CopyStepCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" />
|
|
<MenuItem Header="粘贴"
|
|
Command="{Binding DataContext.PasteStepCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" />
|
|
<MenuItem Header="删除"
|
|
Foreground="Red"
|
|
Command="{Binding DataContext.DeleteStepCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" />
|
|
</ContextMenu>
|
|
</DataGrid.ContextMenu>
|
|
|
|
<!-- 键盘 删除键绑定 Delete 命令 -->
|
|
<i:Interaction.Triggers>
|
|
<i:EventTrigger EventName="PreviewKeyDown">
|
|
<i:InvokeCommandAction Command="{Binding DeleteStepCommand}"
|
|
CommandParameter="{Binding SelectedStep}"
|
|
PassEventArgsToCommand="True" />
|
|
</i:EventTrigger>
|
|
</i:Interaction.Triggers>
|
|
|
|
</DataGrid>
|
|
</GroupBox>
|
|
</Grid>
|
|
</UserControl>
|