<UserControl x:Class="MainShell.ParaSetting.View.SpeedSettingView"
             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.ParaSetting.View"
             xmlns:common="clr-namespace:MainShell.Common"
             xmlns:mw="http://www.maxwell-gp.com/"
             xmlns:attribute="clr-namespace:MainShell.Common.ControlAttribute"
             xmlns:conv="clr-namespace:MainShell.Converter"
             mw:ParameterAttach.DelayAcceptValue ="{Binding ParameterHelper}"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <conv:EnumBindingSourceExtension x:Key="SpeedEnums" UseDescription="True" EnumType="{x:Type common:SpeedType}" />
        <Style x:Key="CommonLabelStyle" TargetType="Label">
            <Setter Property="HorizontalAlignment" Value="Right"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Width" Value="120"/>
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="15"/>
        </Style>
    </UserControl.Resources>
   
        <Border BorderBrush="{StaticResource PgBackground}" BorderThickness="2">
            <Grid >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal" Margin="5">
                <TextBlock Style="{StaticResource LabelStyle}"
                           Text="{DynamicResource SpeedSetting}" 
                           HorizontalAlignment="Center"  VerticalAlignment="Center"
                           Margin="15,0,15,0"
                           FontSize="18" 
                           FontFamily="Segoe UI"
                           FontWeight="Bold" 
                           Foreground="#424A4D"/>
                <mw:NumberBox DecimalPlaces="4" Value="{Binding Speed}" Height="30" Width="110" 
                              mw:NumericKeypadAttach.IsEnabled="True" ShowUpDownButton="True" 
                              Maximum="2000" Minimum="0" Increment="0.5" Grid.Column="3" 
                              HorizontalAlignment="Center" VerticalAlignment="Center"/>
                <Button Click="{mw:Action btnRowData}"  Content="{DynamicResource ChangeSingleData}" Margin="20,0,10,0" Style="{StaticResource Button}"/>
                <Button Click="{mw:Action btnPageData}" Content="{DynamicResource ChangeAllData}" Margin="20,0,10,0" Style="{StaticResource Button}"/>
                <!--<Button Click="{mw:Action btnPageGantryData}" Content="{DynamicResource ChangeMainData}" Margin="20,0,10,0" Style="{StaticResource Button}"/>-->
                <!--<Button Click="{mw:Action btnPageZAndTHData}" Content="修改Z和TH轴数据" Margin="20,0,10,0" Style="{StaticResource Button}"/>-->

            </StackPanel>
            <DataGrid  AutoGenerateColumns="False" 
                       VerticalScrollBarVisibility="Auto"
                       HorizontalScrollBarVisibility="Auto"
                       Margin="20,10,0,10"
                       Grid.Row="1"
                       RowStyle="{StaticResource DataGridRowErrorStyle}"
                       ItemsSource="{Binding SpeedParaSysSetting.SpeedTypeItemCollection.SpeedTypeItemList}"
                       SelectedItem="{Binding SpeedParaSysSetting.SpeedTypeItemCollection.CurrentSelectSpeedTypeItemList}"
                       CanUserSortColumns="False">

                <DataGrid.Columns>
                    <DataGridTextColumn Header="{DynamicResource AxisName}" Width="*"  Binding="{Binding AxisName}" IsReadOnly="True"/>
                    <DataGridTextColumn Header="{DynamicResource Speed}" Width="*">
                        <DataGridTextColumn.Binding>
                            <Binding Path="Speed" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <attribute:NumericValidationRule/>
                                </Binding.ValidationRules>
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>

                    <DataGridTextColumn Header="{DynamicResource Acc}" Width="*">
                        <DataGridTextColumn.Binding>
                            <Binding Path="Acc" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <attribute:NumericValidationRule/>
                                </Binding.ValidationRules>
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>

                    <DataGridTextColumn Header="{DynamicResource Dec}" Width="*">
                        <DataGridTextColumn.Binding>
                            <Binding Path="Dec" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <attribute:NumericValidationRule/>
                                </Binding.ValidationRules>
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>

                    <DataGridTextColumn Header="{DynamicResource Jerk}" Width="*">
                        <DataGridTextColumn.Binding>
                            <Binding Path="Jerk" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <attribute:NumericValidationRule/>
                                </Binding.ValidationRules>
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>

                    <DataGridTextColumn Header="{DynamicResource HighPercent}" Width="*">
                        <DataGridTextColumn.Binding>
                            <Binding Path="HighPercent" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <attribute:NumericValidationRule/>
                                </Binding.ValidationRules>
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>

                    <DataGridTextColumn Header="{DynamicResource MedianPercent}" Width="*">
                        <DataGridTextColumn.Binding>
                            <Binding Path="MedianPercent" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <attribute:NumericValidationRule/>
                                </Binding.ValidationRules>
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>

                    <DataGridTextColumn Header="{DynamicResource LowPercent}" Width="*">
                        <DataGridTextColumn.Binding>
                            <Binding Path="LowPercent" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <attribute:NumericValidationRule/>
                                </Binding.ValidationRules>
                            </Binding>
                        </DataGridTextColumn.Binding>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
            <Border Grid.Row="2">
                <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
                    <TextBlock Margin="5,0" Style="{StaticResource LargeBlodTextblockStyle}"  Text="{DynamicResource SpeedMode}"/>
                    <ComboBox Width="150"  DisplayMemberPath="Description" FontFamily="微软雅黑"
                      SelectedValuePath="Value"
                      FontSize="18"
                      FontWeight="Bold"
                      SelectedValue="{Binding SpeedParaSysSetting.CurrentSpeedType, Mode=TwoWay}"
                      ItemsSource="{StaticResource SpeedEnums}" Margin="5,0">
                        
                    </ComboBox>
                    <Button  Content="{DynamicResource Save}" HorizontalAlignment="Right" Style="{StaticResource SaveButtonStyle}" VerticalAlignment="Center" Width="110" Height="35"  Click="{mw:Action btnSet}"/>
                </StackPanel>
                
            </Border>
        </Grid>
        </Border>
    
</UserControl>
