<UserControl x:Class="FLY.Thick.Base.UI.UiModule.DynAreaThick"
             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:FLY.Thick.Base.UI.UiModule"
             mc:Ignorable="d" d:DesignWidth="250"
             >
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/FLY.Thick.Base.UI;component/Converter/Dictionary_MyConv.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="TextBlock" x:Key="Style.Text.ItemHeader">
                <Setter Property="FontWeight" Value="Bold"/>
                <Setter Property="FontFamily" Value="YouYuan"/>
                <Setter Property="FontSize" Value="12"/>
                <Setter Property="HorizontalAlignment" Value="Left"/>
                <Setter Property="Margin" Value="5,0"/>
            </Style>
            <Style TargetType="TextBlock" x:Key="Style.Text.ItemValue">
                <Setter Property="TextAlignment" Value="Center"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="FontFamily" Value="Microsoft Sans Serif"/>
                <Setter Property="FontSize" Value="24"/>
            </Style>
            
        </ResourceDictionary>
    </UserControl.Resources>
    <Border Style="{StaticResource Styles.Module.Border}" >
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition  />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <Grid x:Name="grid_initparam"/>
            <Border Background="{StaticResource Brushes.TitleBar.Background}" CornerRadius="3" Height="130" >
                <Grid>
                    <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-4" Visibility="{Binding IsTest,Converter={StaticResource visbilityconv}}"
                            Style="{StaticResource Styles.Card.Title}" 
                                    Background="{StaticResource MahApps.Brushes.SemiTransparent}"
                                    Foreground="{StaticResource Brushes.TitleBar.Foreground}"
                                        Text="测试模式" />
                    <Viewbox Margin="10">
                        <TextBlock Text="{Binding Thk,StringFormat={}{0:F1}}" Foreground="White" FontSize="30" FontWeight="Bold" FontFamily="Microsoft Sans Serif" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" />
                    </Viewbox>
                    <TextBlock Text="{Binding ControllerState,Converter={StaticResource ctrlstateconv}}" FontSize="12" FontFamily="Microsoft Sans Serif" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="White" Margin="5"/>
                </Grid>
            </Border>
            <StackPanel Grid.Row="1" Margin="2">
                <Grid Margin="2" Name="grid_ad">
                    <Rectangle Fill="#FF86C2E9" HorizontalAlignment="Left">
                        <Rectangle.Width>
                            <MultiBinding Converter="{StaticResource ratioconv}" Mode="OneWay">
                                <Binding Path="AD" />
                                <Binding Path="ADMax" />
                                <Binding Path="ActualWidth" ElementName="grid_ad"/>
                            </MultiBinding>
                        </Rectangle.Width>
                    </Rectangle>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Style="{StaticResource Style.Text.ItemHeader}" FontFamily="Microsoft Sans Serif" 
                                   Text="AD" />
                        <TextBlock Style="{StaticResource Style.Text.ItemValue}" 
                                   Text="{Binding AD}" />
                    </StackPanel>
                </Grid>
                <Grid Margin="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <Rectangle Fill="#FF86C2E9" HorizontalAlignment="Left" Grid.ColumnSpan="3">
                        <Rectangle.Width>
                            <MultiBinding Converter="{StaticResource ratioconv}" Mode="OneWay">
                                <Binding Path="Position" />
                                <Binding Path="DataContext.PosLength" ElementName="grid_initparam"/>
                                <Binding Path="ActualWidth" ElementName="grid_ad"/>
                            </MultiBinding>
                        </Rectangle.Width>
                    </Rectangle>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Style="{StaticResource Style.Text.ItemHeader}" Text="位置" />
                        <TextBlock Style="{StaticResource Style.Text.ItemValue}" Text="{Binding PosMm,StringFormat={}{0:F0}}"/>
                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" FontSize="12" Foreground="Black"
                                   Text="mm"/>
                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Separator}" FontSize="24" Foreground="Black"/>
                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" FontSize="12" Foreground="Black" Text="{Binding Position}" />
                    </StackPanel>
                    <StackPanel Grid.Column="1" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource Style.Text.ItemValue}" Text="{Binding Velocity,StringFormat={}{0:F1}}" />
                        <TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" FontSize="12" Foreground="Black"
                                   Text="m/min" />
                    </StackPanel>
                </Grid>
            </StackPanel>
        </Grid>
    </Border>
    
</UserControl>
