<fw:NChildWindow x:Class="Com.FirmLib.UI.Manufacturer.WinManufactureInfo"
             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:fw="http://schemas.FWind/xaml"
             xmlns:uc="clr-namespace:Com.FirmLib.UI.Common"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:behaviors="clr-namespace:FWindSoft.Wpf.Behaviors;assembly=FWindSoft.Wpf"
             xmlns:wpf="clr-namespace:FWindSoft.Wpf;assembly=FWindSoft.Wpf"
                  xmlns:bllCommon="clr-namespace:Com.FirmLib.UI.BllCommon"
                 xmlns:dgx="urn:tom-englert.de/DataGridExtensions"
                 mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="500" Title="生产厂家" Height="{Binding Height,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UIElement}}"
                 Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ScrollContentPresenter}}" >
    <fw:NChildWindow.Resources>
        <wpf:BindingProxy x:Key="DATA" Data="{Binding}"></wpf:BindingProxy>
    </fw:NChildWindow.Resources>
    <fw:NChildWindow.AttachElement>
        <StackPanel HorizontalAlignment="Stretch" Orientation="Horizontal" VerticalAlignment="Center">
            <Button Command="{Binding Data.Commands.SaveCommand,Source={StaticResource ResourceKey=DATA}}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  BorderThickness="0"  FontFamily="{DynamicResource ResourceKey={x:Static fw:FontsUtil.AwesomeKey}}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{fw:FontIcon Icon=Save}"  Width="30" FontSize="20"></TextBlock>
                        <TextBlock Text="保存" VerticalAlignment="Center" Margin="-5,0,0,0"></TextBlock>
                    </StackPanel>
                </Button.Content>
            </Button>
        </StackPanel>

    </fw:NChildWindow.AttachElement>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*" MinHeight="200"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" 
                        VerticalAlignment="Center" HorizontalAlignment="Left">
                <!--<TextBlock Text="{Binding ManufactureName,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" MinWidth="60" MaxWidth="160" VerticalAlignment="Center"></TextBlock>-->
                <fw:TextBoxEditor Text="{Binding ManufactureName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" MinWidth="100" MaxWidth="260" BorderThickness="0"  Margin="5"
                                 Command="{x:Static bllCommon:EditCommands.SingleUpdate}" CommandParameter="{Binding RelativeSource={RelativeSource Self}}">
                </fw:TextBoxEditor>
                <!--<Button Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  Height="23"  Margin="10"  fw:ButtonOptions.Icon="../Images/修改.jpg" Padding="0"/>-->

            </StackPanel>
            <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
                <Button Command="{Binding Commands.AddBranchCommand}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  Height="23"  Margin="10" Content="添加品牌"/>
                <Button Command="{Binding Commands.AddProductCommand}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  Height="23" Margin="10" Content="添加产品" />
            </StackPanel>
        </Grid>
        <ListBox Grid.Row="1" Grid.Column="0" ItemsSource="{Binding Brands}" SelectedItem="{Binding CurrentSelectedBrand,Mode=TwoWay}" fw:ItemsControlOptions.MarkIndex="True">
            <ListBox.ItemsPanel >
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemContainerStyle>

                <Style TargetType="{x:Type ListBoxItem}">

                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="|" x:Name="Txt"></TextBlock>
                                    <TextBlock Margin="5,0,5,0" x:Name="TXTN" Text="{Binding Name}" Foreground="Blue"  TextDecorations="Underline">


                                    </TextBlock>
                                    <Button x:Name="BTNU" Content="修改" Visibility="Collapsed" Command="{Binding Data.Commands.UpdateBranchCommand,Source={StaticResource ResourceKey=DATA}}" CommandParameter="{Binding}" VerticalAlignment="Center" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"   fw:ButtonOptions.Icon="../Images/修改.jpg" Height="20" Width="20" Padding="0"></Button>
                                </StackPanel>
                                <ControlTemplate.Triggers>
                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource PreviousData}}"
                                                 Value="{x:Null}">
                                        <Setter TargetName="Txt" Property="Visibility" Value="Collapsed"></Setter>
                                    </DataTrigger>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter TargetName="BTNU" Property="Visibility" Value="Visible"></Setter>
                                        <Setter TargetName="TXTN" Property="Foreground" Value="Black"></Setter>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>


        <DataGrid Grid.Row="2" Grid.Column="0"   AutoGenerateColumns="False" SelectionMode="Single"  FrozenColumnCount="1" ItemsSource="{Binding ProductItems,UpdateSourceTrigger=PropertyChanged}"
                CanUserAddRows="False"
                CanUserDeleteRows="False"
                VerticalScrollBarVisibility="Auto"
                HorizontalScrollBarVisibility="Auto"
                SelectionUnit="FullRow"
                HeadersVisibility="Column" 
                CanUserSortColumns="True"   
                  dgx:DataGridFilter.IsAutoFilterEnabled="True"
                CellStyle="{StaticResource ResourceKey={x:Static uc:CommonStyles.DataGridCellKey}}"
                  AlternationCount="2"
                >
            <DataGrid.RowStyle>
                <Style TargetType="DataGridRow" BasedOn="{StaticResource ResourceKey={x:Type DataGridRow}}">
                    <Setter Property="ContextMenu">
                        <Setter.Value>
                            <ContextMenu>
                                <MenuItem Header="删除" Command="{Binding Data.Commands.DeleteCommand,Source={StaticResource ResourceKey=DATA}}" CommandParameter="{Binding }"></MenuItem>
                            </ContextMenu>
                        </Setter.Value>

                    </Setter>
                    <Setter Property="Height" Value="30"></Setter>
                    <Style.Triggers>
                        <Trigger Property="ItemsControl.AlternationIndex"
                                 Value="0">
                            <Setter Property="Background" Value="White" />
                        </Trigger>
                        <Trigger Property="ItemsControl.AlternationIndex"
                                 Value="1">
                            <Setter Property="Background" Value="#FFE6E3DD" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </DataGrid.RowStyle>
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="操作"  Width="150" IsReadOnly="True" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Button IsEnabled="False" Command="{Binding Data.Commands.ManageTypeCommand,Source={StaticResource ResourceKey=DATA} }" CommandParameter="{Binding}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}"   Content="管理常见问题" HorizontalAlignment="Left" Padding="5,0,5,0"/>
                                <Button Command="{Binding Data.Commands.ManageTypeCommand,Source={StaticResource ResourceKey=DATA} }" CommandParameter="{Binding}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}"   Content="管理型号" HorizontalAlignment="Left" Padding="5,0,5,0"/>
                            </StackPanel>

                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                </DataGridTemplateColumn>
                <fw:TDataGridTextColumn Header="产品" Width="100"   Binding="{Binding Path=ProductName}"></fw:TDataGridTextColumn>
                <fw:TDataGridTextColumn Header="所属设备族" MinWidth="100"  Width="*" IsReadOnly="True"  Binding="{Binding Path=OwnerFamily}"></fw:TDataGridTextColumn>

                <fw:TDataGridTextColumn Header="常用故障判断" MinWidth="100" Width="*" IsReadOnly="True"  Binding="{Binding Path=ComonError}"></fw:TDataGridTextColumn>
                <fw:TDataGridTextColumn Header="型号" MinWidth="100"  Width="*" IsReadOnly="True"  Binding="{Binding Path=ContainTypes,Converter={x:Static wpf:ConverterFactory.ItemsToString}}"></fw:TDataGridTextColumn>
            </DataGrid.Columns>
            <i:Interaction.Behaviors>
                <behaviors:GridCellSingleClickEditBehavior></behaviors:GridCellSingleClickEditBehavior>
            </i:Interaction.Behaviors>

        </DataGrid>

        <GroupBox MaxHeight="170" Grid.Row="3" Grid.Column="0"  Margin="0,10,0,0" Header="使用该厂家产品的所有项目"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.GroupBoxKey}}"  >

            <ListBox ItemsSource="{Binding ProjectAssetItems}" BorderThickness="0"  ScrollViewer.HorizontalScrollBarVisibility="Auto" Margin="-5,0,-5,0">
                <ListBox.ItemsPanel >
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal"  Width="{Binding Path=Width,RelativeSource={RelativeSource AncestorType=ListBox}}"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ListBoxItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                    <Border BorderThickness="1"  BorderBrush="Black" Margin="5" Padding="5" fw:MaskOptions.IsManualHide="true" fw:MaskOptions.IsShow="{Binding IsLoading}">
                                        <fw:MaskOptions.MaskTemplate>
                                            <ControlTemplate>
                                                <Border Background="Gray" Opacity="0.5">
                                                    <ProgressBar  VerticalAlignment="Center" Margin="5" IsIndeterminate="True"></ProgressBar>
                                                </Border>
                                            </ControlTemplate>
                                        </fw:MaskOptions.MaskTemplate>

                                        <Grid Width="150" Height="80" >
                                            <Grid.RowDefinitions>
                                                <RowDefinition></RowDefinition>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                            </Grid.RowDefinitions>
                                            <StackPanel Orientation="Vertical" Grid.Row="0">
                                                <Grid>
                                                   
                                                    <TextBlock Margin="5,0,5,0" Name="TxtName" FontSize="20" Text="{Binding ProjectLocalName}"></TextBlock>
                                                     <Button  HorizontalAlignment="Right" VerticalAlignment="Center" Content="刷新" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}" Command="{Binding Data.Commands.RefreshCommand,Source={StaticResource ResourceKey=DATA}}" CommandParameter="{Binding}" ></Button>
                                                </Grid>

                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,5,0"  Text="涉及资产："  />
                                                    <TextBlock Margin="5,0,5,0" x:Name="TXTN" Text="{Binding AssetCount}" TextDecorations="Underline"/>
                                                    <TextBlock Margin="5,0,5,0"  Text="个" />
                                                </StackPanel>
                                            </StackPanel>
                                            <Button Grid.Row="1" Grid.Column="0" x:Name="BTNU" HorizontalAlignment="Right" Content="资产清单" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}" Command="{Binding Data.Commands.GoAssetCommand,Source={StaticResource ResourceKey=DATA}}" CommandParameter="{Binding}" ></Button>
                                        </Grid>
                                    </Border>

                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
        </GroupBox>

        <GroupBox MaxHeight="170" Grid.Row="4" Grid.Column="0"  Margin="0,10,0,0" Header="供应该厂家产品的所有供应商"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.GroupBoxKey}}">
            <ListBox ItemsSource="{Binding SellerItems}" BorderThickness="0"  ScrollViewer.HorizontalScrollBarVisibility="Auto" Margin="-5,0,-5,0">
                <ListBox.ItemsPanel >
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal"  Width="{Binding Path=Width,RelativeSource={RelativeSource AncestorType=ListBox}}"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ListBoxItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                    <Border BorderThickness="1"  BorderBrush="Black" Margin="5" Padding="5">
                                        <Grid Width="180" Height="110" >
                                            <Grid.RowDefinitions>
                                                <RowDefinition></RowDefinition>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                            </Grid.RowDefinitions>
                                            <StackPanel Orientation="Vertical" Grid.Row="0">
                                                <TextBlock Margin="5,0,5,0"  FontSize="20" Text="{Binding VenderName}"></TextBlock>
                                                <TextBlock Margin="5,0,5,0" Text="{Binding WebSite}"></TextBlock>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,5,0"  Text="供应名录中涉及我的品牌："  />
                                                    <TextBlock Margin="2,0,2,0"  Text="{Binding BrandCount}" TextDecorations="Underline"/>
                                                    <TextBlock Margin="2,0,2,0"  Text="个" />
                                                </StackPanel>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,5,0"  Text="涉及产品："  />
                                                    <TextBlock Margin="2,0,2,0"  Text="{Binding ProductCount}" TextDecorations="Underline"/>
                                                    <TextBlock Margin="2,0,2,0"  Text="个" />
                                                </StackPanel>
                                            </StackPanel>
                                            <Button Grid.Row="1" Grid.Column="0" x:Name="BTNU" HorizontalAlignment="Right" Content="查看供应名录" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}" Command="{Binding Data.Commands.ScanRefTypesCommand,Source={StaticResource ResourceKey=DATA}}" CommandParameter="{Binding}" ></Button>
                                        </Grid>
                                    </Border>

                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
        </GroupBox>

        <GroupBox MaxHeight="170" Grid.Row="5" Grid.Column="0"  Margin="0,10,0,0" Header="维修该厂家产品的所有维修商"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.GroupBoxKey}}">
            <ListBox ItemsSource="{Binding MaintainerItems}" BorderThickness="0"  ScrollViewer.HorizontalScrollBarVisibility="Auto" Margin="-5,0,-5,0">
                <ListBox.ItemsPanel >
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal"  Width="{Binding Path=Width,RelativeSource={RelativeSource AncestorType=ListBox}}"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ListBoxItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                    <Border BorderThickness="1"  BorderBrush="Black" Margin="5" Padding="5">
                                        <Grid Width="180" Height="110" >
                                            <Grid.RowDefinitions>
                                                <RowDefinition></RowDefinition>
                                                <RowDefinition Height="Auto"></RowDefinition>
                                            </Grid.RowDefinitions>
                                            <StackPanel Orientation="Vertical" Grid.Row="0">
                                                <TextBlock Margin="5,0,5,0"  FontSize="20" Text="{Binding VenderName}"></TextBlock>
                                                <TextBlock Margin="5,0,5,0" Text="{Binding WebSite}"></TextBlock>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,5,0"  Text="维修名录中涉及我的品牌："  />
                                                    <TextBlock Margin="2,0,2,0"  Text="{Binding BrandCount}" TextDecorations="Underline"/>
                                                    <TextBlock Margin="2,0,2,0"  Text="个" />
                                                </StackPanel>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Margin="5,0,5,0"  Text="涉及产品："  />
                                                    <TextBlock Margin="2,0,2,0"  Text="{Binding ProductCount}" TextDecorations="Underline"/>
                                                    <TextBlock Margin="2,0,2,0"  Text="个" />
                                                </StackPanel>
                                            </StackPanel>
                                            <Button Grid.Row="1" Grid.Column="0" x:Name="BTNU" HorizontalAlignment="Right" Content="查看维修名录" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}" Command="{Binding Data.Commands.ScanRefTypesCommand,Source={StaticResource ResourceKey=DATA}}" CommandParameter="{Binding}" ></Button>
                                        </Grid>
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
        </GroupBox>
    </Grid>
</fw:NChildWindow>

