<Page x:Class="FLY.Thick.FilmCasting.UI.Server.PgMain"
      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:local="clr-namespace:FLY.Thick.FilmCasting.UI.Server"
      mc:Ignorable="d" 
      d:DesignWidth="800" d:DesignHeight="500" 
      Title="PgMain">
    <Grid Background="{StaticResource IconBackground}" x:Name="grid_root">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal">
                <TextBlock Margin="20,3" VerticalAlignment="Center" FontSize="18" FontWeight="Bold">
                    <Run Text="{StaticResource str.PgMain.Header}" Foreground="{StaticResource IconForeground}" FontSize="24"/>
                    <Run Text="{StaticResource str.PgMain.SubHeader}" />
                </TextBlock>
                <Button Style="{StaticResource Styles.Button.Square.Accent2}"
                                        Content="{StaticResource str.PgMain.AddrSetting}" Command="{Binding AddrSetupCmd}"/>
            </StackPanel>

            <Button Grid.Column="1" Style="{StaticResource Styles.Button.Square.Accent2}" Width="auto"
                    Content="{StaticResource str.PgMain.Reboot}" Command="{Binding RebootCmd}"/>
        </Grid>
        <TabControl Grid.Row="1" Margin="3">
            <TabItem >
                <TabItem.Header>
                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                               Text="{StaticResource str.PgMain.Thickness}"/>
                </TabItem.Header>
                <ScrollViewer >
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <!--FOBJ服务-->
                        <GroupBox Margin="{StaticResource ControlMargin}" DataContext="{Binding SysParam}">
                            <GroupBox.Header>
                                <StackPanel Orientation="Horizontal" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                       Text="{StaticResource str.PgMain.FOBJService}"/>
                                </StackPanel>
                            </GroupBox.Header>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                       Text="{StaticResource str.PgMain.ServiceAddr}" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding Addr}"/>
                                </StackPanel>
                            </StackPanel>
                        </GroupBox>
                        <!--FOBJ服务-->
                        <GroupBox Grid.Row="1" Grid.Column="0" Margin="{StaticResource ControlMargin}" DataContext="{Binding SysParam}">
                            <GroupBox.Header>
                                <StackPanel Orientation="Horizontal" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                       Text="{StaticResource str.PgMain.WsService}"/>
                                </StackPanel>
                            </GroupBox.Header>
                            <StackPanel>
                                <StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                       Text="{StaticResource str.PgMain.ServiceAddr}" />
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding WsAddr}"/>
                                </StackPanel>
                            </StackPanel>
                        </GroupBox>
                        <!--WebAPI服务-->
                        <GroupBox Grid.Row="2" Grid.Column="0" Margin="{StaticResource ControlMargin}" DataContext="{Binding WebApiServer}">
                            <GroupBox.Header>
                                <StackPanel Orientation="Horizontal" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="{StaticResource str.PgMain.WebAPIService}"/>
                                    <TextBlock>
                                        [<TextBlock>
                                            <TextBlock.Style>
                                                <Style TargetType="TextBlock" >
                                                    <Setter Property="Foreground" Value="Red"/>
                                                    <Setter Property="Text" Value="{StaticResource str.PgMain.StateIsStopping}"/>
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding IsRunning}" Value="True">
                                                            <Setter Property="Foreground" Value="Green"/>
                                                            <Setter Property="Text" Value="{StaticResource str.PgMain.StateIsWorking}"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>]
                                        </TextBlock>
                                </StackPanel>
                            </GroupBox.Header>

                            <StackPanel Margin="{StaticResource ControlMargin}" >
                                <StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}">
                                            <Run Text="{StaticResource str.PgMain.Addr}"/>
                                    </TextBlock>
                                    <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding ServerAddr}"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <Button Style="{StaticResource Styles.Button.Square2}" Content="{StaticResource str.PgMain.OpenSwaggerUI}" Command="{Binding DataContext.OpenLinkCmd,ElementName=grid_root}"/>
                                </StackPanel>

                            </StackPanel>
                        </GroupBox>

                        <!--采集器-->
                        <GroupBox Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" Margin="{StaticResource ControlMargin}" DataContext="{Binding FlyAd}">
                            <GroupBox.Header>
                                <StackPanel Orientation="Horizontal" >
                                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="{StaticResource str.PgMain.FlyAd}"/>
                                    <TextBlock>
                                                [<TextBlock>
                                            <TextBlock.Style>
                                                <Style TargetType="TextBlock" >
                                                    <Setter Property="Foreground" Value="Red"/>
                                                    <Setter Property="Text" Value="{StaticResource str.PgMain.Disconnected}"/>
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding IsConnected}" Value="True">
                                                            <Setter Property="Foreground" Value="Green"/>
                                                            <Setter Property="Text" Value="{StaticResource str.PgMain.Connected}"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                            </TextBlock>]
                                            </TextBlock>
                                </StackPanel>
                            </GroupBox.Header>
                            <StackPanel>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <StackPanel>
                                        <StackPanel Orientation="Horizontal"
                                                            Margin="{StaticResource ControlMargin}">
                                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                               Text="{StaticResource str.PgMain.Addr}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent}"
                                                               Text="{Binding Addr}" />
                                        </StackPanel>

                                        <StackPanel Orientation="Horizontal"
                                                            Margin="{StaticResource ControlMargin}">
                                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                               Text="{StaticResource str.PgMain.Now}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent}"
                                                               Text="{Binding Now,StringFormat={}{0:HH:mm:ss}}" />
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <StackPanel Orientation="Horizontal"
                                                                Margin="{StaticResource ControlMargin}">
                                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                                   Text="AD" />
                                                <TextBlock Style="{StaticResource Styles.Text.FieldContent}">
                                                        <Run  Text="{Binding AD,Mode=OneWay}" />
                                                </TextBlock>
                                            </StackPanel>
                                            <StackPanel Orientation="Horizontal"
                                                                Margin="{StaticResource ControlMargin}">
                                                <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                                   Text="{StaticResource str.PgMain.Pulse}" />
                                                <TextBlock Style="{StaticResource Styles.Text.FieldContent}">
                                                        <Run  Text="{Binding Position,Mode=OneWay}" />p
                                                </TextBlock>
                                            </StackPanel>
                                        </StackPanel>
                                    </StackPanel>
                                    <StackPanel Grid.Column="1">
                                        <StackPanel Orientation="Horizontal"
                                                            Margin="{StaticResource ControlMargin}">
                                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                                                               Text="{StaticResource str.PgMain.BeResetTime}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldContent}"
                                                               Text="{Binding BeResetTime,StringFormat={}{0:HH:mm:ss}}" />
                                            <TextBlock Style="{StaticResource Styles.Text.FieldHeader}">
                                                    (<Run Text="{Binding ConnectCnt,Mode=OneWay}" /><Run Text="{StaticResource str.PgMain.Times}" />)
                                            </TextBlock>
                                        </StackPanel>
                                    </StackPanel>
                                </Grid>
                                <UniformGrid Columns="20"
                                                     Margin="2,0"
                                                     VerticalAlignment="Top"
                                                     HorizontalAlignment="Left">
                                    <UniformGrid.Resources>
                                        <Style TargetType="TextBlock"
                                                       BasedOn="{StaticResource Styles.Text.IO}" />
                                    </UniformGrid.Resources>
                                    <TextBlock />
                                    <TextBlock Text="0" />
                                    <TextBlock Text="1" />
                                    <TextBlock Text="2" />
                                    <TextBlock Text="3" />
                                    <Grid />
                                    <TextBlock Text="4" />
                                    <TextBlock Text="5" />
                                    <TextBlock Text="6" />
                                    <TextBlock Text="7" />
                                    <Grid />
                                    <TextBlock Text="8" />
                                    <TextBlock Text="9" />
                                    <TextBlock Text="10" />
                                    <TextBlock Text="11" />
                                    <Grid />
                                    <TextBlock Text="12" />
                                    <TextBlock Text="13" />
                                    <TextBlock Text="14" />
                                    <TextBlock Text="15" />

                                    <TextBlock FontWeight="Bold"
                                                       Text="X" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=0, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=1, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=2, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=3, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Grid />
                                    <Border Tag="{Binding IStatus, ConverterParameter=4, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=5, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=6, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=7, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Grid />
                                    <Border Tag="{Binding IStatus, ConverterParameter=8, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=9, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=10, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=11, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Grid />
                                    <Border Tag="{Binding IStatus, ConverterParameter=12, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=13, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=14, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding IStatus, ConverterParameter=15, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <TextBlock FontWeight="Bold"
                                                       Text="Y" />
                                    <Border Tag="{Binding OStatus, ConverterParameter=0, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding OStatus, ConverterParameter=1, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding OStatus, ConverterParameter=2, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding OStatus, ConverterParameter=3, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Grid />
                                    <Border Tag="{Binding OStatus, ConverterParameter=4, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding OStatus, ConverterParameter=5, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding OStatus, ConverterParameter=6, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                    <Border Tag="{Binding OStatus, ConverterParameter=7, Converter={StaticResource io2bconv}}"
                                                    Style="{StaticResource Styles.Border.IO}" />
                                </UniformGrid>
                            </StackPanel>

                        </GroupBox>
                    </Grid>
                </ScrollViewer>

            </TabItem>
            <TabItem >
                <TabItem.Header>
                    <TextBlock Style="{StaticResource Styles.Text.FieldHeader}"
                              Text="{StaticResource str.PgMain.AllErrNOs}"/>
                </TabItem.Header>
                <local:UcAllErrNos x:Name="ucAllErrNos"/>
            </TabItem>
        </TabControl>

    </Grid>
</Page>
