<Window
    x:Class="PicView.WPF.Views.Windows.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:buttons="clr-namespace:PicView.WPF.Views.UserControls.Buttons"
    xmlns:misc="clr-namespace:PicView.WPF.Views.UserControls.Misc"
    Title="Loading..."
    Width="462"
    Height="400"
    MinWidth="462"
    MinHeight="400"
    AllowsTransparency="True"
    Background="Transparent"
    BorderBrush="{StaticResource BorderBrush}"
    BorderThickness="1"
    Focusable="True"
    Foreground="{StaticResource MainColorBrush}"
    SizeToContent="WidthAndHeight"
    Style="{DynamicResource MyWindowStyle}"
    WindowStartupLocation="CenterScreen"
    WindowStyle="None">

    <Window.Resources>
        <SolidColorBrush x:Key="MagicBrush" Color="{StaticResource IconColor}" />
        <SolidColorBrush x:Key="ImageBrush" Color="{StaticResource IconColor}" />
    </Window.Resources>

    <DockPanel LastChildFill="True">

        <DockPanel
            x:Name="TitleBar"
            Height="30"
            Background="{StaticResource SubtleFadeBrush}"
            DockPanel.Dock="Top">

            <Canvas
                x:Name="LeftButtonContainer"
                Width="131"
                Height="30"
                Background="{StaticResource BackgroundColorBrush}"
                DockPanel.Dock="Left">

                <misc:Icon
                    x:Name="Logo"
                    Width="41"
                    Height="30"
                    Margin="0"
                    Padding="0,2,0,2"
                    Background="{StaticResource BackgroundColorBrush}" />

                <Rectangle
                    Canvas.Left="41"
                    Width="1"
                    Height="30"
                    Fill="{StaticResource BorderBrush}" />

                <Button
                    Name="GalleryButton"
                    Canvas.Left="42"
                    Width="29"
                    Height="30"
                    FocusVisualStyle="{x:Null}"
                    Focusable="False">
                    <Button.Background>
                        <SolidColorBrush x:Name="GalleryBg" Color="Transparent" />
                    </Button.Background>
                    <Image Width="17">
                        <Image.Source>
                            <DrawingImage>
                                <DrawingImage.Drawing>
                                    <DrawingGroup>
                                        <GeometryDrawing Geometry="F1 M22 16L22 4C22 2.9 21.1 2 20 2L8 2C6.9 2 6 2.9 6 4L6 16C6 17.1 6.9 18 8 18L20 18C21.1 18 22 17.1 22 16ZM11 12L13.03 14.71L16 11L20 16L8 16L11 12ZM2 6L2 20C2 21.1 2.9 22 4 22L18 22L18 20L4 20L4 6L2 6Z">
                                            <GeometryDrawing.Brush>
                                                <SolidColorBrush x:Name="GalleryBrush" Color="{StaticResource IconColor}" />
                                            </GeometryDrawing.Brush>
                                        </GeometryDrawing>
                                    </DrawingGroup>
                                </DrawingImage.Drawing>
                            </DrawingImage>
                        </Image.Source>
                    </Image>
                </Button>

                <Rectangle
                    Canvas.Left="71"
                    Width="1"
                    Height="30"
                    Fill="{StaticResource BorderBrush}" />

                <Button
                    Name="RotateButton"
                    Canvas.Left="72"
                    Width="29"
                    Height="30"
                    FocusVisualStyle="{x:Null}"
                    Focusable="False">
                    <Button.Background>
                        <SolidColorBrush x:Name="RotateBg" Color="Transparent" />
                    </Button.Background>
                    <Path
                        Width="15"
                        Height="15"
                        Data="M255.545 8c-66.269.119-126.438 26.233-170.86 68.685L48.971 40.971C33.851 25.851 8 36.559 8 57.941V192c0 13.255 10.745 24 24 24h134.059c21.382 0 32.09-25.851 16.971-40.971l-41.75-41.75c30.864-28.899 70.801-44.907 113.23-45.273 92.398-.798 170.283 73.977 169.484 169.442C423.236 348.009 349.816 424 256 424c-41.127 0-79.997-14.678-110.63-41.556-4.743-4.161-11.906-3.908-16.368.553L89.34 422.659c-4.872 4.872-4.631 12.815.482 17.433C133.798 479.813 192.074 504 256 504c136.966 0 247.999-111.033 248-247.998C504.001 119.193 392.354 7.755 255.545 8z"
                        Stretch="Fill">
                        <Path.Fill>
                            <SolidColorBrush x:Name="RotateBrush" Color="{StaticResource IconColor}" />
                        </Path.Fill>
                    </Path>
                </Button>

                <Rectangle
                    Canvas.Left="101"
                    Width="1"
                    Height="30"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Fill="{StaticResource BorderBrush}" />

                <CheckBox
                    Name="FlipButton"
                    Canvas.Left="102"
                    Width="29"
                    Height="30"
                    FocusVisualStyle="{x:Null}"
                    Focusable="False">
                    <CheckBox.Background>
                        <SolidColorBrush x:Name="FlipBg" Color="Transparent" />
                    </CheckBox.Background>
                    <Path
                        x:Name="FlipPath"
                        Width="13"
                        Height="13"
                        Margin="7,8,0,0"
                        Data="M192,96v64h248c4.4,0,8,3.6,8,8v240c0,4.4-3.6,8-8,8H136c-4.4,0-8-3.6-8-8v-48c0-4.4,3.6-8,8-8h248V224H192v64L64,192  L192,96z"
                        Stretch="Fill">
                        <Path.Fill>
                            <SolidColorBrush x:Name="FlipBrush" Color="{StaticResource IconColor}" />
                        </Path.Fill>
                    </Path>
                </CheckBox>
            </Canvas>

            <Rectangle
                Width="1"
                Height="30"
                Fill="{StaticResource BorderBrush}" />

            <buttons:CloseButton
                x:Name="CloseButton"
                Width="30"
                Height="30"
                Background="{StaticResource BackgroundColorBrush}"
                DockPanel.Dock="Right" />

            <Rectangle
                Width="1"
                Height="30"
                DockPanel.Dock="Right"
                Fill="{StaticResource BorderBrush}" />

            <buttons:FullscreenButton
                x:Name="FullscreenButton"
                Width="32"
                Background="{StaticResource BackgroundColorBrush}"
                DockPanel.Dock="Right" />

            <Rectangle
                Width="1"
                Height="30"
                DockPanel.Dock="Right"
                Fill="{StaticResource BorderBrush}" />

            <buttons:MinButton
                x:Name="MinButton"
                Width="32"
                Background="{StaticResource BackgroundColorBrush}"
                DockPanel.Dock="Right" />

            <Rectangle
                Width="1"
                Height="30"
                DockPanel.Dock="Right"
                Fill="{StaticResource BorderBrush}" />

            <misc:CustomTextBox
                x:Name="TitleText"
                Background="Transparent"
                Foreground="{StaticResource IconColorBrush}" />
        </DockPanel>

        <Grid
            x:Name="LowerBar"
            Height="25"
            Background="{StaticResource BackgroundColorBrushAlt}"
            DockPanel.Dock="Bottom">

            <Canvas
                Width="404"
                Height="25"
                HorizontalAlignment="Center"
                Background="{StaticResource BackgroundColorBrush}">

                <Rectangle
                    Width="1"
                    Height="25"
                    Fill="{StaticResource BorderBrush}" />

                <buttons:FolderButton
                    x:Name="FolderButton"
                    Canvas.Left="1"
                    Width="56"
                    Height="25" />

                <Rectangle
                    Canvas.Left="56"
                    Canvas.Top="0"
                    Width="1"
                    Height="25"
                    Fill="{StaticResource BorderBrush}" />

                <Button
                    x:Name="ImageButton"
                    Canvas.Left="57"
                    Width="55"
                    Height="25"
                    FocusVisualStyle="{x:Null}"
                    Focusable="False">
                    <Button.Background>
                        <SolidColorBrush x:Name="ImageMenuBg" Color="Transparent" />
                    </Button.Background>
                    <Canvas
                        Width="28"
                        Height="25"
                        Margin="14,0,0,0">
                        <Path
                            Canvas.Left="0.233"
                            Canvas.Top="0"
                            Canvas.Bottom="5"
                            Width="20"
                            Height="22"
                            Data="F1M27.242,10.47L5.429,0.05C5.173,-0.072,4.868,0.035,4.748,0.287L0,10.223 2.587,10.223 6.073,2.922 24.983,11.956 19.071,24.335 15.741,22.744 15.741,29.289 17.786,30.267C18.042,30.39,18.346,30.28,18.467,30.027L27.484,11.149C27.605,10.897,27.497,10.593,27.242,10.47"
                            Fill="{StaticResource ImageBrush}"
                            Stretch="Fill" />
                        <Path
                            Canvas.Left="-5.667"
                            Canvas.Top="7"
                            Canvas.Right="13"
                            Width="18"
                            Height="16"
                            Data="F1M23.29,16.034L21.76,16.034C20.866,13.747 19.768,10.543 18.102,10.97 16.146,11.47 15.168,16.034 15.168,16.034 15.168,16.034 14.172,10.883 11.414,8.124 8.654,5.367 5.983,16.034 5.983,16.034L2.333,16.034 2.333,2.314 23.29,2.314z M24.688,0L0.511,0C0.228,0,0,0.229,0,0.509L0,21.429C0,21.71,0.228,21.94,0.511,21.94L24.688,21.94C24.97,21.94,25.198,21.71,25.198,21.429L25.198,0.509C25.198,0.229,24.97,0,24.688,0"
                            Fill="{StaticResource ImageBrush}"
                            Stretch="Fill" />
                        <Path
                            Canvas.Right="17"
                            Canvas.Bottom="10"
                            Width="5"
                            Height="5"
                            Data="F1M1.711,3.42C2.655,3.42 3.422,2.655 3.422,1.71 3.422,0.766 2.655,0 1.711,0 0.765,0 0,0.766 0,1.71 0,2.655 0.765,3.42 1.711,3.42"
                            Fill="{StaticResource ImageBrush}" />
                    </Canvas>
                </Button>

                <Canvas
                    Canvas.Left="112"
                    Width="182"
                    Height="25"
                    Background="{StaticResource AltInterfaceBrush}">

                    <Rectangle
                        Canvas.Left="90"
                        Canvas.Top="0"
                        Width="1"
                        Height="25"
                        Fill="{StaticResource BorderBrush}" />
                    <Rectangle
                        Canvas.Left="0"
                        Canvas.Top="0"
                        Width="1"
                        Height="25"
                        Fill="{StaticResource BorderBrush}" />

                    <Rectangle
                        Canvas.Left="181"
                        Canvas.Top="0"
                        Width="1"
                        Height="25"
                        Fill="{StaticResource BorderBrush}" />

                    <buttons:LeftButton x:Name="LeftButton" />

                    <buttons:RightButton x:Name="RightButton" Canvas.Left="91" />
                </Canvas>

                <Rectangle
                    Canvas.Left="349"
                    Canvas.Top="0"
                    Width="1"
                    Height="25"
                    Fill="{StaticResource BorderBrush}" />

                <Button
                    x:Name="SettingsButton"
                    Canvas.Left="294"
                    Width="55"
                    Height="25"
                    Margin="0"
                    FocusVisualStyle="{x:Null}"
                    Focusable="False">
                    <Button.Background>
                        <SolidColorBrush x:Name="SettingsMenuBg" Color="Transparent" />
                    </Button.Background>
                    <Path
                        Width="21"
                        Height="21"
                        Data="M413.967,276.8c1.06-6.235,1.06-13.518,1.06-20.8s-1.06-13.518-1.06-20.8l44.667-34.318   c4.26-3.118,5.319-8.317,2.13-13.518L418.215,115.6c-2.129-4.164-8.507-6.235-12.767-4.164l-53.186,20.801   c-10.638-8.318-23.394-15.601-36.16-20.801l-7.448-55.117c-1.06-4.154-5.319-8.318-10.638-8.318h-85.098   c-5.318,0-9.577,4.164-10.637,8.318l-8.508,55.117c-12.767,5.2-24.464,12.482-36.171,20.801l-53.186-20.801   c-5.319-2.071-10.638,0-12.767,4.164l-42.549,71.765c-2.119,4.153-1.061,10.399,2.129,13.518L96.97,235.2   c0,7.282-1.06,13.518-1.06,20.8s1.06,13.518,1.06,20.8l-44.668,34.318c-4.26,3.118-5.318,8.317-2.13,13.518L92.721,396.4   c2.13,4.164,8.508,6.235,12.767,4.164l53.187-20.801c10.637,8.318,23.394,15.601,36.16,20.801l8.508,55.117   c1.069,5.2,5.318,8.318,10.637,8.318h85.098c5.319,0,9.578-4.164,10.638-8.318l8.518-55.117c12.757-5.2,24.464-12.482,36.16-20.801   l53.187,20.801c5.318,2.071,10.637,0,12.767-4.164l42.549-71.765c2.129-4.153,1.06-10.399-2.13-13.518L413.967,276.8z    M255.468,328.8c-41.489,0-74.46-32.235-74.46-72.8s32.971-72.8,74.46-72.8s74.461,32.235,74.461,72.8S296.957,328.8,255.468,328.8   z"
                        Stretch="Fill">
                        <Path.Fill>
                            <SolidColorBrush x:Name="SettingsButtonFill" Color="{StaticResource IconColor}" />
                        </Path.Fill>
                    </Path>
                </Button>

                <Button
                    x:Name="FunctionMenuButton"
                    Canvas.Left="349"
                    Canvas.Top="0"
                    Width="55"
                    Height="25"
                    FocusVisualStyle="{x:Null}"
                    Focusable="False">
                    <Button.Background>
                        <SolidColorBrush x:Name="EffectsMenuBg" Color="Transparent" />
                    </Button.Background>
                    <Image Width="22" Height="22">
                        <Image.Source>
                            <DrawingImage>
                                <DrawingImage.Drawing>
                                    <DrawingGroup ClipGeometry="M0,0 V512 H512 V0 H0 Z">
                                        <DrawingGroup Transform="0.707106781186548,-0.707106781186547,0.707106781186547,0.707106781186548,-129.23,312">
                                            <GeometryDrawing>
                                                <GeometryDrawing.Pen>
                                                    <Pen
                                                        Brush="{StaticResource MagicBrush}"
                                                        EndLineCap="Flat"
                                                        LineJoin="Miter"
                                                        StartLineCap="Flat"
                                                        Thickness="32" />
                                                </GeometryDrawing.Pen>
                                                <GeometryDrawing.Geometry>
                                                    <RectangleGeometry
                                                        RadiusX="10"
                                                        RadiusY="10"
                                                        Rect="280.48,122.9,63.03,378.2" />
                                                </GeometryDrawing.Geometry>
                                            </GeometryDrawing>
                                        </DrawingGroup>
                                        <DrawingGroup Transform="0.707106781186548,-0.707106781186547,0.707106781186547,0.707106781186548,-87.81,212">
                                            <GeometryDrawing Brush="{StaticResource MagicBrush}">
                                                <GeometryDrawing.Geometry>
                                                    <RectangleGeometry
                                                        RadiusX="0"
                                                        RadiusY="0"
                                                        Rect="180.35,164.45,63.29,95.1" />
                                                </GeometryDrawing.Geometry>
                                            </GeometryDrawing>
                                        </DrawingGroup>
                                        <GeometryDrawing Brush="{StaticResource MagicBrush}">
                                            <GeometryDrawing.Pen>
                                                <Pen
                                                    Brush="{StaticResource MagicBrush}"
                                                    EndLineCap="Round"
                                                    LineJoin="Miter"
                                                    StartLineCap="Round"
                                                    Thickness="32" />
                                            </GeometryDrawing.Pen>
                                            <GeometryDrawing.Geometry>
                                                <LineGeometry StartPoint="48,192" EndPoint="96,192" />
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                        <GeometryDrawing Brush="{StaticResource MagicBrush}">
                                            <GeometryDrawing.Pen>
                                                <Pen
                                                    Brush="{StaticResource MagicBrush}"
                                                    EndLineCap="Round"
                                                    LineJoin="Miter"
                                                    StartLineCap="Round"
                                                    Thickness="32" />
                                            </GeometryDrawing.Pen>
                                            <GeometryDrawing.Geometry>
                                                <LineGeometry StartPoint="90.18,90.18" EndPoint="124.12,124.12" />
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                        <GeometryDrawing Brush="{StaticResource MagicBrush}">
                                            <GeometryDrawing.Pen>
                                                <Pen
                                                    Brush="{StaticResource MagicBrush}"
                                                    EndLineCap="Round"
                                                    LineJoin="Miter"
                                                    StartLineCap="Round"
                                                    Thickness="32" />
                                            </GeometryDrawing.Pen>
                                            <GeometryDrawing.Geometry>
                                                <LineGeometry StartPoint="192,48" EndPoint="192,96" />
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                        <GeometryDrawing Brush="{StaticResource MagicBrush}">
                                            <GeometryDrawing.Pen>
                                                <Pen
                                                    Brush="{StaticResource MagicBrush}"
                                                    EndLineCap="Round"
                                                    LineJoin="Miter"
                                                    StartLineCap="Round"
                                                    Thickness="32" />
                                            </GeometryDrawing.Pen>
                                            <GeometryDrawing.Geometry>
                                                <LineGeometry StartPoint="293.82,90.18" EndPoint="259.88,124.12" />
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                        <GeometryDrawing Brush="{StaticResource MagicBrush}">
                                            <GeometryDrawing.Pen>
                                                <Pen
                                                    Brush="{StaticResource MagicBrush}"
                                                    EndLineCap="Round"
                                                    LineJoin="Miter"
                                                    StartLineCap="Round"
                                                    Thickness="32" />
                                            </GeometryDrawing.Pen>
                                            <GeometryDrawing.Geometry>
                                                <LineGeometry StartPoint="124.12,259.88" EndPoint="90.18,293.82" />
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                    </DrawingGroup>
                                </DrawingImage.Drawing>
                            </DrawingImage>
                        </Image.Source>
                    </Image>
                </Button>

                <Rectangle
                    Canvas.Left="404"
                    Canvas.Top="0"
                    Width="1"
                    Height="25"
                    Fill="{StaticResource BorderBrush}" />
            </Canvas>
        </Grid>

        <Border
            Background="{StaticResource NoisyBg}"
            BorderBrush="{StaticResource BorderBrush}"
            BorderThickness="0,1,0,1">

            <Grid x:Name="ParentContainer" AllowDrop="True">

                <ScrollViewer
                    x:Name="Scroller"
                    CanContentScroll="False"
                    FocusVisualStyle="{x:Null}"
                    Focusable="False"
                    HorizontalScrollBarVisibility="Disabled"
                    VerticalScrollBarVisibility="Disabled">
                    <Border
                        x:Name="MainImageBorder"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Focusable="False">
                        <Image
                            x:Name="MainImage"
                            AllowDrop="True"
                            Focusable="False"
                            RenderOptions.BitmapScalingMode="Fant"
                            RenderOptions.EdgeMode="Aliased"
                            Stretch="Fill"
                            UseLayoutRounding="True" />
                    </Border>
                </ScrollViewer>
                <Canvas
                    x:Name="TopLayer"
                    Canvas.ZIndex="3"
                    IsHitTestVisible="False" />
            </Grid>
        </Border>
    </DockPanel>
</Window>