<UserControl x:Class="MainShell.DeviceMaintance.View.NeedleCameraPrintView"
             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:MainShell.DeviceMaintance.View"
             xmlns:mwControls="http://www.maxwell-gp.com/"
             xmlns:customControl="clr-namespace:MainShell.Resources.CustomControl"
             mc:Ignorable="d" 
             d:DesignHeight="750" d:DesignWidth="800">
    <UserControl.Resources>
        <Style TargetType="GroupBox" BasedOn="{StaticResource GroupStepControl}"/>
        <Style TargetType="Label" BasedOn="{StaticResource {x:Type Label}}">
            <Setter Property="HorizontalContentAlignment" Value="Right"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="Margin" Value="5"/>
            <Setter Property="Height" Value="35"/>
            <Setter Property="Width" Value="80"/>
        </Style>
        <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}" >
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="3"/>
            <Setter Property="Height" Value="35"/>
            <Setter Property="Width" Value="90"/>
        </Style>
    </UserControl.Resources>
    <Grid  mwControls:ParameterAttach.DelayAcceptValue ="{Binding ParameterHelper}">
        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
            <StackPanel>
                <GroupBox IsEnabled="{Binding UiEnable}" Margin="2" Header="【第一步】基础设置">
                    <GroupBox.Content>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <Button Click="{mwControls:Action MoveToOrginPos}" Content="SXSZ至初始位" Width="100"/>
                            <GroupBox Header="速度设置" Style="{x:Null}">
                                <StackPanel Orientation="Horizontal">
                                    <RadioButton GroupName="speed" Click="{mwControls:Action SpeedChanged}" Tag="10" Margin="5,0" Content="10"/>
                                    <RadioButton GroupName="speed" IsChecked="True" Click="{mwControls:Action SpeedChanged}" Tag="50" Margin="5,0"  Content="50"/>
                                    <RadioButton GroupName="speed" Click="{mwControls:Action SpeedChanged}" Tag="100" Margin="5,0" Content="100"/>
                                </StackPanel>
                            </GroupBox>
                        </StackPanel>
                    </GroupBox.Content>
                </GroupBox>
                <GroupBox IsEnabled="{Binding UiEnable}" Margin="2" Header="【第二步】WS避让位">
                    <GroupBox.Content>
                        <customControl:AxisMoveControl LableContent1="X2(mm)："
                              Value1="{Binding NeedlePrintCalibrateParameter.AvoidancePoint.PointX}"
                              LableContent2="Y2(mm)："
                              Value2="{Binding NeedlePrintCalibrateParameter.AvoidancePoint.PointY}"      
                              ReadCommand="{mwControls:Action TeachWSPos}"
                              MoveCommand="{mwControls:Action MoveToWsPos}"/>
                        <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <Label VerticalAlignment="Center" Content="X2:"/>
                            <mwControls:NumberBox Value="{Binding NeedlePrintCalibrateParameter.AvoidancePoint.PointX}" IsReadOnly="True" Width="80" Margin="4,0" />
                            <Label VerticalAlignment="Center" Content="Y2:"/>
                            <mwControls:NumberBox Value="{Binding NeedlePrintCalibrateParameter.AvoidancePoint.PointY}" IsReadOnly="True" Width="80" Margin="4,0" />
                            <Button Margin="2,0" Click="{mwControls:Action TeachWSPos}" Content="示教"/>
                            <Button Margin="2,0" Click="{mwControls:Action MoveToWsPos}" Content="移动"/>
                        </StackPanel>-->
                    </GroupBox.Content>
                </GroupBox>
                <GroupBox IsEnabled="{Binding UiEnable}" Margin="2" Header="【第三步】Z1位置设置">
                    <GroupBox.Content>
                        <customControl:AxisMoveControl LableContent1="Z1(mm)：" 
                              Value1="{Binding NeedlePrintCalibrateParameter.Z1WorkHeight}"
                              IsAllShow="False"
                              ReadCommand="{mwControls:Action TeachZ1Pos}"
                              MoveCommand="{mwControls:Action MoveToZ1Pos}"/>
                        <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                            <Label VerticalAlignment="Center" Content="Z1:"/>
                            <mwControls:NumberBox mwControls:NumericKeypadAttach.IsEnabled="True" Value="{Binding NeedlePrintCalibrateParameter.Z1WorkHeight, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False" Width="80" Margin="4,0" />
                            <Button Margin="2,0" Click="{mwControls:Action TeachZ1Pos}" Content="示教"/>
                            <Button Margin="2,0" Click="{mwControls:Action MoveToZ1Pos}" Content="移动"/>
                        </StackPanel>-->
                    </GroupBox.Content>
                </GroupBox>
                <GroupBox IsEnabled="{Binding UiEnable}" Margin="2" Header="【第四步】Z2位置设置">
                    <GroupBox.Content>
                        <customControl:AxisMoveControl LableContent1="Z2(mm)："
                               Value1="{Binding NeedlePrintCalibrateParameter.Z2WorkHeight}"
                               IsAllShow="False"
                               ReadCommand="{mwControls:Action TeachZ2Pos}"
                               MoveCommand="{mwControls:Action MoveToZ2Pos}"/>
                            <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                            <Label VerticalAlignment="Center" Content="Z2:"/>
                            <mwControls:NumberBox mwControls:NumericKeypadAttach.IsEnabled="True" Value="{Binding NeedlePrintCalibrateParameter.Z2WorkHeight, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False" Width="80" Margin="4,0" />
                            <Button Margin="2,0" Click="{mwControls:Action TeachZ2Pos}" Content="示教"/>
                            <Button Margin="2,0" Click="{mwControls:Action MoveToZ2Pos}" Content="移动"/>
                        </StackPanel>-->
                    </GroupBox.Content>
                </GroupBox>
                <GroupBox IsEnabled="{Binding UiEnable}" Margin="2" Header="【第五步】铜箔区域设置">
                    <GroupBox.Content>
                        <StackPanel>
                            <Label Content="起点设置："/>
                            <customControl:AxisMoveControl LableContent1="X1(mm)："
                              Value1="{Binding NeedlePrintCalibrateParameter.StartPoint.PointX}"
                              LableContent2="Y1(mm)："
                              Value2="{Binding NeedlePrintCalibrateParameter.StartPoint.PointY}"      
                              ReadCommand="{mwControls:Action TeachStartPos}"
                              MoveCommand="{mwControls:Action MoveToStartPos}"
                              IsReadOnly="True"/>
                            <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                <Label VerticalAlignment="Center" Content="X1:"/>
                                <mwControls:NumberBox Value="{Binding NeedlePrintCalibrateParameter.StartPoint.PointX}" IsReadOnly="True" Width="80" Margin="4,0" />
                                <Label VerticalAlignment="Center" Content="Y1:"/>
                                <mwControls:NumberBox Value="{Binding NeedlePrintCalibrateParameter.StartPoint.PointY}" IsReadOnly="True" Width="80" Margin="4,0" />
                                <Button Margin="2,0" Click="{mwControls:Action TeachStartPos}" Content="示教"/>
                                <Button Margin="2,0" Click="{mwControls:Action MoveToStartPos}" Content="移动"/>
                            </StackPanel>-->
                            <Label Content="尾点设置："/>
                            <customControl:AxisMoveControl LableContent1="X2(mm)："
                                  Value1="{Binding NeedlePrintCalibrateParameter.EndPoint.PointX}"
                                  LableContent2="Y2(mm)："
                                  Value2="{Binding NeedlePrintCalibrateParameter.EndPoint.PointY}"      
                                  ReadCommand="{mwControls:Action TeachEndPos}"
                                  MoveCommand="{mwControls:Action MoveToEndPos}"
                                  IsReadOnly="True"/>
                            <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                <Label VerticalAlignment="Center" Content="X1:"/>
                                <mwControls:NumberBox Value="{Binding NeedlePrintCalibrateParameter.EndPoint.PointX}" IsReadOnly="True" Width="80" Margin="4,0" />
                                <Label VerticalAlignment="Center" Content="Y1:"/>
                                <mwControls:NumberBox Value="{Binding NeedlePrintCalibrateParameter.EndPoint.PointY}" IsReadOnly="True" Width="80" Margin="4,0" />
                                <Button Margin="2,0" Click="{mwControls:Action TeachEndPos}" Content="示教"/>
                                <Button Margin="2,0" Click="{mwControls:Action MoveToEndPos}" Content="移动"/>
                            </StackPanel>-->
                            <Label Content="间距设置："/>
                            <StackPanel Orientation="Horizontal">
                                <Label VerticalAlignment="Center" Content="Xpitch:"/>
                                <mwControls:NumberBox mwControls:NumericKeypadAttach.IsEnabled="True" Value="{Binding NeedlePrintCalibrateParameter.Xpitch}" IsReadOnly="False" Width="80" Margin="4,0" />
                                <Label VerticalAlignment="Center" Content="Ypitch:"/>
                                <mwControls:NumberBox mwControls:NumericKeypadAttach.IsEnabled="True" Value="{Binding NeedlePrintCalibrateParameter.Ypitch}" IsReadOnly="False" Width="80" Margin="4,0" />
                            </StackPanel>
                        </StackPanel>
                    </GroupBox.Content>
                </GroupBox>
                <GroupBox Margin="2" Header="【第六步】针印检验">
                    <GroupBox.Content>
                        <StackPanel>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                <Button IsEnabled="{Binding UiEnable}" Click="{mwControls:Action StartVerify}" Content="开始校验"/>
                                <Button IsEnabled="{Binding UiEnable,Converter={StaticResource boolToInversionConverter}}" Click="{mwControls:Action StopVerify}" Content="停止校验"/>
                                <Button IsEnabled="{Binding UiEnable}" Click="{mwControls:Action SaveParam}" Content="保存"/>
                                <Button IsEnabled="{Binding UiEnable}" Click="{mwControls:Action ResetRecord}" Content="重置记录"/>
                            </StackPanel>
                            <StackPanel IsEnabled="{Binding UiEnable}" Margin="0,2" Orientation="Horizontal" HorizontalAlignment="Center">
                                <Button Click="{mwControls:Action NeedleAlignment}" Content="针尖对准"/>
                                <Button Click="{mwControls:Action CameraAlignment}" Content="相机对准"/>
                            </StackPanel>
                        </StackPanel>

                    </GroupBox.Content>
                </GroupBox>
                <GroupBox IsEnabled="{Binding UiEnable}" Margin="2" Header="【第七步】偏差补偿">
                    <GroupBox.Content>
                        <StackPanel>
                            <Label Content="当前针尖补偿：" Width="90"/>
                            <StackPanel Orientation="Horizontal">
                                <Label VerticalAlignment="Center" Content="XOffset:"/>
                                <mwControls:NumberBox Value="{Binding CurrentNeedleOffsetPoint.PointX}" IsReadOnly="True" Width="80" Margin="4,0" />
                                <Label VerticalAlignment="Center" Content="YOffsetY:"/>
                                <mwControls:NumberBox Value="{Binding CurrentNeedleOffsetPoint.PointY}" IsReadOnly="True" Width="80" Margin="4,0" />
                            </StackPanel>
                            <Label Content="针尖点位："/>
                            <StackPanel Orientation="Horizontal">
                                <Label VerticalAlignment="Center" Content="X1:"/>
                                <mwControls:NumberBox Value="{Binding CurrentNeedlePoint.PointX}" IsReadOnly="True" Width="80" Margin="4,0" />
                                <Label VerticalAlignment="Center" Content="Y1:"/>
                                <mwControls:NumberBox Value="{Binding CurrentNeedlePoint.PointY}" IsReadOnly="True" Width="80" Margin="4,0" />
                            </StackPanel>
                            <Label Content="相机点位："/>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                <Label VerticalAlignment="Center" Content="X1:"/>
                                <mwControls:NumberBox Value="{Binding CameraPoint.PointX}" IsReadOnly="True" Width="80" Margin="4,0" />
                                <Label VerticalAlignment="Center" Content="Y1:"/>
                                <mwControls:NumberBox Value="{Binding CameraPoint.PointY}" IsReadOnly="True" Width="80" Margin="4,0" />
                                <Button Margin="2,0" Click="{mwControls:Action TeachCameraPos}" Content="示教"/>
                                <Button Margin="2,0" Content="补偿偏差" Click="{mwControls:Action CalculateOffset}"/>
                            </StackPanel>
                        </StackPanel>

                    </GroupBox.Content>
                </GroupBox>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</UserControl>
