<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:vm="clr-namespace:detect.gui.VWMS"
        xmlns:vws="clr-namespace:detect.gui.VWS"
        xmlns:webViewControl="clr-namespace:WebViewControl;assembly=WebViewControl.Avalonia"
        xmlns:controls="clr-namespace:detect.gui.Controls"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="detect.gui.VWS.MainWindow"
        Title="MainWindow"
        x:DataType="vm:MainWindowModel"
        Closing="OnClosing">
    <Window.Background>
        <ImageBrush Source="avares://detect.gui/Assets/Images/bg.png" Stretch="Fill" />
    </Window.Background>
    <Grid RowDefinitions="Auto, Auto, 0, *">
        <Border Height="70">
            <Border.Background>
                <ImageBrush Source="avares://detect.gui/Assets/Images/header.png" Stretch="None" />
            </Border.Background>
            <Grid>
                <Border>
                    <TextBlock Classes="logo-text" Text="中核集团预埋件检测系统" VerticalAlignment="Center">
                        <TextBlock.Foreground>
                            <LinearGradientBrush StartPoint="0% 0%" EndPoint="0% 100%">
                                <GradientStop Offset="0.0" Color="#34DEFC" />
                                <GradientStop Offset="0.5" Color="#FFFFFF" />
                                <GradientStop Offset="1.0" Color="#34DEFC" />
                            </LinearGradientBrush>
                        </TextBlock.Foreground>
                    </TextBlock>
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0% 0%" EndPoint="0% 100%" Opacity="0.25">
                            <GradientStop Offset="0.8" Color="Transparent" />
                            <GradientStop Offset="1.0" Color="#34DEFC" />
                        </LinearGradientBrush>
                    </Border.Background>
                </Border>
            </Grid>
        </Border>
        <Border Grid.Row="1" Height="4">
            <Border.Background>
                <LinearGradientBrush StartPoint="0% 0%" EndPoint="100% 0%">
                    <GradientStop Offset="0.0" Color="#2F1A9A" />
                    <GradientStop Offset="0.3" Color="#3A62CB" />
                    <GradientStop Offset="0.5" Color="#34DEFC" />
                    <GradientStop Offset="0.7" Color="#3A62CB" />
                    <GradientStop Offset="1" Color="#2F1A9A" />
                </LinearGradientBrush>
            </Border.Background>
        </Border>
        <Grid Grid.Row="0" HorizontalAlignment="Right" ColumnDefinitions="Auto,5,Auto,5,Auto,5,Auto,15">
            <Button Grid.Column="0"
                    Classes="icon-button circle logout window"
                    ToolTip.Tip="注销"
                    VerticalAlignment="Center"
                    IsVisible="{Binding CurrentUser, Converter={x:Static ObjectConverters.IsNotNull}}"
                    Command="{Binding LogoutCommand}">
            </Button>
            <Button Grid.Column="2"
                    Classes="icon-button circle min window"
                    ToolTip.Tip="最小化"
                    Click="MinClick"/>
            <Button Grid.Column="4"
                    IsEnabled="False"
                    IsVisible="{Binding $parent[Window;0].WindowState, Converter={StaticResource WindowStateConverter}, ConverterParameter=2}"
                    Classes="icon-button circle max window"
                    CornerRadius="100"
                    ToolTip.Tip="最大化"
                    Click="MaxClick"/>
            <Button Grid.Column="4"
                    Classes="icon-button circle restore window"
                    ToolTip.Tip="恢复"
                    IsEnabled="False"
                    IsVisible="{Binding $parent[Window;0].WindowState, Converter={StaticResource WindowStateConverter}, ConverterParameter=1}"
                    Click="RestoreClick"/>
            <Button Grid.Column="6"
                    Classes="icon-button circle close window"
                    ToolTip.Tip="关闭"
                    Click="CloseClick"/>
        </Grid>
        <Border Grid.Row="3">
            <Border.Margin>
                <MultiBinding Converter="{StaticResource SidebarMarginConverter}">
                    <Binding Path="CurrentUser" />
                    <Binding Path="#Sidebar.Bounds.Height" />
                </MultiBinding>
            </Border.Margin>
            <Grid>
                <webViewControl:WebView x:Name="WebView"
                                        ZIndex="50"
                                        Focusable="True"
                                        IsHistoryDisabled="True"
                                        IgnoreCertificateErrors="True"
                                        DisableBuiltinContextMenus="True"
                                        AllowDeveloperTools="True"
                                        IsVisible="False"
                                        Address="{Binding Address}"/>
                <Grid IsVisible="{Binding CurrentUser, Converter={x:Static ObjectConverters.IsNull}}" >
                    <vws:LoginControl x:DataType="vm:LoginControlModel" />
                </Grid>
            </Grid>
        </Border>
        <Grid Grid.Row="3" x:Name="Sidebar" VerticalAlignment="Bottom" IsVisible="{Binding CurrentUser, Converter={x:Static ObjectConverters.IsNotNull}}">
            <Grid.Background>
                <SolidColorBrush Color="#2D77F3" Opacity="0.4"></SolidColorBrush>
            </Grid.Background>
            <Border Margin="0, 10" HorizontalAlignment="Center">
                <StackPanel Orientation="Horizontal">
                    <!-- <RadioButton Classes="sidebar home-app" Content="首页" GroupName="SideBar" IsChecked="{Binding IsHomeView}" Command="{Binding GoCommand}" CommandParameter="0" /> -->
                    <!-- <Border Width="15" /> -->
                    <RadioButton Classes="sidebar home-task" Content="任务管理" GroupName="SideBar" IsChecked="{Binding IsDetectTaskView}" Command="{Binding GoCommand}" CommandParameter="1" />
                    <Border Width="15" />
                    <RadioButton Classes="sidebar home-device" Content="设备管理" GroupName="SideBar" IsChecked="{Binding IsDeviceView}" Command="{Binding GoCommand}" CommandParameter="2" />
                    <Border Width="15" />
                    <RadioButton Classes="sidebar home-log" Content="日志查看" GroupName="SideBar" IsChecked="{Binding IsLogView}" Command="{Binding GoCommand}" CommandParameter="3" />
                    <Border Width="15" />
                    <RadioButton Classes="sidebar home-user" Content="用户管理" GroupName="SideBar" IsChecked="{Binding IsUserView}" Command="{Binding GoCommand}" CommandParameter="4" />
                    <!-- <TextBlock Text="{Binding IsLoading}" Foreground="Azure"></TextBlock>     -->
                </StackPanel>
            </Border>
        </Grid>
        <controls:ProgressBox Grid.Row="3"
                              IconWidth="64"
                              IconHeight="64"
                              Foreground="{StaticResource ButtonPointeroverBackgroundColor}"
                              IsVisible="{Binding IsLoading}" />
    </Grid>
</Window>
