<fw:NChildWindow x:Class="Com.FirmLib.UI.Maintainer.WinManitainerProjectInfo"
             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:wpf="clr-namespace:FWindSoft.Wpf;assembly=FWindSoft.Wpf"
             xmlns:uc="clr-namespace:Com.FirmLib.UI.Common"
            
             xmlns:ui="clr-namespace:Com.FirmLib.UI"
             xmlns:maintainer="clr-namespace:Com.FirmLib.UI.Maintainer"
             xmlns:dgx="urn:tom-englert.de/DataGridExtensions"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="500"  Name="this" 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 wpf:FontsUtil.AwesomeKey}}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{wpf: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>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">

            <Label   Content="{Binding MaintainerName}" Margin="5,0,0,0"></Label>
            <Label  Content="{Binding MaintainerUrl}"  Margin="5,0,0,0"></Label>
            <fw:LineSpliter Margin="5,0,5,0" VerticalAlignment="Center" ></fw:LineSpliter>
            <ui:ContactInformationEditor HorizontalAlignment="Stretch" DataContext="{Binding ContactItem}"></ui:ContactInformationEditor>
        </StackPanel>

        <GridSplitter Grid.Row="0" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderThickness="1" BorderBrush="White"></GridSplitter>

        <GroupBox Grid.Row="0" Grid.Column="2"  Margin="-5,0,-5,0" Header="该厂家提供维护服务的项目设备清单"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.GroupBoxKey}}"  >
            <TabControl>
                <TabItem Header="合同有效期内的设备">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
                            <Button   Command="{Binding Commands.FilterNearCommand}"  Height="23"  Margin="10" Content="即将超出维保时间的设备">
                                <Button.Style>
                                    <Style BasedOn="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}" TargetType="Button">
                                        <Style.Triggers>
             <DataTrigger Binding="{Binding IsFilter}" Value="True">
                 <Setter Property="Foreground"
                      Value="Red"></Setter>
                 <Setter Property="Background"
                      Value="SkyBlue"></Setter>
                 <Setter Property="FontWeight"
                         Value="Bold"></Setter>
                 <Setter Property="FontSize"
                         Value="13"></Setter>
             </DataTrigger>
         </Style.Triggers>
                                    </Style>
                                </Button.Style>
                            </Button>
                            <Button  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  Command="{Binding Commands.SelectAssetCommand}"   Height="23" Margin="10" Content="选择项目内已存在的设备" />
                        </StackPanel>
                        <DataGrid fw:DataGridDragCopyOptions.CanDragCopy="True" Grid.Row="1"   AutoGenerateColumns="False" SelectionMode="Extended"  FrozenColumnCount="1" ItemsSource="{Binding CurrentAssets,UpdateSourceTrigger=PropertyChanged}"
                    CanUserAddRows="False"
                    CanUserDeleteRows="False"
                    VerticalScrollBarVisibility="Auto"
                    HorizontalScrollBarVisibility="Auto"
                    SelectionUnit="Cell"
                    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="100" IsReadOnly="True" >
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Command="{Binding Data.Commands.ScanAssetInfo,Source={StaticResource ResourceKey=DATA} }" CommandParameter="{Binding}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}"   Content="查看设备详情" Padding="5,0,5,0" HorizontalAlignment="Left"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>

                                </DataGridTemplateColumn>
                                <fw:TDataGridTextColumn Header="本地名称" Width="100" IsReadOnly="True"  Binding="{Binding Path=LocalName}"></fw:TDataGridTextColumn>
                                <fw:TDataGridTextColumn Header="本地编码"  Width="80" IsReadOnly="True"  Binding="{Binding Path=LocalCode}"></fw:TDataGridTextColumn>

                                <fw:TDataGridTextColumn Header="品牌"  Width="80" IsReadOnly="True"  Binding="{Binding Path=Brand}"></fw:TDataGridTextColumn>

                                <fw:TDataGridTextColumn Header="产品名"  Width="80" IsReadOnly="True"  Binding="{Binding Path=Product}"></fw:TDataGridTextColumn>

                                <fw:TDataGridTextColumn Header="型号"  Width="80" IsReadOnly="True"  Binding="{Binding Path=Type}"></fw:TDataGridTextColumn>
                                <DataGridTemplateColumn Header="合同截止日期" Width="120" SortMemberPath="MaintainerEndDate" fw:DataGridDragCopyOptions.CanColumnDragCopy="True">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=MaintainerEndDate,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
 <TextBlock Text="{Binding Path=MaintainerEndDate,Converter={x:Static wpf:DateTimeConverter.Date},StringFormat=yyyy年MM月dd日}"  VerticalAlignment="Center"></TextBlock>
                                            </Border>
                                           
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                       <DataGridTemplateColumn.CellEditingTemplate>
                                            <DataTemplate>
                                            <DatePicker fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=MaintainerEndDate,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" SelectedDate="{Binding Path=MaintainerEndDate,Converter={x:Static wpf:DateTimeConverter.Date}}" VerticalAlignment="Center"></DatePicker>
                                            </DataTemplate>
                                       </DataGridTemplateColumn.CellEditingTemplate>
                                </DataGridTemplateColumn>
                                 <DataGridTemplateColumn Header="保养周期" Width="80" SortMemberPath="MaintainPeriod" fw:DataGridDragCopyOptions.CanColumnDragCopy="True">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                            <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=MaintainPeriod,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
<TextBlock Text="{Binding Path=MaintainPeriod}" VerticalAlignment="Center" ></TextBlock>
                                            </Border>
                                        
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                                <DataGridTemplateColumn.CellEditingTemplate>
                                    <DataTemplate>
                                            <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=MaintainPeriod,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
<fw:DescriptionDecorator  Description="天"  Background="Black">
                        <fw:TTextBox Text="{Binding MaintainPeriod, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0">
                            <fw:TTextBox.TextControl>
                                <fw:AccessPlusDecimal></fw:AccessPlusDecimal>
                            </fw:TTextBox.TextControl>
                        </fw:TTextBox>
                    </fw:DescriptionDecorator>
                                            </Border>
                                        
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellEditingTemplate>
                            </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>
                    </Grid>
                    
                </TabItem>
                <TabItem Header="历史维护设备">
                    <DataGrid fw:DataGridDragCopyOptions.CanDragCopy="True"  AutoGenerateColumns="False"   FrozenColumnCount="1" ItemsSource="{Binding HistotyAssets,UpdateSourceTrigger=PropertyChanged}"
                CanUserAddRows="False"
                CanUserDeleteRows="False"
                VerticalScrollBarVisibility="Auto"
                HorizontalScrollBarVisibility="Auto"
                SelectionUnit="Cell"
                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="100" IsReadOnly="True" >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Command="{Binding Data.Commands.ScanAssetInfo,Source={StaticResource ResourceKey=DATA} }" CommandParameter="{Binding}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}"   Content="查看设备详情" Padding="5,0,5,0" HorizontalAlignment="Left"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>

                            </DataGridTemplateColumn>
                            <fw:TDataGridTextColumn Header="是否有其他维修商提供维保" Width="180" IsReadOnly="True"  Binding="{Binding Path=ChangeMaintainer,Converter={x:Static maintainer:WinManitainerProjectInfo.BoolConverter}}"></fw:TDataGridTextColumn>
                            <fw:TDataGridTextColumn Header="本地名称" Width="100" IsReadOnly="True"  Binding="{Binding Path=LocalName}"></fw:TDataGridTextColumn>
                            <fw:TDataGridTextColumn Header="本地编码"  Width="80" IsReadOnly="True"  Binding="{Binding Path=LocalCode}"></fw:TDataGridTextColumn>

                            <fw:TDataGridTextColumn Header="品牌"  Width="80" IsReadOnly="True"  Binding="{Binding Path=Brand}"></fw:TDataGridTextColumn>

                            <fw:TDataGridTextColumn Header="产品名"  Width="80" IsReadOnly="True"  Binding="{Binding Path=Product}"></fw:TDataGridTextColumn>

                            <fw:TDataGridTextColumn Header="型号"  Width="80" IsReadOnly="True"  Binding="{Binding Path=Type}"></fw:TDataGridTextColumn>

                            <DataGridTemplateColumn Header="合同截止日期" Width="120"  SortMemberPath="MaintainerEndDate" fw:DataGridDragCopyOptions.CanColumnDragCopy="True">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Border fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=MaintainerEndDate,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}">
                                            <TextBlock Text="{Binding Path=MaintainerEndDate,Converter={x:Static wpf:DateTimeConverter.Date},StringFormat=yyyy年MM月dd日}"  VerticalAlignment="Center"></TextBlock>
                                        </Border>

                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                                <DataGridTemplateColumn.CellEditingTemplate>
                                    <DataTemplate>
                                        <DatePicker fw:ElementCopyOptions.UseCopy="True" fw:ElementCopyOptions.CopyValue="{Binding Path=MaintainerEndDate,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" fw:ElementCopyOptions.CanEdit="{Binding ChangeMaintainer,Converter={x:Static fw:ConverterFactory.BoolOpposition}}"  IsEnabled="{Binding ChangeMaintainer,Converter={x:Static fw:ConverterFactory.BoolOpposition}}" SelectedDate="{Binding Path=MaintainerEndDate,Converter={x:Static wpf:DateTimeConverter.Date}}" VerticalAlignment="Center"></DatePicker>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellEditingTemplate>
                            </DataGridTemplateColumn>
                            <fw:TDataGridTextColumn Header="保养周期"  Width="80" IsReadOnly="True"  Binding="{Binding Path=MaintainPeriod}"></fw:TDataGridTextColumn>
                        </DataGrid.Columns>
                     
                    </DataGrid>
                </TabItem>
            </TabControl>

        </GroupBox>
    </Grid>
</fw:NChildWindow>

