<pu:WindowX x:Class="SWRIS.MainWindow" 
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:cvt="clr-namespace:SWRIS.Converters"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:SWRIS" WindowStyle="None" 
            FontFamily="{StaticResource PuHuiTiRegular}"
            ResizeMode="CanMinimize" Title="{Binding AppName}" Foreground="#FFFFFF"
            xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" 
            xmlns:vm="clr-namespace:SWRIS.Models.ViewModel" MaskBrush="#66000000"
            mc:Ignorable="d" Closing="Window_Closing" Background="#141332" 
            Height="1080" Width="1920" Left="0" Top="0" Loaded="WindowX_Loaded"
            pu:WindowXCaption.Height="0">
    <Window.DataContext>
        <vm:MainViewModel/>
    </Window.DataContext>
    <Window.Resources>
        <cvt:MenuNameToPositionConverter x:Key="MenuNameToPositionConverter"/>
        <cvt:MenuNameToColorConverter x:Key="MenuNameToColorConverter"/>
        <cvt:StringEmptyToVisibilityConverter x:Key="StringEmptyToVisibilityConverter"/>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="90"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Grid.Row="0" pu:WindowX.IsDragMoveArea="True" MouseDown="StackPanel_MouseDown">
            <StackPanel.Background>
                <ImageBrush  ImageSource="/Resources/menu_bg.png"/>
            </StackPanel.Background>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="715"/>
                    <ColumnDefinition Width="460"/>
                    <ColumnDefinition Width="340"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Horizontal" Grid.Column="0">
                    <Image Source="/Resources/logo.png" Margin="56,19,19,20"/>
                    <TextBlock Text="{Binding AppName}" VerticalAlignment="Center" FontSize="40" FontWeight="Bold" FontFamily="{StaticResource PuHuiTiRegular}"/>
                </StackPanel>
                <Canvas Grid.Column="1">
                    <Image x:Name="popupImage" Source="/Resources/menu_dec.png" Width="344"
                           Canvas.Left="{Binding CurrentPage,Mode=TwoWay,Converter={StaticResource MenuNameToPositionConverter}}"/>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="主页" Tag="Home" FontWeight="Bold" FontFamily="{StaticResource PuHuiTiRegular}" FontSize="30" Padding="30,0" Margin="110,25,20,25" Cursor="Hand"
                                   Foreground="{Binding CurrentPage,Converter={StaticResource MenuNameToColorConverter},ConverterParameter=Home}"
                                   MouseDown="Menu_MouseDown"/>
                        <TextBlock Text="记录" Tag="Record" FontWeight="Bold" FontFamily="{StaticResource PuHuiTiRegular}" FontSize="30" Padding="30,0" Margin="20,25,110,25" Cursor="Hand" 
                                   Foreground="{Binding CurrentPage,Converter={StaticResource MenuNameToColorConverter},ConverterParameter=Record}" 
                                   MouseDown="Menu_MouseDown"/>
                    </StackPanel>
                </Canvas>
                <ItemsControl  Grid.Column="2" ItemsSource="{Binding SwitchInstances}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Margin="0,-20,0,0" Orientation="Horizontal" HorizontalAlignment="Left"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border Background="#3650BE" Width="105" Height="75" Tag="{Binding ProgressName}" CornerRadius="0,0,15,15" Margin="10,0"
                                    MouseLeftButtonDown="SwitchToInstance_MouseDown" Cursor="Hand">
                                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                    <Image Source="{Binding ImageSource}" Width="34" Margin="3"/>
                                    <TextBlock Text="{Binding InstanceName}" FontSize="18" FontWeight="Bold" HorizontalAlignment="Center" Foreground="#AEBAE8"/>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                <StackPanel Orientation="Horizontal" Grid.Column="3" HorizontalAlignment="Right" Margin="0,0,0,0">
                    <Image Source="/Resources/setting.png" MouseDown="Setting_MouseDown" Width="64" Cursor="Hand"/>
                    <StackPanel Orientation="Vertical" Margin="30,0,0,0" VerticalAlignment="Center">
                        <TextBlock Text="{Binding SystemTime.Date,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                                   FontSize="20" FontWeight="Bold" LineHeight="18" LineStackingStrategy="BlockLineHeight"/>
                        <TextBlock Text="{Binding SystemTime.Time,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                   FontSize="34" FontWeight="Bold" FontFamily="{StaticResource PuHuiTiRegular}"
                                   LineHeight="36" LineStackingStrategy="BlockLineHeight"/>
                    </StackPanel>
                    <Image Source="/Resources/minimize.png" MouseDown="Minimize_MouseDown" Width="42" Margin="55,0,0,0" Cursor="Hand"/>
                    <Image Source="/Resources/closed.png" MouseDown="Close_MouseDown" Width="42" Margin="25,0,0,0" Cursor="Hand"/>
                </StackPanel>
            </Grid>
        </StackPanel>
        <Frame x:Name="main_frame" Grid.Row="1"  NavigationUIVisibility="Hidden"/>
        <DockPanel Grid.Row="2" Margin="20 0">
            <StackPanel Orientation="Horizontal" Margin="5,5" 
                            Visibility="{Binding DebugMessage.Message,Converter={StaticResource StringEmptyToVisibilityConverter}}">
                <TextBlock Text="&#xE9ce;" FontSize="17" FontFamily="{StaticResource PanuonIconFont}" VerticalAlignment="Center" Foreground="#7F74FF"/>
                <TextBlock Text="{Binding  DebugMessage.DateTime,StringFormat=HH:mm:ss}" FontSize="16" Margin="5,0" 
                                           VerticalAlignment="Center" 
                                           Foreground="#7F74FF"/>
                <TextBlock Text="{Binding DebugMessage.Message}" FontSize="16" Margin="5,0" 
                                           VerticalAlignment="Center"
                                           Foreground="#7F74FF"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                <TextBlock FontSize="20" Text="版本 " Foreground="#5B7098"/>
                <TextBlock FontSize="20" Text="{Binding Version}" Margin="0,0,30,0" Foreground="#5B7098"/>
                <TextBlock FontSize="20" Text="©" Foreground="#5B7098"/>
                <TextBlock Text="{Binding Copyright}" FontSize="20" Foreground="#5B7098"/>
            </StackPanel>
        </DockPanel>
    </Grid>
</pu:WindowX>
