123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446 |
- <UserControl x:Class="LampInspectionMachine.Views.CameraView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:LampInspectionMachine.Views"
- xmlns:Viewlocal="clr-namespace:LampInspectionMachine.ViewModels"
- xmlns:cognexWF1="clr-namespace:Cognex.VisionPro;assembly=Cognex.VisionPro.Controls"
- xmlns:prism="http://prismlibrary.com/"
- xmlns:valueConvert="clr-namespace:LampInspectionMachine.ValueConverters"
- prism:ViewModelLocator.AutoWireViewModel="True"
- mc:Ignorable="d"
- FontFamily="微软雅黑"
- FontSize="10"
- d:DesignHeight="800"
- d:DesignWidth="800"
- d:Background="White">
- <UserControl.Resources>
- <Style x:Key="buttonborder"
- TargetType="Border">
- <Setter Property="BorderThickness"
- Value="2" />
- <Setter Property="Background"
- Value="Transparent" />
- <Setter Property="VerticalAlignment"
- Value="Center" />
- <Setter Property="BorderBrush"
- Value="Transparent" />
- <Setter Property="CornerRadius"
- Value="5" />
- <Setter Property="Effect">
- <Setter.Value>
- <DropShadowEffect BlurRadius="10"
- Direction="1"
- ShadowDepth="0.5"
- Color="#2961AC" />
- </Setter.Value>
- </Setter>
- </Style>
- <Style TargetType="{x:Type TreeView}">
- <Setter Property="Background"
- Value="#F5F5F5" />
- <Setter Property="BorderBrush"
- Value="#CCCCCC" />
- <Setter Property="BorderThickness"
- Value="1" />
- <Setter Property="FontFamily"
- Value="Segoe UI" />
- <Setter Property="FontSize"
- Value="10" />
- <Setter Property="ItemContainerStyle">
- <Setter.Value>
- <Style TargetType="{x:Type TreeViewItem}">
- <Setter Property="Margin"
- Value="2" />
- <Setter Property="Padding"
- Value="5,3" />
- </Style>
- </Setter.Value>
- </Setter>
- </Style>
- <Style TargetType="{x:Type TreeViewItem}">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type TreeViewItem}">
- <StackPanel>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Image Grid.Column="0"
- Source="/Resources/folder.png"
- Width="16"
- Height="16" />
- <ContentPresenter Grid.Column="1"
- ContentSource="Header" />
- </Grid>
- <ItemsPresenter />
- </StackPanel>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Setter Property="Foreground"
- Value="#333333" />
- <Style.Triggers>
- <Trigger Property="IsMouseOver"
- Value="True">
- <Setter Property="Background"
- Value="#E3F2FD" />
- <Setter Property="Foreground"
- Value="#0D47A1" />
- </Trigger>
- <Trigger Property="IsSelected"
- Value="True">
- <Setter Property="Background"
- Value="#BBDEFB" />
- <Setter Property="Foreground"
- Value="#0D47A1" />
- </Trigger>
- </Style.Triggers>
- </Style>
- <!--ComboBox-->
- <!--ComBoBox项选中背景色-->
- <SolidColorBrush x:Key="ComboBoxSelectdBackground"
- Color="#ff8c69" />
- <!--ComBoBox项鼠标经过背景色-->
- <SolidColorBrush x:Key="ComboBoxMouseOverBackground"
- Color="#ff3030" />
- <!--ComBoBox项选中前景色-->
- <SolidColorBrush x:Key="ComboBoxSelectedForeground"
- Color="White" />
- <!--ComBoBox项鼠标经过前景色-->
- <SolidColorBrush x:Key="ComboBoxMouseOverForegrond"
- Color="White" />
- <ControlTemplate x:Key="ComboBoxToggleButton"
- TargetType="{x:Type ToggleButton}">
- <Grid Height="25"
- HorizontalAlignment="Stretch">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="30" />
- </Grid.ColumnDefinitions>
- <Border Background="White"
- Grid.ColumnSpan="2"
- Opacity="0" />
- <Path x:Name="Arrow"
- Grid.Column="1"
- Data="M 0 0 6 6 12 0 Z"
- VerticalAlignment="Center"
- HorizontalAlignment="Center"
- Stretch="None"
- Fill="#999" />
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="IsChecked"
- Value="true">
- <Setter TargetName="Arrow"
- Property="RenderTransform">
- <Setter.Value>
- <RotateTransform CenterX="6"
- CenterY="3"
- Angle="180"></RotateTransform>
- </Setter.Value>
- </Setter>
- <Setter TargetName="Arrow"
- Property="Margin"
- Value="0 0 0 2" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- <Style TargetType="{x:Type ComboBox}">
- <Setter Property="ItemContainerStyle">
- <Setter.Value>
- <Style TargetType="ComboBoxItem">
- <Setter Property="Height"
- Value="20" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ComboBoxItem}">
- <Grid Height="{TemplateBinding Height}"
- Width="{TemplateBinding Width}">
- <Border x:Name="_borderbg"
- Background="Transparent" />
- <TextBlock Margin="3 0 3 0"
- VerticalAlignment="Center"
- x:Name="_txt"
- Foreground="#333"
- Text="{Binding Content,RelativeSource={RelativeSource TemplatedParent}}" />
- <Border x:Name="_border"
- Background="White"
- Opacity="0" />
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="IsSelected"
- Value="true">
- <Setter TargetName="_borderbg"
- Property="Background"
- Value="{StaticResource ComboBoxSelectdBackground}" />
- <Setter TargetName="_txt"
- Property="Foreground"
- Value="{StaticResource ComboBoxSelectedForeground}" />
- </Trigger>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="IsSelected"
- Value="false" />
- <Condition Property="IsMouseOver"
- Value="true" />
- </MultiTrigger.Conditions>
- <Setter TargetName="_borderbg"
- Property="Background"
- Value="{StaticResource ComboBoxMouseOverBackground}" />
- <Setter TargetName="_txt"
- Property="Foreground"
- Value="{StaticResource ComboBoxMouseOverForegrond}" />
- </MultiTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </Setter.Value>
- </Setter>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ComboBox}">
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="0.7*" />
- <ColumnDefinition Width="0.3*"
- MaxWidth="30" />
- </Grid.ColumnDefinitions>
- <Border Grid.Column="0"
- Grid.ColumnSpan="2"
- BorderThickness="1"
- BorderBrush="{TemplateBinding BorderBrush}"
- CornerRadius="1,0,0,1" />
- <ContentPresenter HorizontalAlignment="Left"
- Margin="3,3,0,3"
- x:Name="ContentSite"
- VerticalAlignment="Center"
- Content="{TemplateBinding SelectionBoxItem}"
- ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
- ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
- IsHitTestVisible="False" />
- <!--ToggleButton 已数据绑定到 ComboBox 本身以切换 IsDropDownOpen-->
- <ToggleButton Grid.Column="0"
- Grid.ColumnSpan="2"
- Template="{StaticResource ComboBoxToggleButton}"
- x:Name="ToggleButton"
- Focusable="false"
- IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
- ClickMode="Press" />
- <!--必须将 TextBox 命名为 PART_EditableTextBox,否则 ComboBox 将无法识别它-->
- <TextBox Visibility="Hidden"
- BorderThickness="0"
- Margin="2 0 0 0"
- x:Name="PART_EditableTextBox"
- VerticalAlignment="Center"
- Focusable="True"
- Background="Transparent"
- IsReadOnly="{TemplateBinding IsReadOnly}" />
- <!--Popup 可显示 ComboBox 中的项列表。IsOpen 已数据绑定到通过 ComboBoxToggleButton 来切换的 IsDropDownOpen-->
- <Popup IsOpen="{TemplateBinding IsDropDownOpen}"
- Placement="Bottom"
- x:Name="Popup"
- Focusable="False"
- AllowsTransparency="True"
- PopupAnimation="Slide">
- <Grid MaxHeight="150"
- MinWidth="{TemplateBinding ActualWidth}"
- x:Name="DropDown"
- SnapsToDevicePixels="True">
- <Border x:Name="DropDownBorder"
- BorderBrush="#e8e8e8"
- BorderThickness="1 0 1 1" />
- <ScrollViewer Margin="1"
- SnapsToDevicePixels="True"
- HorizontalScrollBarVisibility="Auto"
- VerticalScrollBarVisibility="Auto"
- CanContentScroll="True">
- <!--StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True-->
- <StackPanel IsItemsHost="True"
- KeyboardNavigation.DirectionalNavigation="Contained"
- Background="White" />
- </ScrollViewer>
- </Grid>
- </Popup>
- </Grid>
- <ControlTemplate.Triggers>
- <Trigger Property="IsEditable"
- Value="true">
- <Setter TargetName="PART_EditableTextBox"
- Property="Visibility"
- Value="Visible" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <valueConvert:EnumToBoolConverter x:Key="EnumToBoolConverter" />
- </UserControl.Resources>
- <Grid>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="Auto" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Grid>
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <StackPanel Grid.Row="0"
- Margin="50,15,0,0"
- Orientation="Horizontal"
- VerticalAlignment="Center">
- <GroupBox Header="相机">
-
- <ComboBox x:Name="combox"
- Width="190"
- Height="30"
- SelectedItem="{Binding Management.CurrCameraSn}"
- ItemsSource="{Binding Management.CameraList}" />
- </GroupBox>
- </StackPanel>
- <StackPanel Grid.Row="1"
- Margin="50,5,0,0"
- Orientation="Horizontal"
- VerticalAlignment="Center">
- <GroupBox Header="采集方式">
- <StackPanel Orientation="Horizontal">
- <RadioButton Content="软触发"
- IsChecked="{Binding Management.CurrCamConfig.TriggerMode,Converter={StaticResource EnumToBoolConverter},ConverterParameter=软触发}"
- GroupName="SoftTrigger"
- Margin="10" />
- <RadioButton Content="硬触发"
- IsChecked="{Binding Management.CurrCamConfig.TriggerMode,Converter={StaticResource EnumToBoolConverter},ConverterParameter=硬触发}"
- GroupName="SoftTrigger"
- Margin="30,10,40,0" />
- </StackPanel>
- </GroupBox>
- </StackPanel>
- <StackPanel Grid.Row="2"
- Margin="50,5,0,0"
- Orientation="Horizontal"
- VerticalAlignment="Center">
- <GroupBox Header="曝光">
- <StackPanel Orientation="Horizontal">
- <TextBox Width="190"/>
- </StackPanel>
- </GroupBox>
- </StackPanel>
- <Border Grid.Row="3"
- BorderThickness="1"
- BorderBrush="#e8e8e8"
- Margin="50,10,0,0"
- Padding="5">
- <StackPanel Orientation="Horizontal"
- VerticalAlignment="Center">
- <Border Background="#0A85D9"
- BorderBrush="Black"
- BorderThickness="1"
- Margin="10,5,3,5"
- CornerRadius="8">
- <Button Content="初始化"
- Background="Transparent"
- Foreground="White"
- Margin="5"
- MinWidth="50"
- BorderThickness="0"
- Command="{Binding CameraInifCommand}" />
- </Border>
- <Border Background="#0A85D9"
- BorderBrush="Black"
- BorderThickness="1"
- Margin="40,5,3,5"
- CornerRadius="8">
- <Button Content="关闭"
- Background="Transparent"
- Foreground="White"
- Margin="5"
- MinWidth="50"
- BorderThickness="0"
- Command="{Binding CameraCloseCommand}"
- CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />
- </Border>
- </StackPanel>
- </Border>
- <Border Grid.Row="4"
- BorderThickness="1"
- BorderBrush="#e8e8e8"
- Margin="50,10,0,0"
- Padding="5">
- <StackPanel Orientation="Horizontal"
- VerticalAlignment="Center">
- <Border Background="#0A85D9"
- BorderBrush="Black"
- BorderThickness="1"
- Margin="10,5,3,5"
- CornerRadius="8">
- <Button Content="开始采集"
- Background="Transparent"
- Foreground="White"
- Margin="5"
- MinWidth="50"
- BorderThickness="0"
- Command="{Binding SoftTrigger_ContinueCommand}"
- CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}" />
- </Border>
- <Border Background="#0A85D9"
- BorderBrush="Black"
- BorderThickness="1"
- Margin="40,5,3,5"
- CornerRadius="8">
- <Button Content="单张采集"
- Background="Transparent"
- Foreground="White"
- Margin="5"
- MinWidth="50"
- BorderThickness="0"
- Command="{Binding SoftTriggerCommand}" />
- </Border>
- </StackPanel>
- </Border>
-
- </Grid>
- </Grid>
- <DockPanel Grid.Column="1"
- Margin="20,20,10,20">
- <WindowsFormsHost Viewlocal:CogDisplayBinder.ImageSource="{Binding Management.Image}">
- <cognexWF1:CogRecordDisplay x:Name="cogRecordDisplay" />
- </WindowsFormsHost>
- </DockPanel>
- </Grid>
- </Grid>
- </UserControl>
|