<UserControl x:Class="MainShell.ParaSetting.View.AxisSoftLimitSettingView"
             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:behavior="clr-namespace:MainShell.Common.ControlAttribute"
             xmlns:mw="http://www.maxwell-gp.com/"
             mc:Ignorable="d"
             d:DesignHeight="450"
             d:DesignWidth="800">
    <UserControl.Resources>
        <Style x:Key="AxisSoftLimitTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
            <Setter Property="Height" Value="30"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>

        <Style x:Key="AxisSoftLimitNumericEditingTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource AxisSoftLimitTextBoxStyle}">
            <Setter Property="behavior:ControlBehavior.IsNumericOnly" Value="True"/>
        </Style>
    </UserControl.Resources>

    <Grid Background="{StaticResource ProcessPageBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="60"/>
        </Grid.RowDefinitions>

        <GroupBox Grid.Row="0"
                  Margin="4,4,4,8"
                  Header="{DynamicResource AxisSoftLimitGroupHeader}"
                  Style="{StaticResource ProcessWideCardGroupBoxStyle}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0"
                       Style="{StaticResource ProcessLabelStyle}"
                       Content="{DynamicResource AxisSoftLimitFilePathLabel}"/>
                <TextBox Grid.Column="1"
                         Style="{StaticResource AxisSoftLimitTextBoxStyle}"
                         IsReadOnly="True"
                         Text="{Binding ParameterFilePath}"/>
            </Grid>
        </GroupBox>

        <DataGrid Grid.Row="1"
                  Margin="4,0,4,4"
                  AutoGenerateColumns="False"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  CanUserSortColumns="False"
                  ItemsSource="{Binding AxisSoftLimitItems}"
                  SelectedItem="{Binding SelectedAxisSoftLimitItem}">
            <DataGrid.Columns>
                <DataGridTextColumn Header="{DynamicResource AxisName}" Binding="{Binding AxisName}" IsReadOnly="True" Width="2*"/>
                <DataGridTextColumn Header="{DynamicResource AxisSoftLimitCardName}" Binding="{Binding CardName}" IsReadOnly="True" Width="2*"/>
                <DataGridTextColumn Header="{DynamicResource AxisSoftLimitCardNum}" Binding="{Binding CardNum}" IsReadOnly="True" Width="*"/>
                <DataGridTextColumn Header="{DynamicResource AxisSoftLimitAxisNum}" Binding="{Binding AxisNum}" IsReadOnly="True" Width="*"/>
                <DataGridTextColumn Header="{DynamicResource AxisSoftLimitNegativeLabel}" Width="2*" EditingElementStyle="{StaticResource AxisSoftLimitNumericEditingTextBoxStyle}">
                    <DataGridTextColumn.Binding>
                        <Binding Path="NegativeSoftLimit" UpdateSourceTrigger="PropertyChanged"/>
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>
                <DataGridTextColumn Header="{DynamicResource AxisSoftLimitPositiveLabel}" Width="2*" EditingElementStyle="{StaticResource AxisSoftLimitNumericEditingTextBoxStyle}">
                    <DataGridTextColumn.Binding>
                        <Binding Path="PositiveSoftLimit" UpdateSourceTrigger="PropertyChanged"/>
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>

        <Grid Grid.Row="2" Margin="4,8,4,4">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Content="{DynamicResource AxisSoftLimitApplyAllButton}"
                        Click="{mw:Action BtnApplyAll}"
                        Style="{StaticResource SaveButtonStyle}"
                        Margin="0,0,8,0"/>
                <Button Content="{DynamicResource AxisSoftLimitApplyButton}"
                        Click="{mw:Action BtnApply}"
                        Style="{StaticResource SaveButtonStyle}"
                        Margin="0,0,8,0"/>
                <Button Content="{DynamicResource Save}"
                        Click="{mw:Action BtnSave}"
                        Style="{StaticResource SaveButtonStyle}"
                        HorizontalAlignment="Right"/>
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
