<Window x:Class="ThickTcpUiInWindow.Window_BoltCreate"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:local="clr-namespace:ThickTcpUiInWindow"
        Loaded="Window_Loaded" Unloaded="Window_Unloaded"
        Title="Window_BoltCreate" SizeToContent="WidthAndHeight" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignWidth="354" d:DesignHeight="382">
    <Window.Resources>
        <ResourceDictionary>
            <Style TargetType="TextBlock" x:Key="textblock_title">
                <Setter Property="FontSize" Value="18"/>
                <Setter Property="FontStyle" Value="Normal"/>
                <Setter Property="FontWeight" Value="Bold"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="Margin" Value="10"/>
                <Setter Property="Width" Value="164"/>
            </Style>
            <Style TargetType="Button">
                <Setter Property="Height" Value="50"/>
                <Setter Property="Margin" Value="5"/>
            </Style>
            <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/ThickTcpUiInWindow;component/Converter/Dictionary_MyConv.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid TextBlock.FontSize="18">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid Name="grid_null"/>
        <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6" >
                <Run Text="机架总长:" FontWeight="Bold" FontSize="24"/>
                <Run Text="{Binding PosLength}"  />
                <Run Text="(" Foreground="Gray"/>
                <Run Foreground="Gray">
                    <Run.Text>
                        <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                            <Binding Path="PosLength" />
                            <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                        </MultiBinding>
                    </Run.Text>
                </Run>
                <Run Text="mm)" Foreground="Gray" />
        </TextBlock>
        <TabControl Margin="6" Grid.Row="1">
            <TabControl.Resources>
                <Style TargetType="TextBlock" x:Key="item_header">
                    <Setter Property="Width" Value="90"/>
                    <Setter Property="Margin" Value="6"/>
                </Style>
                <Style TargetType="TextBox" x:Key="item_content">
                    <Setter Property="Width" Value="120"/>
                    <Setter Property="Height" Value="23"/>
                </Style>
            </TabControl.Resources>
            <TabItem Header="平均划分">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Vertical" >
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="分区宽度" Style="{StaticResource item_header}" />
                            <TextBox Text="{Binding BoltWidth}" Style="{StaticResource item_content}" />
                            <TextBlock Margin="6" Foreground="Gray">
                                <Run Text="(" />
                                <Run >
                                    <Run.Text>
                                        <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                            <Binding Path="BoltWidth" />
                                            <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                                        </MultiBinding>
                                    </Run.Text>
                                </Run>
                                <Run Text="mm)" />
                            </TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="第1分区号" Style="{StaticResource item_header}"/>
                            <TextBox Text ="{Binding BoltNo1st}" Style="{StaticResource item_content}"/>
                        </StackPanel>

                    </StackPanel>
                    <Button Content="生成分区表" Margin="6" Grid.Row="1" Click="button_apply01_Click" />
                </Grid>

            </TabItem>
            <TabItem Header="重叠划分">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="分区宽度" Style="{StaticResource item_header}" />
                            <TextBox Text="{Binding BoltWidth}" Style="{StaticResource item_content}" />
                            <TextBlock Margin="6" Foreground="Gray">
                                <Run Text="(" />
                                <Run >
                                    <Run.Text>
                                        <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                            <Binding Path="BoltWidth" />
                                            <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                                        </MultiBinding>
                                    </Run.Text>
                                </Run>
                                <Run Text="mm)" />
                            </TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="分区间隔" Style="{StaticResource item_header}"/>
                            <TextBox Text ="{Binding BoltInterval}" Style="{StaticResource item_content}"/>
                            <TextBlock Margin="6" Foreground="Gray">
                                <Run Text="(" />
                                <Run >
                                    <Run.Text>
                                        <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                            <Binding Path="BoltInterval" />
                                            <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                                        </MultiBinding>
                                    </Run.Text>
                                </Run>
                                <Run Text="mm)" />
                            </TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="第1分区号" Style="{StaticResource item_header}"/>
                            <TextBox Text ="{Binding BoltNo1st}" Style="{StaticResource item_content}"/>
                        </StackPanel>


                    </StackPanel>
                    <Button Content="生成分区表" Margin="6" Grid.Row="1" Click="button_apply02_Click"/>
                </Grid>
            </TabItem>
            <TabItem Header="自定义">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Vertical">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="分区宽度" Style="{StaticResource item_header}" />
                        <TextBox Text="{Binding BoltWidth}" Style="{StaticResource item_content}" />
                        <TextBlock Margin="6" Foreground="Gray">
                                <Run Text="(" />
                                <Run >
                                    <Run.Text>
                                        <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                            <Binding Path="BoltWidth" />
                                            <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                                        </MultiBinding>
                                    </Run.Text>
                                </Run>
                                <Run Text="mm)" />
                        </TextBlock>
                    </StackPanel>


                </StackPanel>
                    <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Custom}" MinHeight="153" Grid.Row="1">
                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding No}" Header="分区号" />
                            <DataGridTextColumn Binding="{Binding Position}" Header="脉冲" />
                        </DataGrid.Columns>
                    </DataGrid>
                    <Button Content="生成分区表" Grid.Row="2" Click="button_apply03_Click"/>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
