ui: 模板助手按钮布局与 Segoe MDL2 图标

- 单张与参数:顶行 ROI/训练/加载/保存,底部仅运行匹配;批量测试按钮同步图标与 ToolTip

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
李伟
2026-05-15 11:42:56 +08:00
parent e0eec42a2f
commit 9634e42396
@@ -3,9 +3,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="模板匹配助手"
Height="560"
Width="520"
Width="560"
FontFamily="Microsoft YaHei UI"
WindowStartupLocation="CenterOwner"
ResizeMode="CanResizeWithGrip">
<Window.Resources>
<Style x:Key="TmMdl2Glyph" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Segoe MDL2 Assets" />
<Setter Property="FontSize" Value="15" />
<Setter Property="Margin" Value="0,0,6,0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</Window.Resources>
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -23,22 +32,58 @@
<TabItem Header="单张与参数">
<Grid Margin="0,8,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
<StackPanel>
<Button
Margin="0,0,0,4"
Padding="8,4"
Command="{Binding SelectTemplateRoiCommand}"
Content="框选模板 ROI" />
<Button
Margin="0,0,0,8"
Padding="8,4"
Command="{Binding LearnFromRoiCommand}"
Content="从 ROI 训练模板" />
<StackPanel
Grid.Row="0"
Orientation="Horizontal"
Margin="0,0,0,8">
<Button
Margin="0,0,6,0"
Padding="8,4"
Command="{Binding SelectTemplateRoiCommand}"
ToolTip="在主视图上拖拽框选模板区域">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE7B8;" />
<TextBlock VerticalAlignment="Center" Text="框选模板 ROI" />
</StackPanel>
</Button>
<Button
Margin="0,0,6,0"
Padding="8,4"
Command="{Binding LearnFromRoiCommand}"
ToolTip="根据已框选的 ROI 学习模板">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE8AF;" />
<TextBlock VerticalAlignment="Center" Text="从 ROI 训练模板" />
</StackPanel>
</Button>
<Button
Margin="0,0,6,0"
Padding="8,4"
Command="{Binding LoadModelCommand}"
ToolTip="从磁盘加载已保存的模板模型">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE8E5;" />
<TextBlock VerticalAlignment="Center" Text="加载模型" />
</StackPanel>
</Button>
<Button
Padding="8,4"
Command="{Binding SaveModelCommand}"
ToolTip="将当前模板保存为模型文件">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE74E;" />
<TextBlock VerticalAlignment="Center" Text="保存模型" />
</StackPanel>
</Button>
</StackPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel>
<Grid Margin="0,4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="132" />
@@ -179,13 +224,19 @@
</ScrollViewer>
<StackPanel
Grid.Row="1"
Grid.Row="2"
Orientation="Horizontal"
HorizontalAlignment="Right"
Margin="0,10,0,0">
<Button Margin="0,0,8,0" Padding="10,4" Command="{Binding LoadModelCommand}" Content="加载模型" />
<Button Margin="0,0,8,0" Padding="10,4" Command="{Binding SaveModelCommand}" Content="保存模型" />
<Button Padding="10,4" Command="{Binding RunMatchCommand}" Content="运行匹配" />
<Button
Padding="10,4"
Command="{Binding RunMatchCommand}"
ToolTip="对主视图当前图像执行模板匹配">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE768;" />
<TextBlock VerticalAlignment="Center" Text="运行匹配" />
</StackPanel>
</Button>
</StackPanel>
</Grid>
</TabItem>
@@ -213,22 +264,42 @@
<Button
Padding="10,4"
Margin="0,0,8,0"
Content="选择文件夹…"
Command="{Binding PickFolderCommand}" />
Command="{Binding PickFolderCommand}"
ToolTip="选择包含待测图像的文件夹(仅当前层级)">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE838;" />
<TextBlock VerticalAlignment="Center" Text="选择文件夹…" />
</StackPanel>
</Button>
<Button
Padding="10,4"
Margin="0,0,8,0"
Content="开始批量匹配"
Command="{Binding StartBatchCommand}" />
Command="{Binding StartBatchCommand}"
ToolTip="对文件夹内图像依次执行模板匹配">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE768;" />
<TextBlock VerticalAlignment="Center" Text="开始批量匹配" />
</StackPanel>
</Button>
<Button
Padding="10,4"
Margin="0,0,8,0"
Content="停止"
Command="{Binding StopBatchCommand}" />
Command="{Binding StopBatchCommand}"
ToolTip="停止当前批量任务">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE71A;" />
<TextBlock VerticalAlignment="Center" Text="停止" />
</StackPanel>
</Button>
<Button
Padding="10,4"
Content="在主视图打开所选"
Command="{Binding OpenSelectedInMainViewportCommand}" />
Command="{Binding OpenSelectedInMainViewportCommand}"
ToolTip="将表格当前选中行对应图像在主视图中打开并显示匹配结果">
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TmMdl2Glyph}" Text="&#xE944;" />
<TextBlock VerticalAlignment="Center" Text="在主视图打开所选" />
</StackPanel>
</Button>
</StackPanel>
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="8,0,0,0">
<TextBlock Foreground="Gray" FontSize="11" Text="{Binding ImageFileCount, StringFormat={}{0} 个图像文件}" />