<Page x:Class="ThickTcpUiInWindow.Page_Profile"
      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" 
      mc:Ignorable="d" 
        Background="White"
      d:DesignHeight="768" d:DesignWidth="1024"
	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>
        </ResourceDictionary>
    </Page.Resources>

    <Grid >
        <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>
            <Grid VerticalAlignment="Center" Margin="5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="以%设置" />
                <ToggleButton Grid.Row="1" Style="{StaticResource ToggleButtonStyle1}" HorizontalAlignment="Left" Name="toggleButton_setByPercent" IsChecked="{Binding SetByPercent}" />
            </Grid>
        </StackPanel>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="338*" />
            </Grid.ColumnDefinitions>

            <StackPanel Name="groupbox_profile" Orientation="Vertical" >
                <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="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="名称" />
                        <Viewbox Margin="3" Width="350" Height="40" HorizontalAlignment="Left">
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding PName}" Tag="Full" />
                        </Viewbox>
                    </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" Name="stackpanel_technological">
                        <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" Visibility="{Binding IsChecked,Converter={StaticResource ResourceKey=visbilityconv},ConverterParameter=CollapsedWhenTrue, ElementName=toggleButton_setByPercent}">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="公差" />
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding Alarm, StringFormat={}{0:F2}}" />
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Margin="5" Visibility="{Binding IsChecked,Converter={StaticResource ResourceKey=visbilityconv},ConverterParameter=Collapsed, ElementName=toggleButton_setByPercent}">
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="公差%" />
                            <StackPanel Orientation="Horizontal">
                                <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding AlarmPercent, 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 Comp, StringFormat={}{0:F3}}" />
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="平移B" />
                        <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding Shift,Converter={StaticResource ResourceKey=thickconv}}" />
                    </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="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="扫描" />
                        <StackPanel Orientation="Horizontal">
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding BeginNo}"/>
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" Text="-" />
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding EndNo}" />
                        </StackPanel>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" Margin="5">
                        <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="数据" />
                        <StackPanel Orientation="Horizontal">
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding DataBeginNo}"/>
                            <TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldContent}" Text="-" />
                            <TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding DataEndNo}" />
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
            <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.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding .}" Foreground="White" FontWeight="Bold" FontSize="26" FontFamily="Microsoft Sans Serif" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>-->

            </ListBox>
        </Grid>

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