导航相机参数设置UI优化
This commit is contained in:
@@ -2,56 +2,149 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="相机参数设置"
|
||||
Width="320" Height="420"
|
||||
Width="340" Height="440"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False">
|
||||
<StackPanel Margin="15">
|
||||
|
||||
<TextBlock Text="曝光时间 (µs)" FontSize="11" Foreground="#666" Margin="0,0,0,2" />
|
||||
<DockPanel Margin="0,0,0,10">
|
||||
<Button DockPanel.Dock="Right" Content="设置" Width="45" Height="26" FontSize="11"
|
||||
Margin="6,0,0,0" Command="{Binding ApplyExposureCommand}" />
|
||||
<TextBox Text="{Binding ExposureTime, UpdateSourceTrigger=PropertyChanged}"
|
||||
Height="26" FontSize="12" VerticalContentAlignment="Center" Padding="4,0" />
|
||||
ResizeMode="NoResize" ShowInTaskbar="False"
|
||||
Background="#F5F5F5" FontFamily="Microsoft YaHei UI">
|
||||
<Window.Resources>
|
||||
<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>
|
||||
<StackPanel Margin="12">
|
||||
<!-- 曝光和增益 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="曝光时间 (µs)" Style="{StaticResource ParamLabel}" />
|
||||
<DockPanel Margin="0,0,0,8">
|
||||
<TextBox DockPanel.Dock="Right" Width="65"
|
||||
Text="{Binding ExposureTime, UpdateSourceTrigger=PropertyChanged}"
|
||||
VerticalContentAlignment="Center" Margin="6,0,0,0" />
|
||||
<Slider Minimum="10" Maximum="1000000" Value="{Binding ExposureTime}"
|
||||
VerticalAlignment="Center" />
|
||||
</DockPanel>
|
||||
|
||||
<TextBlock Text="增益" FontSize="11" Foreground="#666" Margin="0,0,0,2" />
|
||||
<DockPanel Margin="0,0,0,10">
|
||||
<Button DockPanel.Dock="Right" Content="设置" Width="45" Height="26" FontSize="11"
|
||||
Margin="6,0,0,0" Command="{Binding ApplyGainCommand}" />
|
||||
<TextBox Text="{Binding GainValue, UpdateSourceTrigger=PropertyChanged}"
|
||||
Height="26" FontSize="12" VerticalContentAlignment="Center" Padding="4,0" />
|
||||
<TextBlock Text="增益" Style="{StaticResource ParamLabel}" />
|
||||
<DockPanel>
|
||||
<TextBox DockPanel.Dock="Right" Width="65"
|
||||
Text="{Binding GainValue, UpdateSourceTrigger=PropertyChanged}"
|
||||
VerticalContentAlignment="Center" Margin="6,0,0,0" />
|
||||
<Slider Minimum="0" Maximum="24" Value="{Binding GainValue}"
|
||||
SmallChange="0.1" LargeChange="1" VerticalAlignment="Center" />
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<TextBlock Text="图像宽度 (px)" FontSize="11" Foreground="#666" Margin="0,0,0,2" />
|
||||
<DockPanel Margin="0,0,0,10">
|
||||
<Button DockPanel.Dock="Right" Content="设置" Width="45" Height="26" FontSize="11"
|
||||
Margin="6,0,0,0" Command="{Binding ApplyWidthCommand}" />
|
||||
<TextBox Text="{Binding ImageWidth, UpdateSourceTrigger=PropertyChanged}"
|
||||
Height="26" FontSize="12" VerticalContentAlignment="Center" Padding="4,0" />
|
||||
<!-- 分辨率 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="图像宽度 (px)" Style="{StaticResource ParamLabel}" />
|
||||
<DockPanel Margin="0,0,0,8">
|
||||
<TextBox DockPanel.Dock="Right" Width="65"
|
||||
Text="{Binding ImageWidth, UpdateSourceTrigger=PropertyChanged}"
|
||||
VerticalContentAlignment="Center" Margin="6,0,0,0" />
|
||||
<Slider Minimum="64" Maximum="8192" Value="{Binding ImageWidth}"
|
||||
SmallChange="1" LargeChange="100" VerticalAlignment="Center" />
|
||||
</DockPanel>
|
||||
|
||||
<TextBlock Text="图像高度 (px)" FontSize="11" Foreground="#666" Margin="0,0,0,2" />
|
||||
<DockPanel Margin="0,0,0,10">
|
||||
<Button DockPanel.Dock="Right" Content="设置" Width="45" Height="26" FontSize="11"
|
||||
Margin="6,0,0,0" Command="{Binding ApplyHeightCommand}" />
|
||||
<TextBox Text="{Binding ImageHeight, UpdateSourceTrigger=PropertyChanged}"
|
||||
Height="26" FontSize="12" VerticalContentAlignment="Center" Padding="4,0" />
|
||||
<TextBlock Text="图像高度 (px)" Style="{StaticResource ParamLabel}" />
|
||||
<DockPanel>
|
||||
<TextBox DockPanel.Dock="Right" Width="65"
|
||||
Text="{Binding ImageHeight, UpdateSourceTrigger=PropertyChanged}"
|
||||
VerticalContentAlignment="Center" Margin="6,0,0,0" />
|
||||
<Slider Minimum="64" Maximum="8192" Value="{Binding ImageHeight}"
|
||||
SmallChange="1" LargeChange="100" VerticalAlignment="Center" />
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<TextBlock Text="像素格式" FontSize="11" Foreground="#666" Margin="0,0,0,2" />
|
||||
<DockPanel Margin="0,0,0,10">
|
||||
<Button DockPanel.Dock="Right" Content="设置" Width="45" Height="26" FontSize="11"
|
||||
Margin="6,0,0,0" Command="{Binding ApplyPixelFormatCommand}" />
|
||||
<!-- 像素格式 -->
|
||||
<Border Style="{StaticResource CardStyle}">
|
||||
<StackPanel>
|
||||
<TextBlock Text="像素格式" Style="{StaticResource ParamLabel}" />
|
||||
<ComboBox SelectedItem="{Binding SelectedPixelFormat}"
|
||||
ItemsSource="{Binding PixelFormatOptions}"
|
||||
Height="26" FontSize="12" VerticalContentAlignment="Center" />
|
||||
</DockPanel>
|
||||
Height="28" FontSize="11.5" VerticalContentAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Rectangle Height="1" Fill="#E0E0E0" Margin="0,2,0,10" />
|
||||
|
||||
<Button Content="读取当前参数" Height="30" FontSize="12"
|
||||
Command="{Binding RefreshCameraParamsCommand}" />
|
||||
<!-- 操作按钮 -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,4,0,0">
|
||||
<Button Content="应用设置" Padding="20,6" FontSize="12" Cursor="Hand" Click="ApplyAll_Click">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Background" Value="#005FB8" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="Bd" Background="{TemplateBinding Background}"
|
||||
CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="#1A6FC4" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="#004C99" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Content="读取参数" Padding="20,6" FontSize="12" Cursor="Hand" Margin="8,0,0,0"
|
||||
Command="{Binding RefreshCameraParamsCommand}">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Background" Value="White" />
|
||||
<Setter Property="Foreground" Value="#333" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="Bd" Background="{TemplateBinding Background}"
|
||||
BorderBrush="#E0E0E0" BorderThickness="1"
|
||||
CornerRadius="6" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="#EAF2FB" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="#CCE8FF" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace XplorePlane.Views
|
||||
{
|
||||
@@ -9,5 +10,24 @@ namespace XplorePlane.Views
|
||||
InitializeComponent();
|
||||
DataContext = viewModel;
|
||||
}
|
||||
|
||||
private void ApplyAll_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dc = DataContext;
|
||||
if (dc == null) return;
|
||||
var type = dc.GetType();
|
||||
ExecuteCommand(type, dc, "ApplyExposureCommand");
|
||||
ExecuteCommand(type, dc, "ApplyGainCommand");
|
||||
ExecuteCommand(type, dc, "ApplyWidthCommand");
|
||||
ExecuteCommand(type, dc, "ApplyHeightCommand");
|
||||
ExecuteCommand(type, dc, "ApplyPixelFormatCommand");
|
||||
}
|
||||
|
||||
private static void ExecuteCommand(System.Type type, object dc, string cmdName)
|
||||
{
|
||||
var prop = type.GetProperty(cmdName);
|
||||
if (prop?.GetValue(dc) is ICommand cmd && cmd.CanExecute(null))
|
||||
cmd.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user