<UserControl x:Class="MainShell.Resources.CustomControl.LoadingWaitView"
             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:MainShell.Resources.CustomControl"
             DataContext="{x:Static local:LoadingService.Instance}"
             Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibleConverter}}"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <Border Background="#44000000" />
        <Border Background="White" CornerRadius="8" Padding="30" 
                VerticalAlignment="Center" HorizontalAlignment="Center" Width="350">
            <Border.Effect>
                <DropShadowEffect BlurRadius="15" Opacity="0.2"/>
            </Border.Effect>

            <StackPanel>
                <TextBlock Text="{Binding Message}" FontSize="14" Margin="0,0,0,15" TextAlignment="Center" FontWeight="Bold"/>

                <ProgressBar Height="12" 
                             Value="{Binding ProgressValue}" 
                             IsIndeterminate="{Binding IsIndeterminate}"
                             Maximum="100"/>
                <TextBlock HorizontalAlignment="Right" Margin="0,5,0,0" FontSize="12" Foreground="Gray">
                    <TextBlock.Style>
                        <Style TargetType="TextBlock">
                            <Setter Property="Text" Value="{Binding ProgressValue, StringFormat={}{0:F0}%}"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsIndeterminate}" Value="True">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                </TextBlock>
                <Button Content="取消操作" 
                Command="{Binding CancelCommand}"
                Style="{StaticResource StopButtonStyle}"
                Visibility="{Binding CanCancel, Converter={StaticResource BoolToVisibleConverter}}"
                HorizontalAlignment="Center" 
                Padding="20,5"
                Margin="0,10,0,0"
                Cursor="Hand"/>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
