气泡测量面板: 界面风格现代化、按钮统一到工具栏、初始工具同步修复
This commit is contained in:
@@ -3,104 +3,116 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Title="气泡测量工具"
|
Title="气泡测量工具"
|
||||||
Width="260" Height="340"
|
Width="340" Height="380"
|
||||||
ResizeMode="NoResize"
|
ResizeMode="NoResize"
|
||||||
WindowStartupLocation="CenterOwner"
|
WindowStartupLocation="CenterOwner"
|
||||||
Topmost="True"
|
Topmost="True" ShowInTaskbar="False"
|
||||||
ShowInTaskbar="False">
|
Background="#F5F5F5" FontFamily="Microsoft YaHei UI">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<Style x:Key="ToolToggleStyle" TargetType="RadioButton">
|
<Style x:Key="IconBtnStyle" TargetType="ButtonBase">
|
||||||
|
<Setter Property="Cursor" Value="Hand" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="RadioButton">
|
<ControlTemplate TargetType="ButtonBase">
|
||||||
<Border x:Name="Bd" Background="#EEEEEE" BorderBrush="#CCCCCC"
|
<Border x:Name="Bd" Background="#FFFFFF" BorderBrush="#E0E0E0"
|
||||||
BorderThickness="1" CornerRadius="3" Padding="10,4" Cursor="Hand">
|
BorderThickness="1" CornerRadius="6" Padding="8,6">
|
||||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
</Border>
|
</Border>
|
||||||
<ControlTemplate.Triggers>
|
<ControlTemplate.Triggers>
|
||||||
<Trigger Property="IsChecked" Value="True">
|
|
||||||
<Setter TargetName="Bd" Property="Background" Value="#0078D7" />
|
|
||||||
<Setter TargetName="Bd" Property="BorderBrush" Value="#005A9E" />
|
|
||||||
<Setter Property="Foreground" Value="White" />
|
|
||||||
</Trigger>
|
|
||||||
<Trigger Property="IsMouseOver" Value="True">
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
<Setter TargetName="Bd" Property="Background" Value="#DDDDDD" />
|
<Setter TargetName="Bd" Property="Background" Value="#EAF2FB" />
|
||||||
|
<Setter TargetName="Bd" Property="BorderBrush" Value="#B0D4F1" />
|
||||||
</Trigger>
|
</Trigger>
|
||||||
<MultiTrigger>
|
<DataTrigger Binding="{Binding IsChecked, RelativeSource={RelativeSource Self}}" Value="True">
|
||||||
<MultiTrigger.Conditions>
|
<Setter TargetName="Bd" Property="Background" Value="#005FB8" />
|
||||||
<Condition Property="IsMouseOver" Value="True" />
|
<Setter TargetName="Bd" Property="BorderBrush" Value="#004C99" />
|
||||||
<Condition Property="IsChecked" Value="True" />
|
</DataTrigger>
|
||||||
</MultiTrigger.Conditions>
|
|
||||||
<Setter TargetName="Bd" Property="Background" Value="#006CBE" />
|
|
||||||
</MultiTrigger>
|
|
||||||
</ControlTemplate.Triggers>
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style x:Key="CardStyle" TargetType="Border">
|
||||||
|
<Setter Property="Background" Value="White" />
|
||||||
|
<Setter Property="BorderBrush" Value="#E8E8E8" />
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
<Setter Property="CornerRadius" Value="8" />
|
||||||
|
<Setter Property="Padding" Value="12,10" />
|
||||||
|
<Setter Property="Margin" Value="0,0,0,8" />
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="ParamLabel" TargetType="TextBlock">
|
||||||
|
<Setter Property="FontSize" Value="11" />
|
||||||
|
<Setter Property="Foreground" Value="#555" />
|
||||||
|
<Setter Property="Margin" Value="0,0,0,3" />
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="TextBox">
|
||||||
|
<Setter Property="BorderBrush" Value="#D0D0D0" />
|
||||||
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
|
<Setter Property="Padding" Value="4,3" />
|
||||||
|
<Setter Property="FontSize" Value="11.5" />
|
||||||
|
<Style.Resources>
|
||||||
|
<Style TargetType="Border">
|
||||||
|
<Setter Property="CornerRadius" Value="4" />
|
||||||
|
</Style>
|
||||||
|
</Style.Resources>
|
||||||
|
</Style>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<StackPanel Margin="10">
|
<StackPanel Margin="10">
|
||||||
<!-- 工具选择 -->
|
<!-- 工具栏:工具选择 + 撤销/清除/完成 -->
|
||||||
<TextBlock Text="工具" FontWeight="SemiBold" Margin="0,0,0,4" />
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
|
||||||
<WrapPanel>
|
<RadioButton x:Name="RbRoi" IsChecked="True" Style="{StaticResource IconBtnStyle}" ToolTip="ROI" Margin="0,0,4,0">
|
||||||
<RadioButton x:Name="RbRoi" IsChecked="True" Margin="0,0,4,4"
|
|
||||||
ToolTip="ROI" Style="{StaticResource ToolToggleStyle}">
|
|
||||||
<Image Source="/Assets/Icons/rectangle32.png" Width="20" Height="20" />
|
<Image Source="/Assets/Icons/rectangle32.png" Width="20" Height="20" />
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton x:Name="RbWand" Margin="0,0,4,4"
|
<RadioButton x:Name="RbWand" Style="{StaticResource IconBtnStyle}" ToolTip="魔棒" Margin="0,0,4,0">
|
||||||
ToolTip="魔棒" Style="{StaticResource ToolToggleStyle}">
|
|
||||||
<Image Source="/Assets/Icons/magic32.png" Width="20" Height="20" />
|
<Image Source="/Assets/Icons/magic32.png" Width="20" Height="20" />
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton x:Name="RbBrush" Margin="0,0,4,4"
|
<RadioButton x:Name="RbBrush" Style="{StaticResource IconBtnStyle}" ToolTip="画笔" Margin="0,0,4,0">
|
||||||
ToolTip="画笔" Style="{StaticResource ToolToggleStyle}">
|
|
||||||
<Image Source="/Assets/Icons/brush32.png" Width="20" Height="20" />
|
<Image Source="/Assets/Icons/brush32.png" Width="20" Height="20" />
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton x:Name="RbEraser" Margin="0,0,0,4"
|
<RadioButton x:Name="RbEraser" Style="{StaticResource IconBtnStyle}" ToolTip="橡皮擦" Margin="0,0,10,0">
|
||||||
ToolTip="橡皮擦" Style="{StaticResource ToolToggleStyle}">
|
|
||||||
<Image Source="/Assets/Icons/eraser32.png" Width="20" Height="20" />
|
<Image Source="/Assets/Icons/eraser32.png" Width="20" Height="20" />
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
</WrapPanel>
|
<Button Style="{StaticResource IconBtnStyle}" ToolTip="撤销" Click="Undo_Click" Margin="0,0,4,0">
|
||||||
|
|
||||||
<Separator Margin="0,6" />
|
|
||||||
|
|
||||||
<!-- 阈值 -->
|
|
||||||
<TextBlock Text="灰度阈值(与点击点的最大灰度差)" Margin="0,0,0,4" FontSize="11" Foreground="Gray" />
|
|
||||||
<DockPanel>
|
|
||||||
<TextBox x:Name="TbThreshold" DockPanel.Dock="Right" Width="45" Text="30"
|
|
||||||
VerticalContentAlignment="Center" Margin="6,0,0,0" />
|
|
||||||
<Slider x:Name="SliderThreshold" Minimum="0" Maximum="60" Value="30"
|
|
||||||
VerticalAlignment="Center" />
|
|
||||||
</DockPanel>
|
|
||||||
|
|
||||||
<!-- 画笔大小 -->
|
|
||||||
<TextBlock Text="画笔/橡皮大小" Margin="0,8,0,4" />
|
|
||||||
<DockPanel>
|
|
||||||
<TextBox x:Name="TbBrushSize" DockPanel.Dock="Right" Width="45" Text="5"
|
|
||||||
VerticalContentAlignment="Center" Margin="6,0,0,0" />
|
|
||||||
<Slider x:Name="SliderBrushSize" Minimum="1" Maximum="30" Value="5"
|
|
||||||
VerticalAlignment="Center" />
|
|
||||||
</DockPanel>
|
|
||||||
|
|
||||||
<Separator Margin="0,8" />
|
|
||||||
|
|
||||||
<!-- 结果 -->
|
|
||||||
<TextBlock Text="测量结果" FontWeight="SemiBold" Margin="0,0,0,4" />
|
|
||||||
<TextBlock x:Name="TbResult" Text="空隙率: --" FontSize="14" Margin="0,0,0,4" />
|
|
||||||
<DockPanel Margin="0,0,0,8">
|
|
||||||
<TextBlock Text="VoidLimit(%):" VerticalAlignment="Center" />
|
|
||||||
<TextBox x:Name="TbVoidLimit" Width="50" Text="25.0" Margin="6,0,0,0"
|
|
||||||
VerticalContentAlignment="Center" />
|
|
||||||
</DockPanel>
|
|
||||||
|
|
||||||
<!-- 操作按钮 -->
|
|
||||||
<WrapPanel HorizontalAlignment="Center">
|
|
||||||
<Button Padding="8,4" Margin="0,0,8,0" ToolTip="撤销" Click="Undo_Click">
|
|
||||||
<Image Source="/Assets/Icons/Undo.png" Width="20" Height="20" />
|
<Image Source="/Assets/Icons/Undo.png" Width="20" Height="20" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button Padding="8,4" Margin="0,0,8,0" ToolTip="清除标记" Click="ClearMask_Click">
|
<Button Style="{StaticResource IconBtnStyle}" ToolTip="清除标记" Click="ClearMask_Click" Margin="0,0,4,0">
|
||||||
<Image Source="/Assets/Icons/Clear.png" Width="20" Height="20" />
|
<Image Source="/Assets/Icons/Clear.png" Width="20" Height="20" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button Content="OK" Padding="12,4" Click="Finish_Click" />
|
<Button Style="{StaticResource IconBtnStyle}" ToolTip="完成" Click="Finish_Click">
|
||||||
</WrapPanel>
|
<Image Source="/Assets/Icons/ok.png" Width="20" Height="20" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- 参数卡片 -->
|
||||||
|
<Border Style="{StaticResource CardStyle}">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock Text="灰度阈值(与点击点的最大灰度差)" Style="{StaticResource ParamLabel}" />
|
||||||
|
<DockPanel Margin="0,0,0,8">
|
||||||
|
<TextBox x:Name="TbThreshold" DockPanel.Dock="Right" Width="50" Text="30"
|
||||||
|
VerticalContentAlignment="Center" Margin="6,0,0,0" />
|
||||||
|
<Slider x:Name="SliderThreshold" Minimum="0" Maximum="60" Value="30"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</DockPanel>
|
||||||
|
<TextBlock Text="画笔/橡皮大小" Style="{StaticResource ParamLabel}" />
|
||||||
|
<DockPanel>
|
||||||
|
<TextBox x:Name="TbBrushSize" DockPanel.Dock="Right" Width="50" Text="5"
|
||||||
|
VerticalContentAlignment="Center" Margin="6,0,0,0" />
|
||||||
|
<Slider x:Name="SliderBrushSize" Minimum="1" Maximum="30" Value="5"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</DockPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<!-- 结果卡片 -->
|
||||||
|
<Border Style="{StaticResource CardStyle}">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock x:Name="TbResult" Text="空隙率: --" FontSize="13" FontWeight="SemiBold" Foreground="#333" Margin="0,0,0,6" />
|
||||||
|
<DockPanel>
|
||||||
|
<TextBlock Text="VoidLimit(%):" VerticalAlignment="Center" Style="{StaticResource ParamLabel}" />
|
||||||
|
<TextBox x:Name="TbVoidLimit" Width="50" Text="25.0" Margin="6,0,0,0"
|
||||||
|
VerticalContentAlignment="Center" />
|
||||||
|
</DockPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ namespace XplorePlane.Views.ImageProcessing
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 初始同步:确保面板默认值推送到 canvas
|
// 初始同步:确保面板默认值推送到 canvas
|
||||||
|
_canvas?.SetBubbleTool(PolygonRoiCanvas.BubbleSubTool.Roi);
|
||||||
_canvas?.SetBubbleThreshold((int)SliderThreshold.Value);
|
_canvas?.SetBubbleThreshold((int)SliderThreshold.Value);
|
||||||
_canvas?.SetBubbleBrushSize((int)SliderBrushSize.Value);
|
_canvas?.SetBubbleBrushSize((int)SliderBrushSize.Value);
|
||||||
if (double.TryParse(TbVoidLimit.Text, out double initLimit))
|
if (double.TryParse(TbVoidLimit.Text, out double initLimit))
|
||||||
|
|||||||
Reference in New Issue
Block a user