<Page x:Class="ThickTcpUiInWindow.Page_Boltmap"
      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:ThickTcpUiInWindow"
      mc:Ignorable="d" 
      d:DesignHeight="768" d:DesignWidth="1024"
      Loaded="Page_Loaded" Unloaded="Page_Unloaded"
	Title="Page_Boltmap">
    <Page.Resources>
        <ResourceDictionary>
            <local:BorderType2VisibilityConverter x:Key="bt2vconv"/>
            <local:BorderType2BoolConverter x:Key="bt2bconv"/>
            <local:BoltNoMidConverter x:Key="bnmidconv"/>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ThickTcpUiInWindow;component/Converter/Dictionary_MyConv.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="496*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid Name="grid_null"/>
        <StackPanel Orientation="Horizontal" Background="{StaticResource Background_Title}">
            <Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
            <TextBlock Style="{StaticResource TextBlockStyle_Title}"  Text="分区设置"/>
        </StackPanel>
        <StackPanel Grid.Row="1" Orientation="Vertical" >
            <Grid Margin="0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>
                <Button Style="{StaticResource ResourceKey=ButtonStyle3}" Width="150" Margin="0,5,5,5"  >
                    <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="分区表"/>
                </Button>
                <WrapPanel Orientation="Horizontal" Grid.Column="1" >
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="分区号范围" />
                        <TextBlock Style="{StaticResource TextBlockStyle_FieldContent}">
                        <Run Text="{Binding FirstBoltNo,Mode=OneWay}"/>
                        <Run Text="-"/>
                        <Run Text="{Binding LastBoltNo,Mode=OneWay}"/>
                        </TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="脉冲范围" />
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}">
                        <Run Text="{Binding PosBegin,Mode=OneWay}"/>
                        <Run Text="-"/>
                        <Run Text="{Binding PosEnd,Mode=OneWay}"/>
                            </TextBlock>
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm_interval}" Text="|"/>
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" >
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                <Binding Path="PosBegin" />
                                <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                            </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                            <Run Text="-"/>
                            <Run>
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                    <Binding Path="PosEnd" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                            </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                            </TextBlock>
                        </StackPanel>

                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock  Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="平均分区宽度" />
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" Text="{Binding BoltWidth,Mode=OneWay}" />
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm_interval}" Text="|"/>
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" >
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                    <Binding Path="BoltWidth" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                            </TextBlock>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock  Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="平均分区间隔" />
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" Text="{Binding BoltInterval,Mode=OneWay}" />
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm_interval}" Text="|"/>
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" >
                            <Run >
                                <MultiBinding Converter="{StaticResource p2mmconv}" Mode="OneWay" StringFormat="{}{0:F0}">
                                    <Binding Path="BoltInterval" />
                                    <Binding Path="DataContext.Encoder1_mmpp" ElementName="grid_null"/>
                                </MultiBinding>
                            </Run>
                            <Run Text="mm"/>
                            </TextBlock>
                        </StackPanel>
                    </StackPanel>
                </WrapPanel>
                <Button Grid.Column="2" Content="划分" Style="{StaticResource ResourceKey=ButtonStyle2}" HorizontalAlignment="Right" VerticalAlignment="Bottom"
                        Click="button_createimg_Click"
                        />
            </Grid>

            <Grid Margin="0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Button Style="{StaticResource ResourceKey=ButtonStyle3}" Width="150" Margin="0,5,5,5" Click="button_apply_Click" >
                    <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="参数&#x0a;应用"/>
                </Button>
                <WrapPanel Orientation="Horizontal" Grid.Column="1">
                    <StackPanel Orientation="Horizontal">
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="边界定义" />
                        <ComboBox Name="comboBox1" >
                            <ComboBoxItem IsSelected="{Binding BorderType, Converter={StaticResource ResourceKey=bt2bconv},ConverterParameter=BeginEnd}">
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}"  FontSize="32" Text="前后边界对应分区号"/>
                            </ComboBoxItem>
                            <ComboBoxItem IsSelected="{Binding BorderType, Converter={StaticResource ResourceKey=bt2bconv},ConverterParameter=Begin}">
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}"  FontSize="32" Text="前边界对应分区号"/>
                            </ComboBoxItem>
                            <ComboBoxItem IsSelected="{Binding BorderType, Converter={StaticResource ResourceKey=bt2bconv},ConverterParameter=End}">
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}"  FontSize="32" Text="后边界对应分区号"/>
                            </ComboBoxItem>
                            <ComboBoxItem IsSelected="{Binding BorderType, Converter={StaticResource ResourceKey=bt2bconv},ConverterParameter=Mid}">
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}"  FontSize="32" Text="中间对应分区号"/>
                            </ComboBoxItem>
                            <ComboBoxItem IsSelected="{Binding BorderType, Converter={StaticResource ResourceKey=bt2bconv},ConverterParameter=Null}">
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}"  FontSize="32" Text="无"/>
                            </ComboBoxItem>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Visibility="{Binding BorderType, Converter={StaticResource ResourceKey=bt2vconv}, ConverterParameter=BeginEnd}">
                        <StackPanel Orientation="Vertical" Margin="5" >
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="前边界分区号" />
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding BorderBoltNo_B}" />
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Margin="5" >
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="后边界分区号" />
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding BorderBoltNo_E}"/>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding BorderType, Converter={StaticResource ResourceKey=bt2vconv}, ConverterParameter=Begin}">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="前边界分区号" />
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding BorderBoltNo_B}" />
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding BorderType, Converter={StaticResource ResourceKey=bt2vconv}, ConverterParameter=End}">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="后边界分区号" />
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding BorderBoltNo_E}"/>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding BorderType, Converter={StaticResource ResourceKey=bt2vconv}, ConverterParameter=Mid}">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="中间分区号" />
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Width="100" HorizontalAlignment="Left">
                            <TextBox.Text>
                                <MultiBinding Converter="{StaticResource bnmidconv}" StringFormat="{}{0:F1}">
                                    <Binding Path="BorderBoltNo_B" />
                                    <Binding Path="BorderBoltNo_E" />
                                </MultiBinding>
                            </TextBox.Text>
                        </TextBox>
                    </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Vertical" Margin="5">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="数据平滑" />
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" HorizontalAlignment="Left" Text="{Binding Smooth}"/>
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}"  Text="分区" />
                            </StackPanel>
                            
                        </StackPanel>
                    </StackPanel>
                </WrapPanel>
            </Grid>
        </StackPanel>
    </Grid>
</Page>
