<controls:EnhancedPage
    x:Class="Pixeval.Pages.IllustrationViewer.ImageViewerPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Pixeval.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid>
        <controls:ZoomableImage
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            ImageIsMirrored="{x:Bind _viewModel.IsMirrored, Mode=OneWay}"
            ImageRotationDegree="{x:Bind _viewModel.RotationDegree, Mode=TwoWay}"
            ImageScale="{x:Bind _viewModel.Scale, Mode=TwoWay}"
            IsPlaying="{x:Bind _viewModel.IsPlaying, Mode=OneWay}"
            Mode="{x:Bind _viewModel.ShowMode, Mode=TwoWay}"
            MsIntervals="{x:Bind _viewModel.MsIntervals, Mode=OneWay}"
            Source="{x:Bind _viewModel.DisplayStreamsSource, Mode=OneWay}">
            <controls:ZoomableImage.ContextFlyout>
                <!--  PrimaryCommands 点击后不会自动隐藏Flyout  -->
                <CommandBarFlyout>
                    <AppBarButton Command="{x:Bind _viewModel.PlayGifCommand}" Visibility="{x:Bind controls:C.ToVisibility(_viewModel.IllustrationViewModel.IsUgoira)}" />
                    <AppBarButton
                        Command="{x:Bind _viewModel.OriginalIllustrationViewModel.BookmarkCommand}"
                        CommandParameter="{x:Bind _viewModel.DownloadParameter}"
                        IsEnabled="{x:Bind _viewModel.LoadSuccessfully, Mode=OneWay}" />
                    <AppBarSeparator />
                    <AppBarButton Command="{x:Bind _viewModel.ZoomInCommand}" />
                    <AppBarButton Command="{x:Bind _viewModel.ZoomOutCommand}" />
                    <AppBarButton Command="{x:Bind _viewModel.ShareCommand}" />
                    <CommandBarFlyout.SecondaryCommands>
                        <AppBarButton
                            Command="{x:Bind _viewModel.IllustrationViewModel.CopyCommand}"
                            CommandParameter="{x:Bind _viewModel.DownloadParameter}"
                            IsEnabled="{x:Bind _viewModel.LoadSuccessfully, Mode=OneWay}" />
                        <AppBarButton
                            Command="{x:Bind _viewModel.IllustrationViewModel.SaveCommand}"
                            CommandParameter="{x:Bind _viewModel.DownloadParameter}"
                            IsEnabled="{x:Bind _viewModel.LoadSuccessfully, Mode=OneWay}" />
                        <AppBarButton Command="{x:Bind _viewModel.SetAsCommand}">
                            <AppBarButton.Flyout>
                                <MenuFlyout>
                                    <MenuFlyoutItem Command="{x:Bind _viewModel.SetAsBackgroundCommand}" />
                                    <MenuFlyoutItem Command="{x:Bind _viewModel.SetAsLockScreenCommand}" />
                                </MenuFlyout>
                            </AppBarButton.Flyout>
                        </AppBarButton>
                        <AppBarSeparator />
                        <!--<AppBarButton Command="{x:Bind _viewModel.IllustrationViewModel.GenerateLinkCommand}" />-->
                        <AppBarButton Command="{x:Bind _viewModel.IllustrationViewModel.GenerateWebLinkCommand}" CommandParameter="{x:Bind}" />
                        <AppBarButton Command="{x:Bind _viewModel.IllustrationViewModel.OpenInWebBrowserCommand}" />
                        <!--<AppBarButton
                                Command="{x:Bind _viewModel.ShowQrCodeCommand}"
                                x:Uid="/ImageViewerPage/ShowQRCode"
                                Icon="{ui:FontIcon Glyph=QRCodeED14}"
                                Click="ShowQrCodeCommandOnExecuteRequested" />-->
                    </CommandBarFlyout.SecondaryCommands>
                </CommandBarFlyout>
            </controls:ZoomableImage.ContextFlyout>
        </controls:ZoomableImage>
        <Grid Visibility="{x:Bind controls:C.ToVisibilityNegation(_viewModel.LoadSuccessfully), Mode=OneWay}">
            <Image
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                Source="{x:Bind _viewModel.ThumbnailSource, Mode=OneWay}"
                Stretch="Uniform" />
            <Rectangle Fill="{ThemeResource PixevalAppAcrylicBrush}" />
            <StackPanel
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Spacing="10">
                <ProgressRing
                    Width="50"
                    Height="50"
                    IsIndeterminate="{x:Bind controls:C.IsZeroD(_viewModel.LoadingProgress), Mode=OneWay}"
                    Value="{x:Bind _viewModel.LoadingProgress, Mode=OneWay}" />
                <TextBlock Style="{StaticResource CaptionTextBlockStyle}" Text="{x:Bind _viewModel.LoadingText, Mode=OneWay}" />
            </StackPanel>
        </Grid>
    </Grid>
</controls:EnhancedPage>
