Dispenser/DispenserUI/Views/Windows/CameraViewerWindow.axaml

371 lines
22 KiB
XML

<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:components="clr-namespace:DispenserUI.ViewModels.Components"
xmlns:converter="clr-namespace:DispenserUI.ViewModels.Converter"
xmlns:controls="clr-namespace:DispenserUI.Views.Controls"
xmlns:anim="https://github.com/whistyun/AnimatedImage.Avalonia"
Width="1750"
Height="900"
CornerRadius="0"
TransparencyLevelHint="AcrylicBlur"
Background="Transparent"
WindowStartupLocation="CenterScreen"
x:DataType="components:CameraViewerVM"
Icon="/Assets/UI/camera.png"
x:Class="DispenserUI.Views.Windows.CameraViewerWindow"
Title="相机预览">
<Window.Resources>
<converter:BoolConverter x:Key="BoolConverter" />
<converter:EqualsConverter x:Key="EqualsConverter" />
</Window.Resources>
<Grid x:Name="Body" ColumnDefinitions="*,340">
<Grid Grid.Column="0" RowDefinitions="50,*,50">
<Grid Row="0" ColumnDefinitions="*,300" Background="#171717">
<Grid Column="0" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Button
Command="{Binding ToggleCaptureVideo}"
IsVisible="{Binding CapturingVideo,Converter={StaticResource BoolConverter},ConverterParameter='false'}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/cycle_white.png" Width="25" Height="25"
ToolTip.Tip="连续采集"
VerticalAlignment="Center" />
</Button>
<Button
Command="{Binding ToggleCaptureVideo}"
IsVisible="{Binding CapturingVideo,Converter={StaticResource BoolConverter},ConverterParameter='true'}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image
anim:ImageBehavior.AnimatedSource="avares://DispenserUI/Assets/UI/capturing_rainbow.gif"
Width="25" Height="25"
ToolTip.Tip="停止采集"
VerticalAlignment="Center" />
</Button>
<Button
Command="{Binding ToCapturePhoto}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/cycle_1_white.png" Width="25" Height="25"
ToolTip.Tip="单张采集"
VerticalAlignment="Center" />
</Button>
<Button
Command="{Binding ToSavePhoto}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/camera_white.png" Width="25" Height="25"
ToolTip.Tip="保存图片"
VerticalAlignment="Center" />
</Button>
<Button
IsVisible="{Binding RecordingVideo,Converter={StaticResource BoolConverter},ConverterParameter='False'}"
Command="{Binding ToToggleRecordingVideo}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/video_white.png" Width="25" Height="25"
ToolTip.Tip="录制视频"
VerticalAlignment="Center" />
</Button>
<Button
IsVisible="{Binding RecordingVideo}"
Command="{Binding ToToggleRecordingVideo}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/video_red.png" Width="25" Height="25"
ToolTip.Tip="停止录制视频"
VerticalAlignment="Center" />
</Button>
<Button
IsVisible="{Binding ShowingCrosshair,Converter={StaticResource BoolConverter},ConverterParameter='false'}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
Command="{Binding ToggleShowCrosshair}"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/crosshair_white.png" Width="25" Height="25"
ToolTip.Tip="添加十字辅助线"
VerticalAlignment="Center" />
</Button>
<Button
IsVisible="{Binding ShowingCrosshair,Converter={StaticResource BoolConverter},ConverterParameter='true'}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
Command="{Binding ToggleShowCrosshair}"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/crosshair_red.png" Width="25" Height="25"
ToolTip.Tip="隐藏十字辅助线"
VerticalAlignment="Center" />
</Button>
<Button
IsVisible="{Binding ShowingGrid,Converter={StaticResource BoolConverter},ConverterParameter='false'}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/graid_white.png" Width="25" Height="25"
ToolTip.Tip="添加网格辅助线"
VerticalAlignment="Center" />
</Button>
<Button
IsVisible="{Binding ShowingGrid,Converter={StaticResource BoolConverter},ConverterParameter='true'}"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/graid_red.png" Width="25" Height="25"
ToolTip.Tip="隐藏网格辅助线"
VerticalAlignment="Center" />
</Button>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,0,0">
<TextBlock Text="微调步距" VerticalAlignment="Center" Width="60"
Foreground="White" />
<Image Source="/Assets/UI/question_white.png" Width="20" Height="20" Cursor="Hand"
VerticalAlignment="Center" Margin="2,0,0,0"
ToolTip.Tip="微调步距: 每次点击单位移动距离,单位毫米" />
<NumericUpDown
Value="{Binding TuningStep,Mode=TwoWay}"
Width="50"
Minimum="1"
Maximum="100"
ShowButtonSpinner="False"
FormatString="F0"
Margin="10,0,0,0"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
<TextBlock Text="mm" VerticalAlignment="Center" Foreground="White" Margin="1,0,0,0"
FontSize="14" />
</StackPanel>
</StackPanel>
</Grid>
<Grid Column="1">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
<Button
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
Tapped="OnNarrowClicked"
VerticalContentAlignment="Center"
HorizontalContentAlignment="Right">
<Image Source="/Assets/UI/zoom_out_white.png" Width="25" Height="25"
ToolTip.Tip="图像缩小"
VerticalAlignment="Center" />
</Button>
<TextBlock Text="{Binding ScaleRatio}" Margin="10,0,10,0" FontSize="12" Foreground="White"
VerticalAlignment="Center" />
<Button
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
Tapped="OnEnlargeClicked"
VerticalContentAlignment="Center"
HorizontalAlignment="Right"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/zoom_in_white.png" Width="25" Height="25"
ToolTip.Tip="图像放大"
VerticalAlignment="Center" />
</Button>
<Button
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
IsVisible="{Binding StretchIndex,Converter={StaticResource EqualsConverter},ConverterParameter='0'}"
Command="{Binding ToChangeStretch}"
VerticalContentAlignment="Center"
HorizontalAlignment="Right"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/1_1_white.png" Width="25" Height="25"
ToolTip.Tip="1:1显示"
VerticalAlignment="Center" />
</Button>
<Button
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
IsVisible="{Binding StretchIndex,Converter={StaticResource EqualsConverter},ConverterParameter='1'}"
Command="{Binding ToChangeStretch}"
VerticalContentAlignment="Center"
HorizontalAlignment="Right"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/stretch_uniform.png" Width="25" Height="25"
ToolTip.Tip="保持宽高比"
VerticalAlignment="Center" />
</Button>
<Button
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
IsVisible="{Binding StretchIndex,Converter={StaticResource EqualsConverter},ConverterParameter='2'}"
Command="{Binding ToChangeStretch}"
VerticalContentAlignment="Center"
HorizontalAlignment="Right"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/stretch_uniform_fill.png" Width="25" Height="25"
ToolTip.Tip="填充屏幕"
VerticalAlignment="Center" />
</Button>
<Button
IsVisible="{Binding IsFullScreen}"
Margin="0,0,10,0"
BorderThickness="0"
Background="Transparent"
Width="50"
Height="50"
Cursor="Hand"
Tapped="OnNormalWindowClicked"
VerticalContentAlignment="Center"
HorizontalAlignment="Right"
HorizontalContentAlignment="Center">
<Image Source="/Assets/UI/recover_to_origin_white.png" Width="25" Height="25"
ToolTip.Tip="还原窗口大小"
VerticalAlignment="Center" />
</Button>
</StackPanel>
</Grid>
</Grid>
<controls:ImageViewer Grid.Row="1"
x:Name="Viewer"
Stretch="{Binding Stretch}"
ShowToolBar="False"
Background="White"
TuningStep="{Binding TuningStep}"
ShowingCrosshair="{Binding ShowingCrosshair}"
Source="{Binding CaptureImage}"
CenterPixelChanged="OnCenterPixelChanged"
ScaleRatioChanged="OnScaleRatioChanged"
PixelChanged="OnPixelChanged" />
<Grid Row="2" Height="50" Background="#171717" VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal" Margin="20,0,10,0">
<TextBlock Text="采集帧率: " VerticalAlignment="Center" Foreground="White" />
<TextBlock Text="{Binding AcquisitionFps,StringFormat='0.##'}" VerticalAlignment="Center"
Margin="10,0,0,0" Foreground="White" />
<TextBlock Text="fps" VerticalAlignment="Center" Foreground="White" />
</StackPanel>
<TextBlock Text=" | " VerticalAlignment="Center" Foreground="White" />
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<TextBlock Text="图像数: " VerticalAlignment="Center" Foreground="White" />
<TextBlock Text="{Binding ImageCount}" VerticalAlignment="Center" Margin="10,0,0,0"
Foreground="White" />
</StackPanel>
<TextBlock Text=" | " VerticalAlignment="Center" Foreground="White" />
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<TextBlock Text="带宽: " VerticalAlignment="Center" Foreground="White" />
<TextBlock Text="{Binding Bandwidth,StringFormat='F2'}" VerticalAlignment="Center"
Margin="10,0,0,0" Foreground="White" />
</StackPanel>
<TextBlock Text=" | " VerticalAlignment="Center" Foreground="White" />
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<TextBlock Text="图像尺寸: " VerticalAlignment="Center" Foreground="White" />
<TextBlock Text="{Binding OriginSize}" VerticalAlignment="Center" Margin="10,0,0,0"
Foreground="White" />
</StackPanel>
<TextBlock Text=" | " VerticalAlignment="Center" Foreground="White" />
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<TextBlock Text="像素坐标: " VerticalAlignment="Center" Foreground="White" />
<TextBlock Text="{Binding PixelCoordinate,StringFormat='F0'}" VerticalAlignment="Center"
Margin="10,0,0,0" Foreground="White" />
</StackPanel>
<TextBlock Text=" | " VerticalAlignment="Center" Foreground="White" />
<StackPanel Orientation="Horizontal" Margin="10,0,10,0">
<TextBlock Text="相机坐标: " VerticalAlignment="Center" Foreground="White" />
<TextBlock Text="{Binding CameraPositionX,StringFormat='F3'}" VerticalAlignment="Center"
Margin="10,0,0,0" Foreground="White" />
<TextBlock Text="*" VerticalAlignment="Center"
Margin="10,0,0,0" Foreground="White" />
<TextBlock Text="{Binding CameraPositionY,StringFormat='F3'}" VerticalAlignment="Center"
Margin="10,0,0,0" Foreground="White" />
</StackPanel>
<TextBlock Text=" | " VerticalAlignment="Center" Foreground="White" />
</StackPanel>
</Grid>
</Grid>
<Border Grid.Column="1" Padding="20" Background="White" BorderThickness="1" BorderBrush="Gray">
<ScrollViewer>
<StackPanel>
<controls:CameraParamsEditor x:Name="ParamsEditor" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="拍照位置" Width="80" VerticalAlignment="Center" HorizontalAlignment="Left" />
<Button Cursor="Hand" Command="{Binding ToMoveToWaferHeight}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Image Source="/Assets/UI/wafer.png" Width="28" Height="28" Stretch="Uniform" />
<TextBlock Text="晶环拍照位" Width="70" VerticalAlignment="Center" Margin="5,0,0,0" />
</StackPanel>
</Button>
<Button Command="{Binding ToMoveToSubstrateHeight}" Cursor="Hand" VerticalAlignment="Center"
Margin="20,0,0,0">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Image Source="/Assets/UI/substrate.png" Width="28" Height="28" Stretch="Uniform" />
<TextBlock Text="基板拍照位" Width="70" VerticalAlignment="Center" Margin="5,0,0,0" />
</StackPanel>
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock Text="移动电机" Width="80" VerticalAlignment="Center" HorizontalAlignment="Left" />
<Button Cursor="Hand" Command="{Binding ToMoveToCrosshairCenter}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Image Source="/Assets/UI/crosshair_black.png" Width="28" Height="28" Stretch="Uniform" />
<TextBlock Text="移动到中心点" Width="70" VerticalAlignment="Center" Margin="5,0,0,0" />
</StackPanel>
</Button>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Border>
</Grid>
</Window>