<Page x:Class="FLY.Thick.BlowingScan.UI.Client.PgProfileBlowing"
      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:common="clr-namespace:FLY.Thick.BlowingScan.Common;assembly=FLY.Thick.BlowingScan"
      mc:Ignorable="d" 
      d:DesignHeight="1024" d:DesignWidth="1280" Background="WhiteSmoke"
	Title="Page_Profile" 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.MergedDictionaries>
            <common:BlowingProfileParam x:Key="param" />
        </ResourceDictionary>
    </Page.Resources>

    <Grid d:DataContext="{StaticResource param}">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="496*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <Button Style="{StaticResource ButtonStyle_back}" Command="BrowseBack"/>
            <TextBlock Style="{StaticResource TextBlockStyle_Title}" >
                <Run Foreground="#FF3A3A3A" FontSize="60"  Text="产品工艺表"/>
            </TextBlock>
        </StackPanel>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="338*" />
            </Grid.ColumnDefinitions>
            <ScrollViewer MinWidth="550">
                <StackPanel Name="groupbox_profile" Orientation="Vertical" >
                    <StackPanel Orientation="Horizontal" >
                        <Border Background="{StaticResource Color_theme_activity}" Width="150" Margin="0,5,5,5" >
                            <Viewbox>
                                <TextBlock  Style="{StaticResource TextBlockStyle_ItemHeader}" Text="产品" />
                            </Viewbox>
                        </Border>
                        <StackPanel>
                            <StackPanel Orientation="Vertical" Margin="2">
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="名称" />
                                <Viewbox Margin="2" Width="350" Height="40" HorizontalAlignment="Left">
                                    <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding PName}" Tag="Full" />
                                </Viewbox>
                            </StackPanel>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <StackPanel Orientation="Vertical" Margin="2">
                                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="订单号" />
                                    <Viewbox Margin="2" Width="300" Height="40" HorizontalAlignment="Left">
                                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding OrderNo}" Tag="Full" />
                                    </Viewbox>
                                </StackPanel>
                                <StackPanel Grid.Column="1" Orientation="Vertical" Margin="2">
                                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="卷号" />
                                    <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding Number}" />
                                </StackPanel>
                            </Grid>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" >
                        <Border Background="{StaticResource Color_theme_activity}" Width="150" Margin="0,5,5,5" >
                            <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="工艺" />
                        </Border>
                        <StackPanel Orientation="Horizontal" >
                            <StackPanel Orientation="Vertical" Margin="5">
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="目标值" />
                                <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding Target, StringFormat={}{0:F2}}" />
                            </StackPanel>
                            <StackPanel Orientation="Vertical" Margin="5" >
                                <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="公差%" />
                                <StackPanel Orientation="Horizontal">
                                    <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding TolerancePercent, Converter={StaticResource percentconv}}" />
                                    <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent_mm}" Text="%" />
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" >
                        <Button Style="{StaticResource ResourceKey=ButtonStyle3}" Width="150" Margin="0,5,5,5"  Click="button_abhelper_Click">
                            <TextBlock Style="{StaticResource TextBlockStyle_ItemHeader}" Text="补偿" />
                        </Button>
                        <StackPanel Orientation="Vertical" Margin="5">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="斜率A" />
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding K, StringFormat={}{0:F3}}" />
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>
            <ListBox Name="listview_profile" Margin="5" MinWidth="400" Grid.Column="1" Background="{StaticResource Background_Title}">
                <ListBox.Resources>
                    <Style x:Key="FocusVisual">
                        <Setter Property="Control.Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Rectangle Margin="0" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="0" StrokeDashArray="1 2"/>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                    <SolidColorBrush x:Key="Item.MouseOver.Background" Color="Transparent"/>
                    <SolidColorBrush x:Key="Item.MouseOver.Foreground" Color="White"/>
                    <SolidColorBrush x:Key="Item.MouseOver.Border" Color="#FF3B3B3B"/>

                    <SolidColorBrush x:Key="Item.SelectedInactive.Background" Color="#FF3B3B3B"/>
                    <SolidColorBrush x:Key="Item.SelectedInactive.Foreground" Color="White"/>
                    <SolidColorBrush x:Key="Item.SelectedInactive.Border" Color="#FF3B3B3B"/>

                    <SolidColorBrush x:Key="Item.SelectedActive.Background" Color="LightGray"/>
                    <SolidColorBrush x:Key="Item.SelectedActive.Foreground" Color="Black"/>
                    <SolidColorBrush x:Key="Item.SelectedActive.Border" Color="LightGray"/>

                    <Style  TargetType="{x:Type ListBoxItem}">
                        <Setter Property="FontFamily" Value="Microsoft YaHei UI Light"/>
                        <Setter Property="FontSize" Value="16"/>
                        <!--<Setter Property="HorizontalContentAlignment" Value="Center"/>-->

                        <Setter Property="SnapsToDevicePixels" Value="True"/>
                        <Setter Property="Padding" Value="4,1"/>
                        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                        <Setter Property="Background" Value="Transparent"/>
                        <Setter Property="BorderBrush" Value="Transparent"/>
                        <Setter Property="BorderThickness" Value="1"/>
                        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                                        <!--<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />-->
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock x:Name="Tb" Text="{Binding .}" Foreground="White" FontWeight="Bold" FontSize="26" FontFamily="Microsoft Sans Serif" />
                                        </StackPanel>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <MultiTrigger>
                                            <MultiTrigger.Conditions>
                                                <Condition Property="IsMouseOver" Value="True"/>
                                            </MultiTrigger.Conditions>
                                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource Item.MouseOver.Background}"/>
                                            <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource Item.MouseOver.Border}"/>
                                            <Setter Property="Foreground" TargetName="Tb" Value="{StaticResource Item.MouseOver.Foreground}"/>
                                        </MultiTrigger>
                                        <MultiTrigger>
                                            <MultiTrigger.Conditions>
                                                <Condition Property="Selector.IsSelectionActive" Value="False"/>
                                                <Condition Property="IsSelected" Value="True"/>
                                            </MultiTrigger.Conditions>
                                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource Item.SelectedInactive.Background}"/>
                                            <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource Item.SelectedInactive.Border}"/>
                                            <Setter Property="Foreground" TargetName="Tb" Value="{StaticResource Item.SelectedInactive.Foreground}"/>
                                        </MultiTrigger>
                                        <MultiTrigger>
                                            <MultiTrigger.Conditions>
                                                <Condition Property="Selector.IsSelectionActive" Value="True"/>
                                                <Condition Property="IsSelected" Value="True"/>
                                            </MultiTrigger.Conditions>
                                            <Setter Property="Background" TargetName="Bd" Value="{StaticResource Item.SelectedActive.Background}"/>
                                            <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource Item.SelectedActive.Border}"/>
                                            <Setter Property="Foreground" TargetName="Tb" Value="{StaticResource Item.SelectedActive.Foreground}"/>
                                        </MultiTrigger>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.Resources>

            </ListBox>
        </Grid>

        <StackPanel Orientation="Horizontal"  Grid.Row="2" HorizontalAlignment="Right" Margin="0,10,-6,10">
            <Button Content="应用" Style="{StaticResource ResourceKey=ButtonStyle2}" Click="button_apply_Click" />
            <Button Content="读取" Style="{StaticResource ResourceKey=ButtonStyle2}" Click="button_read_Click" />
            <Button Content="删除" Style="{StaticResource ResourceKey=ButtonStyle2}" Click="button_del_Click"/>
        </StackPanel>
    </Grid>
</Page>