<UserControl x:Class="MainShell.Manual.View.SubstrateHeightMeasureView"
             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:mw="http://www.maxwell-gp.com/"
             xmlns:recipe="clr-namespace:MainShell.Recipe.Models.SubstrateParameter"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <Style x:Key="SubstrateHeightMeasureSummaryLabelStyle" TargetType="TextBlock" BasedOn="{StaticResource ProcessReadOnlyValueTextStyle}">
                <Setter Property="Width" Value="126"/>
                <Setter Property="FontWeight" Value="SemiBold"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>

            <Style x:Key="SubstrateHeightMeasureSummaryValueStyle" TargetType="TextBox" BasedOn="{StaticResource ProcessTextBoxStyle}">
                <Setter Property="MinWidth" Value="110"/>
                <Setter Property="Margin" Value="8,0,0,0"/>
                <Setter Property="IsReadOnly" Value="True"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="FontWeight" Value="SemiBold"/>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid Background="{StaticResource ProcessPageBackgroundBrush}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Border Style="{StaticResource ProcessCameraHostBorderStyle}">
            <ContentControl Content="{Binding CameraAxisViewModel}" />
        </Border>
        <ScrollViewer Grid.Column="1"
                      Margin="0,4,4,4"
                      VerticalScrollBarVisibility="Auto"
                      HorizontalScrollBarVisibility="Disabled"
                      Style="{StaticResource ProcessScrollViewerStyle}"
                      CanContentScroll="False">
            <Grid Margin="4">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <GroupBox Grid.Row="0" Header="{DynamicResource SubstrateHeightMeasureManualSummary}" Style="{StaticResource ProcessWideCardGroupBoxStyle}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Grid.Column="0" Margin="4,2,14,2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{DynamicResource SubstrateHeightMeasureManualRecipeName}" Style="{StaticResource SubstrateHeightMeasureSummaryLabelStyle}"/>
                            <TextBox Grid.Column="1" Text="{Binding RecipeName, Mode=OneWay}" Style="{StaticResource SubstrateHeightMeasureSummaryValueStyle}" HorizontalAlignment="Left"/>
                        </Grid>

                        <Grid Grid.Row="0" Grid.Column="1" Margin="4,2,0,2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{DynamicResource SubstrateHeightMeasureManualMode}" Style="{StaticResource SubstrateHeightMeasureSummaryLabelStyle}"/>
                            <TextBox Grid.Column="1" HorizontalAlignment="Left">
                                <TextBox.Style>
                                    <Style TargetType="TextBox" BasedOn="{StaticResource SubstrateHeightMeasureSummaryValueStyle}">
                                        <Setter Property="Text" Value="{DynamicResource SubstrateHeightMeasureManualTeachMode}"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding CurrentMeasureMode}" Value="{x:Static recipe:SubstrateHeightMeasureMode.RowColumnOffset}">
                                                <Setter Property="Text" Value="{DynamicResource SubstrateHeightMeasureManualRowColumnMode}"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBox.Style>
                            </TextBox>
                        </Grid>

                        <Grid Grid.Row="1" Grid.Column="0" Margin="4,2,14,2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{DynamicResource SubstrateHeightMeasureManualConfiguredCount}" Style="{StaticResource SubstrateHeightMeasureSummaryLabelStyle}"/>
                            <TextBox Grid.Column="1" Text="{Binding ConfiguredPointCount, Mode=OneWay}" Style="{StaticResource SubstrateHeightMeasureSummaryValueStyle}" HorizontalAlignment="Left"/>
                        </Grid>

                        <Grid Grid.Row="1" Grid.Column="1" Margin="4,2,0,2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{DynamicResource SubstrateHeightMeasureManualMeasuredCount}" Style="{StaticResource SubstrateHeightMeasureSummaryLabelStyle}"/>
                            <TextBox Grid.Column="1" Text="{Binding MeasuredPointCount, Mode=OneWay}" Style="{StaticResource SubstrateHeightMeasureSummaryValueStyle}" HorizontalAlignment="Left"/>
                        </Grid>
                    </Grid>
                </GroupBox>

                <GroupBox Grid.Row="1" Header="{DynamicResource SubstrateHeightMeasureManualResultList}" Style="{StaticResource ProcessWideCardGroupBoxStyle}" Margin="0,8,0,0">
                    <DataGrid Style="{StaticResource ProcessDataGridStyle}"
                              AutoGenerateColumns="False"
                              IsReadOnly="True"
                              CanUserAddRows="False"
                              ItemsSource="{Binding PointResults}"
                              MinHeight="260">
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="1.4*" Header="{DynamicResource SubstrateHeightMeasureManualPointName}" Binding="{Binding PointName}"/>
                            <DataGridTextColumn Width="*" Header="{DynamicResource SubstrateHeightMeasureManualRow}" Binding="{Binding RowIndex}"/>
                            <DataGridTextColumn Width="*" Header="{DynamicResource SubstrateHeightMeasureManualColumn}" Binding="{Binding ColumnIndex}"/>
                            <DataGridTextColumn Width="1.2*" Header="{DynamicResource SubstrateHeightMeasureManualPositionX}" Binding="{Binding PositionX, StringFormat={}{0:F4}}"/>
                            <DataGridTextColumn Width="1.2*" Header="{DynamicResource SubstrateHeightMeasureManualPositionY}" Binding="{Binding PositionY, StringFormat={}{0:F4}}"/>
                            <DataGridTextColumn Width="1.2*" Header="{DynamicResource SubstrateHeightMeasureManualHeightValue}" Binding="{Binding HeightValue, StringFormat={}{0:F4}}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </GroupBox>

                <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,8,0,0">
                    <Button Content="{DynamicResource Start}" Click="{mw:Action StartProcess}" Style="{StaticResource StartButtonStyle}" Margin="5"
                            IsEnabled="{Binding Runner.IsRunning, Converter={StaticResource boolToInversionConverter}}" />
                    <Button Content="{DynamicResource Stop}" Click="{mw:Action StopProcess}" Style="{StaticResource StopButtonStyle}" Margin="5"
                            IsEnabled="{Binding Runner.IsRunning}" />
                </StackPanel>
            </Grid>
        </ScrollViewer>
    </Grid>
</UserControl>
