<UserControl x:Class="StartServerWPF.Modules.Main.Views.MainView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:StartServerWPF.Modules.Main.Views"
             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"
             mc:Ignorable="d" 
             d:DesignHeight="800" d:DesignWidth="1200"  Background="LightGray"
             xmlns:prism="http://prismlibrary.com/"  
             prism:ViewModelLocator.AutoWireViewModel="True" >
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/StartServerWPF.Assets;component/Styles/BaseResources.xaml"/>
                <!--<ResourceDictionary Source="/Detection.platform.Assets;component/Styles/ButtonStyles.xaml"/>-->
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <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>
    <Grid >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="460"/>
            <ColumnDefinition Width="23*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="10*"/>
            <RowDefinition Height="10*"/>
            <RowDefinition Height="10"/>
        </Grid.RowDefinitions>
        <Border  Margin="10"  CornerRadius="5"  Background="White">
            <Grid  >
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock Text="系统控制" FontSize="22" Margin="20,10,0,10"/>
                <Grid Grid.Row="1" Margin="110,0,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="1*"/>
                        <RowDefinition Height="1*"/>
                        <RowDefinition Height="1*"/>
                        <RowDefinition Height="1*"/>
                        <RowDefinition Height="5*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="2*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="连接VPN:" VerticalAlignment="Center" FontSize="20" />
                    <CheckBox  IsChecked="{Binding VPNIsConnect}" Command="{Binding ConnectVPNCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}" Style="{StaticResource ToggleButtonSwitch}" x:Name="rtnConnect"   Grid.Column="1" HorizontalAlignment="Left" FontSize="20">
                    </CheckBox>
                    <TextBlock Grid.Row="1" Grid.Column="0"  FontSize="20" Text="连接状态："  VerticalAlignment="Center"/>
                    <TextBlock Grid.Row="1" Grid.Column="1" FontSize="20" Text="{Binding VPNStatus}" Foreground="{Binding VPNStatusForeColor}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                    <Button  Grid.Row="1" Grid.Column="2" FontSize="15" Content="检查状态" Command="{Binding GetVPNStatusCommand}"  HorizontalAlignment="Right" Margin="0,0,10,0"/>
                    <TextBlock Grid.Row="2" Grid.Column="0" FontSize="20" Text="IP 地址:" VerticalAlignment="Center"  />
                    <TextBlock  Grid.Row="2" Grid.Column="1" FontSize="20" Text="{Binding VpnIP}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                    <!--<Button Content="参数设置" Grid.Column="2" Grid.Row="2"  Command="{Binding SetVPNParaCommand}"  VerticalAlignment="Center"/>-->
                    <!--<Button Content="运行日志" Grid.Row="2" Grid.Column="2"  Command="{Binding DisplayLogCommand}" VerticalAlignment="Center"/>-->
                    <Grid  Grid.Row="4" Grid.ColumnSpan="3" IsEnabled="{Binding ElementName=rtnConnect,Path=IsChecked}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="1*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="35"/>
                        </Grid.RowDefinitions>
                        <TextBlock Text="启动服务:" VerticalAlignment="Center" FontSize="20"/>
                        <CheckBox  IsChecked="False" Name="cBoxService" Command="{Binding StartCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self}}" Style="{StaticResource ToggleButtonSwitch}"    Grid.Column="1" HorizontalAlignment="Left">
                        </CheckBox>
                        <TextBlock Grid.Row="1" Grid.Column="0" FontSize="20" Text="启动时间："  VerticalAlignment="Center"/>
                        <TextBlock Grid.Row="1" Grid.Column="1" FontSize="20" Text="{Binding StartTime,StringFormat=yyyy-MM-dd HH:mm:ss}"  VerticalAlignment="Center" HorizontalAlignment="Left"/>
                        <TextBlock Grid.Row="2" Grid.Column="0" FontSize="20" Text="运行时间："  VerticalAlignment="Center"/>
                        <TextBlock Grid.Row="2" Grid.Column="1" FontSize="20" Text="{Binding RunTime,StringFormat=yyyy-MM-dd HH:mm:ss}"  VerticalAlignment="Center" HorizontalAlignment="Left"/>
                        <TextBlock Grid.Row="3" Grid.Column="0" FontSize="20" Text="监隔间隔(s):"  VerticalAlignment="Center"/>
                        <ComboBox Grid.Row="3" Grid.Column="1"  ItemsSource="{Binding IntervalTimesSource}" SelectedIndex="{Binding SelectedIndex}" Text="{Binding ProMonInterval}" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="20"/>
                        <!--<RadioButton GroupName="start" Content="一键启动" Grid.Column="0" VerticalAlignment="Center">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Checked">
                                <i:InvokeCommandAction Command="{Binding OneKeyStartCommand}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </RadioButton>
                    <RadioButton GroupName="start" Content="全部关闭" IsChecked="True" Grid.Column="1" VerticalAlignment="Center">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Checked">
                                <i:InvokeCommandAction Command="{Binding OneKeyStopCommand}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </RadioButton>-->
                        <!--<Button Content="实时波形" Command="{Binding DisplayRealWavesCommand}" Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right"/>-->
                    </Grid>
                </Grid>
            </Grid>
        </Border>
        <Border Grid.Row="1"  Margin="10"  CornerRadius="5"  Background="White">
            <StackPanel >
                <TextBlock Text="程序运行状态" FontSize="22" Margin="20,10,0,10"/>
                <Grid Margin="10">
                    <DataGrid  ItemsSource="{Binding ProcessDataSource}"  Background="White"  IsReadOnly="True" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="程序" Width="80"  Binding="{Binding ProcessTile}"/>
                            <DataGridTextColumn Header="进程"  Width="90" Binding="{Binding ProName}"/>
                            <DataGridTextColumn Header="监控时间" Width="*" Binding="{Binding MonitorTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}"/>
                            <DataGridTextColumn Header="运行状态" Width="80" Binding="{Binding ProcessStatus}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                    <!--<ProgressBar Grid.Row="4" Grid.ColumnSpan="3" VerticalAlignment="Bottom" IsIndeterminate="{Binding IsIndeterminate}" Foreground="Green"  Value="0"/>-->
                </Grid>
                <UniformGrid Rows="1" IsEnabled="{Binding ElementName=cBoxService, Path=IsChecked, Converter={StaticResource Boolean2BooleanReConverter}}">
                    <CheckBox Content="数据处理" IsChecked="{Binding ApmsIsEnable}"  Style="{StaticResource ToggleButtonSwitch}" Width="100"/>
                    <CheckBox Content="结果处理" IsChecked="{Binding ToolsIsEnable}" Style="{StaticResource ToggleButtonSwitch}" Width="100"/>
                </UniformGrid>
            </StackPanel>
        </Border>
        <UniformGrid Grid.Column="1" Grid.RowSpan="2"  Columns="1" >
            <Border  CornerRadius="5" Background="White" Margin="5">
                <Grid Margin="10">
                    <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>
            </Border>
            <Border  CornerRadius="5" Background="White" Margin="5">
                <Grid Margin="10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="61*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="后处理事件" FontSize="15"/>
                    <DataGrid Grid.Row="1"  ItemsSource="{Binding ToolsEventSource}"  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 EarthquakeSource}"/>
                        </DataGrid.Columns>
                    </DataGrid>

                </Grid>
            </Border>
            <Border  CornerRadius="5" Background="White" Margin="5">
                <Grid Margin="10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="61*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="实时处理程序信息" FontSize="15"/>
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition  Width="150"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="消息时间"  HorizontalAlignment="Center"/>
                        <TextBlock Grid.Column="1" Text="消息内容" HorizontalAlignment="Center"/>
                    </Grid>
                    <ListBox Grid.Row="2"   ItemsSource="{Binding ApmsProcessSliceSource}" 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>

                </Grid>
            </Border>
            <Border  CornerRadius="5" Background="White" Margin="5">
                <Grid Margin="10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="61*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="后处理程序信息" FontSize="15"/>
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition  Width="150"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="消息时间"  HorizontalAlignment="Center"/>
                        <TextBlock Grid.Column="1" Text="消息内容" HorizontalAlignment="Center"/>
                    </Grid>
                    <ListBox Grid.Row="2"   ItemsSource="{Binding ToolsProcessSliceSource}" 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>
                </Grid>
            </Border>
        </UniformGrid>
    </Grid>
</UserControl>
