<adonisControls:AdonisWindow x:Class="FModel.Views.ImageMerger"
                             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                             xmlns:local="clr-namespace:FModel"
                             xmlns:converters="clr-namespace:FModel.Views.Resources.Converters"
                             xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI"
                             xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI"
                             xmlns:adonisExtensions="clr-namespace:AdonisUI.Extensions;assembly=AdonisUI"
                             WindowStartupLocation="CenterScreen" IconVisibility="Collapsed"
                             Height="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenHeight}, Converter={converters:RatioConverter}, ConverterParameter='0.65'}"
                             Width="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenWidth}, Converter={converters:RatioConverter}, ConverterParameter='0.55'}">
    <adonisControls:AdonisWindow.Style>
        <Style TargetType="adonisControls:AdonisWindow" BasedOn="{StaticResource {x:Type adonisControls:AdonisWindow}}">
            <Setter Property="Title" Value="Image Merger"/>
        </Style>
    </adonisControls:AdonisWindow.Style>
    <Grid Margin="10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="10"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <GroupBox Grid.Column="0" adonisExtensions:LayerExtension.Layer="2"
                  Padding="{adonisUi:Space 0}" Background="Transparent">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <ListBox x:Name="ImagesListBox" Grid.Row="0" SelectionMode="Extended" />
                <Separator Grid.Row="1" Style="{StaticResource CustomSeparator}" Tag="COMMANDS" />
                <Grid Grid.Row="2" Margin="0 0 0 10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="5"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Row="0" Grid.Column="0" Text="Images Per Row" VerticalAlignment="Center" Margin="0 0 10 0" />
                    <Slider x:Name="SizeSlider" Grid.Row="0" Grid.Column="1" TickPlacement="None" AutoToolTipPlacement="BottomRight"
                            IsMoveToPointEnabled="True" Minimum="1" Maximum="20" TickFrequency="1" MouseUp="Click_DrawPreview" Thumb.DragCompleted="DrawPreview"/>
                    <TextBlock Grid.Row="2" Grid.Column="0" Text="Margin Between Images" VerticalAlignment="Center" Margin="0 0 10 0" />
                    <Slider Grid.Row="2" Grid.Column="1" Value="{Binding ImageMergerMargin, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
                            TickPlacement="None" AutoToolTipPlacement="BottomRight" IsMoveToPointEnabled="True" Minimum="0" Maximum="50" TickFrequency="1"
                            MouseUp="Click_DrawPreview" Thumb.DragCompleted="DrawPreview" />
                </Grid>
                <StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center">
                    <Button x:Name="AddButton" Content="Add" MinWidth="80" Padding="1,3,1,3" Click="OnImageAdd"/>
                    <Button x:Name="UpButton" Content="🡹" MinWidth="40" Padding="1,3,1,3" Click="ModifyItemInList"/>
                    <Button x:Name="DownButton" Content="🡻" MinWidth="40" Padding="1,3,1,3" Click="ModifyItemInList"/>
                    <Button x:Name="DeleteButton" Content="Remove" MinWidth="80" Padding="1,3,1,3" Click="ModifyItemInList"/>
                    <Button x:Name="ClearButton" Content="Clear" MinWidth="80" Padding="1,3,1,3" Click="OnClear"/>
                    <Button x:Name="OpenImageButton" Content="Open Image" MinWidth="100" Padding="1,3,1,3" Click="OnOpenImage"/>
                    <Button x:Name="SaveImageButton" Content="Save Image" MinWidth="100" Padding="1,3,1,3" Click="OnSaveImage"/>
                </StackPanel>
            </Grid>
        </GroupBox>

        <Grid Grid.Column="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Border Grid.Row="0" BorderBrush="#525463" BorderThickness="1" Background="#272833">
                <Image x:Name="ImagePreview" Width="512" Height="512" >
                    <Image.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Copy" Click="OnCopyImage">
                                <MenuItem.Icon>
                                    <Viewbox Width="16" Height="16">
                                        <Canvas Width="24" Height="24">
                                            <Path Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" Data="{StaticResource CopyIcon}" />
                                        </Canvas>
                                    </Viewbox>
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="Save" Click="OnSaveImage">
                                <MenuItem.Icon>
                                    <Viewbox Width="16" Height="16">
                                        <Canvas Width="24" Height="24">
                                            <Path Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" Data="{StaticResource SaveIcon}" />
                                        </Canvas>
                                    </Viewbox>
                                </MenuItem.Icon>
                            </MenuItem>
                        </ContextMenu>
                    </Image.ContextMenu>
                </Image>
            </Border>
        </Grid>
    </Grid>
</adonisControls:AdonisWindow>
