<UserControl x:Class="StartServerWPF.Modules.Main.Views.DataProcessView"
             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:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:prism="http://prismlibrary.com/" 
             xmlns:hc="https://handyorg.github.io/handycontrol"
             prism:ViewModelLocator.AutoWireViewModel="True"
            xmlns:local="clr-namespace:StartServerWPF.Modules.Main.Views"
             mc:Ignorable="d" Background="#FFEEF1F3"
             d:DesignHeight="600" d:DesignWidth="900">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>

            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="60"/>
            <RowDefinition Height="4*"/>
        </Grid.RowDefinitions>
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Loaded">
                <i:InvokeCommandAction Command="{Binding Path=LoadedCommand}"/>
            </i:EventTrigger>
            <!--<i:EventTrigger EventName="Unloaded">
                <i:InvokeCommandAction Command="{Binding Path=UnloadedCommand}"/>
            </i:EventTrigger>-->
        </i:Interaction.Triggers>

        <Border Background="White">
            <TextBlock Text="{Binding Title}" FontSize="16" FontWeight="Bold" VerticalAlignment="Center"  Margin="10,0,10,0"/>
        </Border>
        <Border Background="White"  Grid.Row="1" CornerRadius="5" Margin="10">
            <Grid Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition  Height="1*" />
                    <RowDefinition  Height="200" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1.5*"/>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="2*"/>
                </Grid.ColumnDefinitions>
                <Border  Grid.Row="0">
                    <UniformGrid Columns="1">
                        <TextBlock Text="实时处理配置" Background="Black" Foreground="White" VerticalAlignment="Center" Height="30" FontSize="18"/>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="工程文件:" Width="65" VerticalAlignment="Center"/>
                            <Button Content="..." DockPanel.Dock="Right" Visibility="Hidden" />
                            <ComboBox DockPanel.Dock="Left" ItemsSource="{Binding WorkareaNameSource}" SelectedIndex="{Binding WareaSelectedIndex}"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="配置名称:" Width="65" VerticalAlignment="Center"/>
                            <Button Content="删除"  Background="#FFA6783E" Foreground="White" DockPanel.Dock="Right" Command="{Binding DeleteCommand}"/>
                            <Button Content="添加" Background="#FF0ABEFF" Foreground="White" DockPanel.Dock="Right" Command="{Binding AddItemCommand}"/>
                            <ComboBox DockPanel.Dock="Left" ItemsSource="{Binding NameSource}" DisplayMemberPath="Name" SelectedIndex="{Binding DataSelectedIndex}"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="数据目录:"  Width="65" VerticalAlignment="Center"/>
                            <Button Content="..." Foreground="White" DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="DataPath" Background="#FF0ABEFF"/>
                            <TextBox DockPanel.Dock="Left" Text="{Binding DataPath}" IsReadOnly="True"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="结果目录:"  Width="65" VerticalAlignment="Center"/>
                            <Button Content="..." Foreground="White" DockPanel.Dock="Right" Command="{Binding SelectFileCommand}" CommandParameter="SavePath" Background="#FF0ABEFF"/>
                            <TextBox DockPanel.Dock="Left" Text="{Binding SavePath}" IsReadOnly="True"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="开始时间:"  Width="65" VerticalAlignment="Center"/>
                            <hc:DateTimePicker  DockPanel.Dock="Left" SelectedDateTime="{Binding StartSelectedDate}"/>
                        </DockPanel>
                        <DockPanel VerticalAlignment="Center">
                            <TextBlock Text="结束时间:"  Width="65" VerticalAlignment="Center"/>
                            <hc:DateTimePicker DockPanel.Dock="Left" SelectedDateTime="{Binding EndSelectedDate}"/>
                        </DockPanel>
                    </UniformGrid>
                </Border>
                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition/>
                        <RowDefinition Height="30"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="处理进程"/>
                    <Border Grid.Row="1" BorderBrush="Gray" BorderThickness="1">
                        <ListBox ItemsSource="{Binding ProcessSliceSource}" Margin="5,0,1,1" BorderThickness="0">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition  Width="150"/>
                                            <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <TextBlock Text="{Binding MonitorTime}" />
                                        <TextBlock Grid.Column="1" Text="{Binding ProcessMes}" TextWrapping="Wrap" HorizontalAlignment="Center"/>
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </Border>
                    <StackPanel Grid.Row="2" Orientation="Horizontal"  HorizontalAlignment="Center" VerticalAlignment="Center">
                        <Button  Content="保存" Background="#FF0ABEFF" Foreground="White" Command="{Binding SaveCommand}" VerticalAlignment="Bottom" Margin="0,0,30,0"/>
                        <Button  Content="开始" Background="#FF0ABEFF" Foreground="White" Command="{Binding StartCommand}" VerticalAlignment="Bottom" IsEnabled="{Binding IsBusy}"/>
                        <hc:LoadingCircle  Height="30" Visibility="{Binding IsBusy, Converter={StaticResource Boolean2VisibilityReConverter}}"/>
                    </StackPanel>
                </Grid>
                 
                <Grid Grid.Column="2" Grid.Row="0" Margin="20">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="61*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="事件列表" FontSize="15" VerticalAlignment="Center" />
                    <DataGrid Grid.Row="1" ItemsSource="{Binding ApmsEventSource}"   Background="White"  IsReadOnly="True" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="消息时间" Width="*" MinWidth="160" Binding="{Binding CurrentTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}"/>
                            <DataGridTextColumn Header="发震时刻"  Width="*" MinWidth="160" Binding="{Binding OriginTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}"/>
                            <DataGridTextColumn Header="东坐标(m)" Width="*" Binding="{Binding EastCoordinate}"/>
                            <DataGridTextColumn Header="北坐标(m)" Width="*" Binding="{Binding NorthCoordinate}"/>
                            <DataGridTextColumn Header="深度(m)" Width="*" Binding="{Binding Depth}"/>
                            <DataGridTextColumn Header="震级(ML)" Width="*" Binding="{Binding ML}"/>
                            <DataGridTextColumn Header="能量(m)" Width="*" Binding="{Binding Energy}"/>
                            <DataGridTextColumn Header="震源性质(m)" Width="*" Binding="{Binding NorthCoordinate}"/>
                            <!--<DataGridTextColumn Header="发送状态(m)" Width="*" Binding="{Binding IsSend}"/>-->
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </Grid>
        </Border>

         
    </Grid>
</UserControl>
