<UserControl x:Class="YoseenPTZ.ViewDef.PTZView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:mdix="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:mvvm="clr-namespace:MVVM;assembly=MVVM"
        xmlns:mvvmhelpers="clr-namespace:MVVM.Helpers;assembly=MVVM"
        
        xmlns:local="clr-namespace:YoseenPTZ.ViewDef"
        xmlns:resdef="clr-namespace:YoseenPTZ.ResourceDef"
        xmlns:coredef="clr-namespace:YoseenPTZ.CoreDef">
    <Grid x:Name="grid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="150"></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <!--manual-->
        <Grid Grid.Column="0" Style="{StaticResource style_grid}">
            <Grid.Resources>
                <Style TargetType="Button" BasedOn="{StaticResource MaterialDesignIconButton2}">
                    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ptz_PreviewMouseLeftButtonDown"></EventSetter>
                    <EventSetter Event="PreviewMouseLeftButtonUp" Handler="ptz_PreviewMouseLeftButtonUp"></EventSetter>
                </Style>
                <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
                    <Setter Property="HorizontalAlignment" Value="Center"></Setter>
                    <Setter Property="VerticalAlignment" Value="Center"></Setter>
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition></RowDefinition>
                <RowDefinition></RowDefinition>
                <RowDefinition></RowDefinition>
                <RowDefinition></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition Width="20"></ColumnDefinition>
                <ColumnDefinition ></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <!--ptz-->
            <Button Tag="LeftUp" Grid.Row="0" Grid.Column="0">
                <resdef:MyIcon Kind="ptz_upleft"></resdef:MyIcon>
            </Button>
            <Button Tag="Up" Grid.Row="0" Grid.Column="1">
                <resdef:MyIcon Kind="ptz_up"></resdef:MyIcon>
            </Button>
            <Button Tag="RightUp" Grid.Row="0" Grid.Column="2">
                <resdef:MyIcon Kind="ptz_upright"></resdef:MyIcon>
            </Button>

            <Button Tag="Left" Grid.Row="1" Grid.Column="0">
                <resdef:MyIcon Kind="ptz_left"></resdef:MyIcon>
            </Button>
            <Button Tag="Right" Grid.Row="1" Grid.Column="2">
                <resdef:MyIcon Kind="ptz_right"></resdef:MyIcon>
            </Button>

            <Button Tag="LeftDown" Grid.Row="2" Grid.Column="0">
                <resdef:MyIcon Kind="ptz_downleft"></resdef:MyIcon>
            </Button>
            <Button Tag="Down" Grid.Row="2" Grid.Column="1">
                <resdef:MyIcon Kind="ptz_down"></resdef:MyIcon>
            </Button>
            <Button Tag="RightDown" Grid.Row="2" Grid.Column="2">
                <resdef:MyIcon Kind="ptz_downright"></resdef:MyIcon>
            </Button>

            <!--focus-->
            <Button Grid.Row="0" Grid.Column="4" Tag="ZoomIn" ToolTip="焦距增大">
                <mdix:PackIcon Kind="Plus"></mdix:PackIcon>
            </Button>
            <TextBlock Grid.Row="0" Grid.Column="5" Text="焦距"></TextBlock>
            <Button Grid.Row="0" Grid.Column="6" Tag="ZoomOut" ToolTip="焦距减小">
                <mdix:PackIcon Kind="Minus"></mdix:PackIcon>
            </Button>

            <Button Grid.Row="1" Grid.Column="4" Tag="FocusFar" ToolTip="焦点后调">
                <mdix:PackIcon Kind="Plus"></mdix:PackIcon>
            </Button>
            <TextBlock Grid.Row="1" Grid.Column="5" Text="焦点"></TextBlock>
            <Button Grid.Row="1" Grid.Column="6" Tag="FocusNear" ToolTip="焦点前调">
                <mdix:PackIcon Kind="Minus"></mdix:PackIcon>
            </Button>

            <Button Grid.Row="2" Grid.Column="4" Tag="IrisOpen" ToolTip="光圈扩大">
                <mdix:PackIcon Kind="Plus"></mdix:PackIcon>
            </Button>
            <TextBlock Grid.Row="2" Grid.Column="5" Text="光圈"></TextBlock>
            <Button Grid.Row="2" Grid.Column="6" Tag="IrisClose" ToolTip="光圈减小">
                <mdix:PackIcon Kind="Minus"></mdix:PackIcon>
            </Button>
            
            <!--speed-->
            <Slider Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" VerticalAlignment="Center" Margin="5" x:Name="ptz_sliderSpeed"
                                            Minimum="1.0" Maximum="100.0" SmallChange="1" LargeChange="2"></Slider>
            <TextBlock Grid.Row="3" Grid.Column="4" Text="{Binding ElementName=ptz_sliderSpeed,Path=Value,StringFormat=F0}" Width="30"></TextBlock>

            <!---->
            <Button Grid.Row="3" Grid.Column="5"  Tag="B160_Backlight" ToolTip="补光">
                <mdix:PackIcon Kind="LightbulbOn"></mdix:PackIcon>
            </Button>
            <TextBox Grid.Row="3" Grid.Column="6"  Text="{Binding Path=backlight,UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" VerticalAlignment="Center" Width="50"></TextBox>

            <!---->
            <Grid Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="7" ButtonBase.Click="ptzPower_Click">
                <Grid.Resources>
                    <Style TargetType="ToggleButton" BasedOn="{StaticResource MaterialDesignFlatToggleButton2}"></Style>
                </Grid.Resources>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <ToggleButton x:Name="btnLightPower" Grid.Column="0" Tag="LightPower" ToolTip="灯光">
                    <mdix:PackIcon Kind="LightbulbOn"></mdix:PackIcon>
                </ToggleButton>
                <ToggleButton x:Name="btnWiperPower" Grid.Column="1" Tag="WiperPower" ToolTip="雨刷">
                    <mdix:PackIcon Kind="Wiper"></mdix:PackIcon>
                </ToggleButton>
            </Grid>
        </Grid>

        <!--get, set ptz-->
        <Grid Grid.Column="1" Style="{StaticResource style_grid}">
            <Grid.Resources>
                <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
                    <Setter Property="HorizontalAlignment" Value="Center"></Setter>
                    <Setter Property="VerticalAlignment" Value="Center"></Setter>
                    <Setter Property="FontWeight" Value="Bold"></Setter>
                </Style>
                <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
                    <Setter Property="HorizontalAlignment" Value="Center"></Setter>
                    <Setter Property="VerticalAlignment" Value="Center"></Setter>
                    <Setter Property="FontWeight" Value="Bold"></Setter>
                    <Setter Property="Width" Value="50"></Setter>
                </Style>

                <Style TargetType="Button" BasedOn="{StaticResource MaterialDesignOutlinedButton}">
                    <Setter Property="Margin" Value="4,2,4,2"></Setter>
                    <Setter Property="Width" Value="60"></Setter>
                </Style>
            </Grid.Resources>

            <Grid.RowDefinitions>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Row="0" Grid.Column="0" Text="P水平角" Foreground="#60b0f0" ></TextBlock>
            <TextBlock Grid.Row="0" Grid.Column="1" Text="T垂直角" Foreground="#60b0f0" ></TextBlock>
            <TextBlock Grid.Row="0" Grid.Column="2" Text="Z系数" Foreground="#60b0f0" ></TextBlock>


            <TextBlock Grid.Row="1" Grid.Column="0" Text="0.01度"></TextBlock>
            <TextBlock Grid.Row="1" Grid.Column="1" Text="0.01度"></TextBlock>
            <TextBlock Grid.Row="1" Grid.Column="2" Text="0.1,[10-300]" FontSize="10"></TextBlock>

            <TextBox Grid.Row="2" Grid.Column="0" IsReadOnly="True" Text="{Binding Path=curP}"></TextBox>
            <TextBox Grid.Row="2" Grid.Column="1" IsReadOnly="True" Text="{Binding Path=curT}"></TextBox>
            <TextBox Grid.Row="2" Grid.Column="2" IsReadOnly="True" Text="{Binding Path=curZ}"></TextBox>
            <Button Grid.Row="2" Grid.Column="3" x:Name="btnGetPtz" Content="获取" Click="btnGetPtz_Click"></Button>

            <TextBox Grid.Row="3" Grid.Column="0" Text="{Binding Path=toP}"></TextBox>
            <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=toT}"></TextBox>
            <TextBox Grid.Row="3" Grid.Column="2" Text="{Binding Path=toZ}"></TextBox>
            <Button Grid.Row="3" Grid.Column="3" x:Name="btnSetPtz" Content="设置" Click="btnSetPtz_Click" ></Button>
        </Grid>


        <Grid Grid.Column="2" Style="{StaticResource style_grid}">
            <Grid.Resources>
                <Style TargetType="Button" BasedOn="{StaticResource MaterialDesignOutlinedButton}">
                    <Setter Property="Margin" Value="4,2,4,2"></Setter>
                    <Setter Property="Width" Value="120"></Setter>
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <Button Grid.Row="0" Content="云台调试" Click="btnPTZDebug_Click" ></Button>
            <Button Grid.Row="1" Content="预置位-后端" Click="btnPreset_Click" ></Button>
            <Button Grid.Row="2" Content="预置位-前端" Click="btnPresetRaw_Click" ></Button>
        </Grid>

    </Grid>
</UserControl>
