<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maintain.ViewModels.MaintainEventView"
             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:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
             xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:micro="clr-namespace:Caliburn.Micro"
             xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.Maintain"
             xmlns:rtinfo="clr-namespace:MECF.Framework.Common.Aitex.Core.RT.EMS;assembly=MECF.Framework.Common"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:cv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
             mc:Ignorable="d" 
             d:DesignHeight="1024" 
             d:DesignWidth="1900">
    <UserControl.Resources>
        <cv:BoolReverseConverter x:Key="boolReverseConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*" />
            <ColumnDefinition Width="11*" />
        </Grid.ColumnDefinitions>

        <StackPanel Grid.Column="0">
            <!--  Query Condition Card  -->
            <GroupBox BorderThickness="1" Header="Query Condition">
                <StackPanel Margin="0,5">
                    <StackPanel.Resources>
                        <!--<Style TargetType="toolkit:DateTimeUpDown">
                            <Setter Property="Width" Value="170" />
                            <Setter Property="Format" Value="Custom" />
                            <Setter Property="FormatString" Value="yyyy/MM/dd HH:mm:ss" />
                        </Style>-->
                    </StackPanel.Resources>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Width="70" VerticalAlignment="Center" FontFamily="Arial" FontSize="14" Foreground="{StaticResource FG_Black}" Text="Start Time" />
                        <WindowsFormsHost Width="170" Height="22" Margin="5,0,0,0" VerticalAlignment="Center" FontFamily="Arial" FontSize="14">
                            <forms:DateTimePicker x:Name="wfTimeFrom" CustomFormat="yyyy/MM/dd HH:mm:ss" Format="Custom" Value="2011-8-1"/>
                        </WindowsFormsHost>
                    </StackPanel>
                    <StackPanel Margin="0,5,0,0" Orientation="Horizontal">
                        <TextBlock Width="70" VerticalAlignment="Center" FontFamily="Arial" FontSize="14" Foreground="{StaticResource FG_Black}" Text="End Time" />
                        <WindowsFormsHost Width="170" Height="22" Margin="5,0,0,0" VerticalAlignment="Center" FontFamily="Arial" FontSize="14">
                            <forms:DateTimePicker x:Name="wfTimeTo" CustomFormat="yyyy/MM/dd HH:mm:ss" Format="Custom" Value="2011-8-1" />
                        </WindowsFormsHost>
                    </StackPanel>
                </StackPanel>
            </GroupBox>

            <!--  Query Condition Card  -->
            <GroupBox Header="Query Option-Plan">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.Row="0">
                        <TextBlock Width="70" VerticalAlignment="Center" FontFamily="Arial" FontSize="14" Foreground="{StaticResource FG_Black}" Text="Plan" />
                        <ComboBox Grid.Column="1" Margin="0,5,0,5" FontSize="18" Text="{Binding SearchPlanName}" MinWidth="120"
                                  VerticalAlignment="Center" ItemsSource="{Binding PlanNames}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding }" FontSize="18" VerticalAlignment="Center"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Row="1">
                        <TextBlock Width="70" VerticalAlignment="Center" FontFamily="Arial" FontSize="14" Foreground="{StaticResource FG_Black}" Text="Module" />
                        <ComboBox Grid.Column="1" Margin="0,5,0,5" FontSize="18" Text="{Binding SearchPlanModule}" MinWidth="120"
                                VerticalAlignment="Center" ItemsSource="{Binding PlanModules}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate DataType="{x:Type rtinfo:MaintainerInfo}">
                                    <TextBlock Text="{Binding }" FontSize="18" VerticalAlignment="Center"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </StackPanel>
                </Grid>
                
            </GroupBox>

            <!--  Query Condition Card  -->
            <GroupBox Header="Query Option-Item">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" Grid.Row="0">
                        <TextBlock Width="70" VerticalAlignment="Center" FontFamily="Arial" FontSize="14" Foreground="{StaticResource FG_Black}" Text="Item" />
                        <ComboBox Grid.Column="1" Margin="0,5,0,5" FontSize="18" Text="{Binding SearchParentItemName}" MinWidth="120"
                      VerticalAlignment="Center" ItemsSource="{Binding ParentItemNames}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding }" FontSize="18" VerticalAlignment="Center"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Row="1">
                        <TextBlock Width="70" VerticalAlignment="Center" FontFamily="Arial" FontSize="14" Foreground="{StaticResource FG_Black}" Text="ItemName" />
                        <ComboBox Grid.Column="1" Margin="0,5,0,5" FontSize="18" Text="{Binding SearchItemName}" MinWidth="120"
                    VerticalAlignment="Center" ItemsSource="{Binding ItemNames}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding }" FontSize="18" VerticalAlignment="Center"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Grid.Row="2">
                        <TextBlock Width="70" VerticalAlignment="Center" FontFamily="Arial" FontSize="14" Foreground="{StaticResource FG_Black}" Text="Index" />
                        <ComboBox Grid.Column="1" Margin="0,5,0,5" FontSize="18" Text="{Binding SearchIndex}" MinWidth="80"
                                  VerticalAlignment="Center" ItemsSource="{Binding ItemIndexs}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding }" FontSize="18" VerticalAlignment="Center"/>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </StackPanel>
                </Grid>

            </GroupBox>

            <!--  Extra Condition  -->
            <GroupBox Header="Extra Condition">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Row="0" Margin="0,5" Orientation="Horizontal">
                        <TextBlock VerticalAlignment="Center" FontFamily="Arial" FontSize="14" Text="Key Words" />
                        <TextBox Width="170" Margin="5,0,0,0" FontSize="14" Text="{Binding SearchKeyWords, UpdateSourceTrigger=PropertyChanged}" />
                    </StackPanel>
                    <Button Grid.Row="1" Width="80" Height="25" Content="Filter" FontFamily="Arial" HorizontalAlignment="Right">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <micro:ActionMessage MethodName="Filter"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Grid>
                
            </GroupBox>

            <!--  Query and Export Buttons Card  -->
            <Grid Grid.Row="6" Margin="84,18,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Button Width="100" Height="30" Content="Query" FontFamily="Arial">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="Query">
                                <micro:ActionMessage.Parameters>
                                    <!--  首次查询  -->
                                    <micro:Parameter Value="-1" />
                                </micro:ActionMessage.Parameters>
                            </micro:ActionMessage>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>

                <Grid Grid.Row="0" Grid.Column="1" Margin="10,0,0,0">
                    <TextBlock VerticalAlignment="Center" FontSize="9" Text="Loading..." Visibility="{Binding IsLoading, Converter={StaticResource BoolVisibilityConverter}}" />
                </Grid>

            </Grid>
        </StackPanel>
        <Grid Grid.Column="1" Margin="10,0,0,0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="35" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0" Orientation="Horizontal">

                    <TextBlock
                VerticalAlignment="Center"
                FontSize="16"
                Text="Show" />

                    <ComboBox
                Width="100"
                Height="23"
                Margin="5,0,0,0"
                FontSize="13"
                IsEnabled="{Binding IsLoading, Converter={StaticResource boolReverseConverter}}"
                ItemsSource="{Binding PaginationCapacity}"
                SelectedItem="{Binding SelectedPaginationCapacity}" />

                    <TextBlock
                Margin="5,0,0,0"
                VerticalAlignment="Center"
                FontSize="16"
                Text="Items Per Page " />

                    <Button
                Height="29"
                Margin="10,0,0,0"
                Command="{Binding NavigateCommand}"
                CommandParameter="first"
                Content="|&lt; First"
                FontFamily="Arial,SimSun"
                FontSize="15"
                IsEnabled="{Binding IsLoading, Converter={StaticResource boolReverseConverter}}" />

                    <Button
                Height="29"
                Margin="10,0,0,0"
                Command="{Binding NavigateCommand}"
                CommandParameter="previous"
                Content="&lt;&lt; Previous"
                FontFamily="Arial,SimSun"
                FontSize="15"
                IsEnabled="{Binding IsLoading, Converter={StaticResource boolReverseConverter}}" />

                    <TextBlock
                Width="100"
                Margin="10,0,0,0"
                VerticalAlignment="Center"
                FontSize="16"
                Text="{Binding PageInfo}"
                TextAlignment="Center" />


                    <Button
                Height="29"
                Margin="10,0,0,0"
                Command="{Binding NavigateCommand}"
                CommandParameter="next"
                Content="Next &gt;&gt;"
                FontFamily="Arial,SimSun"
                FontSize="15"
                IsEnabled="{Binding IsLoading, Converter={StaticResource boolReverseConverter}}" />

                    <Button
                Height="29"
                Margin="10,0,0,0"
                Command="{Binding NavigateCommand}"
                CommandParameter="last"
                Content="Last &gt;|"
                FontFamily="Arial,SimSun"
                FontSize="15"
                IsEnabled="{Binding IsLoading, Converter={StaticResource boolReverseConverter}}" />

                    <TextBlock
                Margin="20,0,0,0"
                VerticalAlignment="Center"
                FontSize="16"
                Text="Quick GoTo" />

                    <ComboBox
                Width="100"
                Height="25"
                Margin="5,0,0,0"
                FontSize="13"
                IsEnabled="{Binding IsLoading, Converter={StaticResource boolReverseConverter}}"
                ItemsSource="{Binding Path=PaginationSource, Mode=OneWay}"
                SelectedValue="{Binding Path=SelectedPage, Mode=TwoWay, Delay=10}" />
                </StackPanel>

                <DataGrid Name="dataGrid1" Grid.Row="1" Width="Auto" Margin="0,5,0,0" 
                          AutoGenerateColumns="False" CanUserAddRows="False" CanUserReorderColumns="False" CanUserSortColumns="False"
                          FontSize="13" IsReadOnly="True" ItemsSource="{Binding SearchedResult, Mode=OneWay}" SelectionMode="Single"
                          SelectionUnit="FullRow" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto"
                          ScrollViewer.VerticalScrollBarVisibility="Auto" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling">
                    <DataGrid.Columns>
                        <DataGridTemplateColumn Width="Auto" MinWidth="150" Header="Time">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                                               FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding MaintainTime}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTemplateColumn Width="Auto" MinWidth="100" Header="Plan">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                               FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding PlanName}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="80" Header="Module">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                               FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding PlanModule}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="100" Header="Item">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                                               FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding ParentItemName}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="100" Header="Name">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                                               FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding ItemName}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="40" Header="Index">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                               FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding Index}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="150" Header="Description">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                                               FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding Description}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="80" Header="Recorder">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                       FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding Recorder}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        
                        <DataGridTemplateColumn Width="Auto" MinWidth="200" Header="Record">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type local:MaintainEventInfo}">
                                    <TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontFamily="Arial" 
                                               FontSize="14" Foreground="{DynamicResource FG_Black}" Text="{Binding Record}" TextWrapping="Wrap"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        
                    </DataGrid.Columns>
                </DataGrid>

            </Grid>
        </Grid>
    </Grid>
</UserControl>
