<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>
        </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}}" Style="{StaticResource Styles.Module.Text.ItemValue.Unit}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="White" Margin="{StaticResource ControlMargin}"/>
                </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 Styles.Module.Text.ItemHeader}"
                                   Text="AD" />
                        <TextBlock Style="{StaticResource Styles.Module.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 Styles.Module.Text.ItemHeader}" Text="位置" />
                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue}" Text="{Binding PosMm,StringFormat={}{0:F0}}"/>
                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue.Unit}" Text="mm"/>
                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue.Separator}"/>
                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue.Unit}" Text="{Binding Position}" />
                    </StackPanel>
                    <StackPanel Grid.Column="1" Orientation="Horizontal">
                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue}" Text="{Binding Velocity,StringFormat={}{0:F1}}" />
                        <TextBlock Style="{StaticResource Styles.Module.Text.ItemValue.Unit}" Text="m/min" />
                    </StackPanel>
                </Grid>
            </StackPanel>
        </Grid>
    </Border>
    
</UserControl>
