<Page x:Class="XFEToolBox.Client.Installer.Views.Pages.DownloadProgressPage"
      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:viewmodel="clr-namespace:XFEToolBox.Client.Installer.ViewModel.Pages"
      xmlns:controls="clr-namespace:XFEToolBox.WpfCore.Controls;assembly=XFEToolBox.WpfCore"
      mc:Ignorable="d" d:DesignHeight="380" d:DesignWidth="720"
      d:DataContext="{d:DesignInstance Type=viewmodel:DownloadProgressPageViewModel}"
      Background="Transparent" Title="下载更新" Loaded="Page_Loaded" Unloaded="Page_Unloaded">
    <Grid Margin="34,28,34,30">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <StackPanel>
            <TextBlock Text="正在获取更新" Foreground="{DynamicResource ToolTextPrimaryBrush}"
                       FontSize="25" FontWeight="Bold"/>
            <TextBlock Text="安装包下载完成后会自动进行校验和安装，请保持网络连接。"
                       Foreground="{DynamicResource ToolTextSecondaryBrush}" FontSize="11" Margin="0,5,0,0"/>
        </StackPanel>

        <Border Grid.Row="1" Margin="0,24,0,18" Padding="22" CornerRadius="15"
                Background="{DynamicResource ToolControlBackgroundBrush}"
                BorderBrush="{DynamicResource ToolControlBorderBrush}" BorderThickness="1"
                VerticalAlignment="Center">
            <StackPanel>
                <Grid>
                    <TextBlock Text="更新包" Foreground="{DynamicResource ToolTextPrimaryBrush}"
                               FontWeight="SemiBold"/>
                    <TextBlock Text="{Binding DownloadText}" HorizontalAlignment="Right"
                               Foreground="{DynamicResource ToolTextSecondaryBrush}"/>
                </Grid>
                <controls:ModernProgressBar x:Name="progress" Height="12" Margin="0,14,0,0"
                                            ProgressBarCornerRadius="6" IsBusy="{Binding IsBusy}"
                                            IsPause="{Binding IsPause}" IsError="{Binding IsError}"
                                            Value="{Binding Value}" MaxValue="{Binding MaxValue}"/>
                <TextBlock Text="{Binding ErrorMessage}" Margin="0,13,0,0"
                           Foreground="{DynamicResource ToolDangerBrush}" TextWrapping="Wrap">
                    <TextBlock.Style>
                        <Style TargetType="TextBlock">
                            <Setter Property="Visibility" Value="Collapsed"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsError}" Value="True">
                                    <Setter Property="Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>
            </StackPanel>
        </Border>

        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Height="42" MinWidth="110" Content="{Binding PauseText}"
                    Command="{Binding PauseSwitchCommand}" IsEnabled="{Binding PauseSwitchEnable}"/>
            <Button Height="42" MinWidth="130" Margin="10,0,0,0" Content="重新下载"
                    Command="{Binding RetryCommand}" controls:ButtonAssist.IsPrimary="True"/>
        </StackPanel>
    </Grid>
</Page>
