<customControls:GalleryAnimationControl
    mc:Ignorable="d"
    x:Class="PicView.Avalonia.Views.Gallery.GalleryAnimationControlView"
    x:DataType="viewModels:MainViewModel"
    xmlns="https://github.com/avaloniaui"
    xmlns:customControls="clr-namespace:PicView.Avalonia.CustomControls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:gallery="clr-namespace:PicView.Avalonia.Views.Gallery"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewModels="clr-namespace:PicView.Avalonia.ViewModels"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Design.DataContext>
        <viewModels:MainViewModel />
    </Design.DataContext>
    <Panel>

        <Panel.ContextMenu>
            <ContextMenu Opened="MenuBase_OnOpened">
                <MenuItem Header="{CompiledBinding Translation.Stretch.Value, Mode=OneWay}">
                    <MenuItem.Icon>
                        <Image
                            Height="12"
                            Source="{StaticResource Image}"
                            Width="12" />
                    </MenuItem.Icon>
                    <MenuItem
                        Command="{CompiledBinding Gallery.GalleryItemStretchCommand}"
                        CommandParameter="Uniform"
                        Header="{CompiledBinding Translation.Uniform.Value,
                                                 Mode=OneWay}"
                        IsChecked="{CompiledBinding Gallery.IsUniformMenuChecked.Value}"
                        ToggleType="Radio" />
                    <MenuItem
                        Command="{CompiledBinding Gallery.GalleryItemStretchCommand}"
                        CommandParameter="UniformToFill"
                        Header="{CompiledBinding Translation.UniformToFill.Value,
                                                 Mode=OneWay}"
                        IsChecked="{CompiledBinding Gallery.IsUniformToFillMenuChecked.Value}"
                        ToggleType="Radio" />
                    <MenuItem
                        Command="{CompiledBinding Gallery.GalleryItemStretchCommand}"
                        CommandParameter="Fill"
                        Header="{CompiledBinding Translation.Fill.Value,
                                                 Mode=OneWay}"
                        IsChecked="{CompiledBinding Gallery.IsFillMenuChecked.Value}"
                        ToggleType="Radio" />
                    <MenuItem
                        Command="{CompiledBinding Gallery.GalleryItemStretchCommand}"
                        CommandParameter="None"
                        Header="{CompiledBinding Translation.None.Value,
                                                 Mode=OneWay}"
                        IsChecked="{CompiledBinding Gallery.IsNoneMenuChecked.Value}"
                        ToggleType="Radio" />
                    <MenuItem
                        Command="{CompiledBinding Gallery.GalleryItemStretchCommand}"
                        CommandParameter="Square"
                        Header="{CompiledBinding Translation.Square.Value,
                                                 Mode=OneWay}"
                        IsChecked="{CompiledBinding Gallery.IsSquareMenuChecked.Value}"
                        ToggleType="Radio" />
                    <MenuItem
                        Command="{CompiledBinding Gallery.GalleryItemStretchCommand}"
                        CommandParameter="FillSquare"
                        Header="{CompiledBinding Translation.FillSquare.Value,
                                                 Mode=OneWay}"
                        IsChecked="{CompiledBinding Gallery.IsFillSquareMenuChecked.Value}"
                        ToggleType="Radio" />
                </MenuItem>
                <MenuItem
                    Header="{CompiledBinding Translation.ExpandedGalleryItemSize.Value,
                                             Mode=OneWay}"
                    PointerPressed="Flyout_OnPointerPressed"
                    StaysOpenOnClick="True">
                    <MenuItem.Icon>
                        <Image
                            Height="12"
                            Source="{StaticResource Image}"
                            Width="12" />
                    </MenuItem.Icon>
                    <FlyoutBase.AttachedFlyout>
                        <Flyout>
                            <Border
                                Background="{DynamicResource MainButtonBackgroundColor}"
                                BorderBrush="{DynamicResource MainBorderColor}"
                                BorderThickness="2"
                                CornerRadius="4"
                                Padding="10,3">
                                <gallery:GalleryItemSizeSlider x:Name="GalleryItemSizeSlider" />
                            </Border>
                        </Flyout>
                    </FlyoutBase.AttachedFlyout>
                </MenuItem>
                <Separator />
                <MenuItem
                    Command="{CompiledBinding Gallery.CloseGalleryCommand}"
                    Header="{CompiledBinding Translation.HideBottomGallery.Value,
                                             Mode=OneWay}"
                    IsVisible="{CompiledBinding !Gallery.IsGalleryExpanded.Value}">
                    <MenuItem.Icon>
                        <Path
                            Data="{StaticResource CloseGeometry}"
                            Fill="{DynamicResource MainTextColor}"
                            Height="12"
                            Stretch="Fill"
                            Width="12" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem
                    Command="{CompiledBinding Gallery.ToggleGalleryCommand}"
                    Header="{CompiledBinding Translation.CloseGallery.Value,
                                             Mode=OneWay}"
                    IsVisible="{CompiledBinding Gallery.IsGalleryExpanded.Value}">
                    <MenuItem.Icon>
                        <Path
                            Data="{StaticResource CloseGeometry}"
                            Fill="{DynamicResource MainTextColor}"
                            Height="12"
                            Stretch="Fill"
                            Width="12" />
                    </MenuItem.Icon>
                </MenuItem>
            </ContextMenu>
        </Panel.ContextMenu>

        <Button
            BorderThickness="1,0,0,0"
            Classes="ButtonBorder hover"
            Command="{CompiledBinding Gallery.ToggleGalleryCommand}"
            CornerRadius="0,0,0,45"
            DockPanel.Dock="Right"
            Height="60"
            HorizontalAlignment="Right"
            IsVisible="{CompiledBinding Gallery.IsGalleryExpanded.Value}"
            VerticalAlignment="Top"
            Width="50"
            ZIndex="99">
            <Path
                Data="{StaticResource CloseGeometry}"
                Fill="{DynamicResource MainTextColor}"
                Height="23"
                Margin="7,0,0,11"
                Stretch="Fill"
                Width="23" />
        </Button>

        <customControls:GalleryListBox
            AutoScrollToSelectedItem="False"
            Background="{DynamicResource SecondaryBackgroundColor}"
            BorderBrush="{DynamicResource TertiaryBorderColor}"
            BorderThickness="0,1,0,0"
            Focusable="False"
            Padding="0"
            ScrollViewer.HorizontalScrollBarVisibility="Visible"
            ScrollViewer.IsScrollInertiaEnabled="True"
            ScrollViewer.VerticalScrollBarVisibility="Disabled"
            SelectedIndex="{CompiledBinding PicViewer.Index.Value}"
            VerticalAlignment="{CompiledBinding Gallery.GalleryVerticalAlignment.Value}"
            x:Name="GalleryListBox">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel
                        HorizontalAlignment="Left"
                        Orientation="{CompiledBinding Gallery.GalleryOrientation.Value,
                                                      Mode=OneWay}"
                        VerticalAlignment="Center" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.Styles>
                <Style Selector="ListBoxItem">
                    <Setter Property="Margin" Value="{CompiledBinding Gallery.GalleryItem.ItemMargin.Value}" />
                    <Setter Property="BorderThickness" Value="3" />
                </Style>
            </ListBox.Styles>
        </customControls:GalleryListBox>
    </Panel>
</customControls:GalleryAnimationControl>