<UserControl x:Class="HistoryView.Views.Status"
             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:HistoryView.Views"
             mc:Ignorable="d" 
             xmlns:controls="clr-namespace:HistoryView.Controls"
             xmlns:baseControls="clr-namespace:HistoryView.Controls.Basics"
             xmlns:regions="clr-namespace:HistoryView.Views.Regions"
             xmlns:convert="clr-namespace:HistoryView.Converters"
             xmlns:prism="http://prismlibrary.com/"
             x:Name="This"
             prism:ViewModelLocator.AutoWireViewModel="True">
    <UserControl.Resources>
        <convert:Mini8StatusToBrushMulti x:Key="Mini8Multi"/>
    </UserControl.Resources>
    <Border Background="{StaticResource BackgroundColor}" CornerRadius="8">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>

            <controls:Header Title="{DynamicResource SoftwareName}" TextElement.FontSize="11">
                <controls:Header.DisplayContent>
                    <Grid VerticalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="0"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="0"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="0"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="0"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="0"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <RadioButton Style="{StaticResource FunctionRadioButton}" Command="{Binding SwitchCommand}" CommandParameter="Monitor" IsChecked="True">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{StaticResource dashboardDrawingImage}" Height="22"/>
                                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource TextColor}" Margin="4,0" Text="{DynamicResource Monitor}"  MaxWidth="72" TextWrapping="Wrap"/>
                            </StackPanel>
                        </RadioButton>

                        <RadioButton  Grid.Column="2" Style="{StaticResource FunctionRadioButton}" Command="{Binding SwitchCommand}"  CommandParameter="GasPanel">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{StaticResource Icon_Gas}" Height="22"/>
                                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource TextColor}" Margin="4,0" Text="{DynamicResource GasPanel}" MaxWidth="72" TextWrapping="Wrap"/>
                            </StackPanel>
                        </RadioButton>

                        <RadioButton  Grid.Column="4" Style="{StaticResource FunctionRadioButton}" Command="{Binding SwitchCommand}"  CommandParameter="HeaterGram">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{StaticResource Icon_Gas}" Height="22"/>
                                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource TextColor}" Margin="4,0" Text="配管加热器" MaxWidth="72" TextWrapping="Wrap"/>
                            </StackPanel>
                        </RadioButton>


                        <RadioButton  Grid.Column="6" Style="{StaticResource FunctionRadioButton}" Command="{Binding SwitchCommand}"  CommandParameter="Alarm">
                            <controls:WarningPopUp AlarmSource="{Binding Alarms.DisplayAlarm}"/>
                        </RadioButton>

                        <RadioButton Grid.Column="8" Style="{StaticResource FunctionRadioButton}" Command="{Binding SwitchCommand}" CommandParameter="Setting">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{StaticResource Icon_SettingGear}" Height="22"/>
                                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource TextColor}" Margin="4,0" Text="{DynamicResource Setting}"  MaxWidth="80" TextWrapping="Wrap"/>
                            </StackPanel>
                        </RadioButton>

                        <Border Grid.Column="10" Background="{StaticResource ThemeColor}" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Visible" CornerRadius="4">
                            <ItemsControl Margin="0,2" HorizontalAlignment="Left" ItemsSource="{Binding Hardwares.Mini8s}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Border Margin="2" BorderThickness="0"
                                                VerticalAlignment="Center" CornerRadius="2">
                                            <Border.BorderBrush>
                                                <MultiBinding Converter="{StaticResource Mini8Multi}" ConverterParameter="Bright">
                                                    <Binding  Path="Value.Status"/>
                                                    <Binding  Path="Value.IsConnected"/>
                                                </MultiBinding>
                                            </Border.BorderBrush>
                                            <Border.Background>
                                                <MultiBinding Converter="{StaticResource Mini8Multi}" ConverterParameter="Bright">
                                                    <Binding Path="Value.Status"/>
                                                    <Binding Path="Value.IsConnected"/>
                                                </MultiBinding>
                                            </Border.Background>

                                            <TextBlock  Text="{Binding Value.Index}" Foreground="{StaticResource TextColor}" Margin="4,2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                        </Border>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel HorizontalAlignment="Center"></WrapPanel>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </Border>
                    </Grid>
                </controls:Header.DisplayContent>

                <controls:Header.UserContent>
                    <Grid VerticalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="0"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="0"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="0"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <!--<Button  Style="{StaticResource FunctionButton}" Command="{Binding LanguageOperationCommand}">
                            <Image Source="{StaticResource Language}" Width="22" VerticalAlignment="Center"/>
                        </Button>-->
                        <!--<Popup IsOpen="{Binding PopLanguage}" StaysOpen="False" AllowsTransparency="True">
                            <Border BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="2" Background="{StaticResource BackgroundDarkColor}" CornerRadius="8">
                                <ItemsControl ItemsSource="{Binding Language.Languages}" Margin="8">
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <Button Margin="4,8" Height="28" MinWidth="100"
                                                Style="{StaticResource FunctionButton}" 
                                                Content="{Binding Key, Mode=OneWay}"
                                                Command="{Binding RelativeSource={RelativeSource AncestorType=local:Status, Mode=FindAncestor}, Path=DataContext.LanguageOperationCommand}"
                                                CommandParameter="{Binding}"/>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                            </Border>
                        </Popup>-->

                        <!--<Button Grid.Column="2" Style="{StaticResource FunctionButton}" Command="{Binding UserOperationCommand}">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{StaticResource Icon_User}" Height="20"/>
                                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource TextColor}" Margin="4,0,0,0" Text="{Binding User.UserName}"/>
                            </StackPanel>
                        </Button>-->
                        <!--<Popup Width="auto" Height="auto" PopupAnimation="Slide" IsOpen="{Binding PopUser}"  StaysOpen="False" AllowsTransparency="True" Placement="Bottom">
                            <controls:UserInfo SwitchUserCommand="{Binding SwitchUserCommand}" User="{Binding User}"/>
                        </Popup>-->

                        <Button Grid.Column="4" Style="{StaticResource FunctionButton}" Command="{Binding ExitCommand}">
                            <StackPanel Orientation="Horizontal">
                                <Image Source="{StaticResource Icon_Exit}" Height="22"/>
                                <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{StaticResource TextColor}" Margin="8,0,0,0" Text="{DynamicResource Exit}"/>
                            </StackPanel>
                        </Button>

                        <baseControls:TimerWatch Grid.Column="6" Margin="4,0" VerticalAlignment="Center" Orientation="Vertical" TextElement.FontSize="10" TextBrush="{StaticResource TextColor}"/>
                    </Grid>
                </controls:Header.UserContent>

            </controls:Header>
            <Grid Grid.Row="2">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>

                <ContentControl prism:RegionManager.RegionName="ModuleContent"/>
            </Grid>


        </Grid>
    </Border>


</UserControl>
