<Page x:Class="ThickTcpUiInWindow.Page_Grid"
      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" 
      xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
      d:DesignHeight="768" d:DesignWidth="1024"
      Background="White"
	Title="Page_Grid" Loaded="Page_Loaded" Unloaded="Page_Unloaded">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/FLY.ControlLibrary;component/Themes/Dictionary_MyStyle.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/ThickTcpUiInWindow;component/Converter/Dictionary_MyConv.xaml"/>
                <!--<ResourceDictionary Source="pack://application:,,,/ThickTcpUiInWindow;component/Culture/StringResource.zh-CN.xaml"/>-->
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="{x:Type ToggleButton}" x:Key="ToggleButtonStyle_direction" >
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Padding" Value="1"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ToggleButton}">
                            <Canvas Height="45" Width="106">
                                <Path x:Name="Path_Background" Data="F1M1,1C1,1 105,1 105,1 105,1 105,44 105,44 105,44 1,44 1,44 1,44 1,1 1,1z" 
								Fill="#FF008BE5" Height="45" Width="106"/>
                                <Path x:Name="Path_block" Data="F1M1,1C1,1 23,1 23,1 23,1 23,35 23,35 23,35 1,35 1,35 1,35 1,1 1,1z" 
								Fill="#FFFFFFFF" Height="36" Canvas.Left="77" Canvas.Top="5" Width="24"/>
                                <Viewbox x:Name="Viewbox_No" Canvas.Left="0" Width="78" Height="45" VerticalAlignment="Center" HorizontalAlignment="Center">
                                    <TextBlock x:Name="TextBlock_No" 
                                               Text="{DynamicResource strDirectionForw}" 
                                               Foreground ="White" 
                                               Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" 
                                               Margin="5"/>
                                </Viewbox>
                                </Canvas>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="False">
                                    <Setter TargetName="TextBlock_No" Property="Text" Value="{DynamicResource strDirectionBackw}"/>
                                    <Setter TargetName="Viewbox_No" Property="Canvas.Left" Value="28"/>
                                    <Setter TargetName="Path_block" Property="Canvas.Left" Value="4"/>
                                    <Setter TargetName="Path_Background" Property="Fill" Value="#FF3B3B3B"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </ResourceDictionary>
    </Page.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Background="{StaticResource Background_Title}">
            <Button Style="{StaticResource ButtonStyle_back2}" Command="BrowseBack"/>
            <TextBlock Style="{StaticResource TextBlockStyle_Title}"   Text="{DynamicResource strGridTest}"/>
        </StackPanel>
        <Grid Grid.Row="1" Margin="0,5,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition/>
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            <Border Width="150" Background="{StaticResource Color_theme_activity}" Margin="0,5,5,5">
                <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}"  Text="{DynamicResource strOperation}"/>
            </Border>
            <WrapPanel Orientation="Horizontal" Grid.Column="1">
                <WrapPanel.Resources>
                    <Style TargetType="Button" BasedOn="{StaticResource ResourceKey=ButtonStyle2}">
                        <Setter Property="Margin" Value="5"/>
                        <Setter Property="Height" Value="75"/>
                        <Setter Property="Width" Value="140"/>
                    </Style>
                </WrapPanel.Resources>
                <Button Content="{DynamicResource strBackward}" Click="button_backw_Click" />
                <Button Content="{DynamicResource strForward}" Click="button_forw_Click" />
                <Button Content="{DynamicResource strOrg}" Click="button_org_Click" />
                <Button Content="{DynamicResource strStop}" Click="button_stop_Click" />
                <StackPanel Orientation="Vertical" Margin="5">
                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeader}" Text="{DynamicResource strCurrPulse}" />
                    <TextBlock Name="textblock_position"  Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" Text="{Binding Position}" />
                </StackPanel>
                <StackPanel Orientation="Vertical" Margin="5" Name="stackpanel_adlag">
                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strForwBackwDistance}" />
                    <StackPanel Orientation="Horizontal">
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding PPDistance,UpdateSourceTrigger=PropertyChanged}" />
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="{DynamicResource strPulse}" />

                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" >
                            <Run Text="="/>
                            <Run Text="{Binding ADLag,Mode=OneWay}" />
                        </TextBlock>
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="ms" />
                    </StackPanel>

                </StackPanel>
            </WrapPanel>
        </Grid>
        <Grid Grid.Row="2" Margin="0,5,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Border Width="150" Background="{StaticResource Color_theme_activity}" >
                <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="{DynamicResource strData}" />
            </Border>
            <Grid Grid.Column="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <WrapPanel Orientation="Horizontal" >
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strSeriesCnt}" />
                        <StackPanel Orientation="Horizontal">
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding SeriesCnt}" />
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="{DynamicResource strStripOf}"/>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strSerieIndex}" />
                        <StackPanel Orientation="Horizontal">
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding SerieIndex}" />
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strDirection}" />
                        <ToggleButton Style="{StaticResource ToggleButtonStyle_direction}" IsChecked="{Binding Direction, Converter={StaticResource ResourceKey=forwconv},ConverterParameter=FORWARD}" />
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="{DynamicResource strAutoChange}" />
                        <ToggleButton Style="{StaticResource ToggleButtonStyle1}" IsChecked="{Binding AutoChange}" />
                    </StackPanel>
                    <Button Content="{DynamicResource strGet}" Style="{StaticResource ResourceKey=ButtonStyle2}" Margin="5" Height="75" Width="140" Click="button_get_Click"/>
                    <Button Content="{DynamicResource strSave}" Style="{StaticResource ResourceKey=ButtonStyle2}" Margin="5" Height="75" Width="140" Click="button_save_Click"/>
                </WrapPanel>
                <WindowsFormsHost Margin="5" Grid.Row="1">
                    <Chr:Chart x:Name="chart1"/>
                </WindowsFormsHost>
            </Grid>


        </Grid>
    </Grid>
</Page>