<UserControl x:Class="Valg.EVA.Skanning.UserInterfaceElements.BallotPaperImage.ImageView"
             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:controls="clr-namespace:Ab2d.Controls;assembly=Ab2d.Controls.ZoomPanel"
             xmlns:ballotPaperImage="clr-namespace:Valg.EVA.Skanning.UserInterfaceElements.BallotPaperImage"
             mc:Ignorable="d" 
             d:DataContext="{d:DesignInstance ballotPaperImage:BallotPaperImageViewModel}"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Valg.EVA.Skanning.Assets;component/ResourceDictionaries/ResourceLibrary.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <controls:ZoomPanel Name="ImageZoomPanel"
                            Viewbox="0.0 0.0 1.0 1.0"
                            RotationAngle="{Binding ElementName=RotationAngleSlider, Path=Value, Mode=TwoWay}"
                            IsMouseWheelZoomEnabled="True"  
                            IsAnimated="True" IsPanningAnimated="False" 
                            ZoomMode="Move"
                            IsViewboxLimited="True"
                            ViewboxLimits="-0.5 -0.5 2 2">
            <Image Width="auto" Height="auto" Stretch="Uniform">
                <Image.Source>
                    <PriorityBinding>
                        <Binding Path="Selected" IsAsync="True"></Binding>
                    </PriorityBinding>
                </Image.Source>
            </Image>
        </controls:ZoomPanel>
        <StackPanel Orientation="Vertical" HorizontalAlignment="Right">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,20,20,20" Width="280">
                <ToggleButton x:Name="MoveButton" Command="{x:Static controls:ZoomPanel.SetMoveModeCommand}" CommandTarget="{Binding ElementName=ImageZoomPanel}" Style="{StaticResource MoveImageButton}" Height="40" Width="40" Margin="0,0,0,0"></ToggleButton>
                <ToggleButton x:Name="RectangleButton" Command="{x:Static controls:ZoomPanel.SetRectangleModeCommand}" CommandTarget="{Binding ElementName=ImageZoomPanel}" Style="{StaticResource RectangleButton}" Height="40" Width="40" Margin="8,0,0,0"></ToggleButton>
                <ToggleButton x:Name="ZoomInButton" Command="{x:Static controls:ZoomPanel.SetZoomInModeCommand}" CommandTarget="{Binding ElementName=ImageZoomPanel}" Style="{StaticResource ZoomInButton}" Height="40" Width="40" Margin="8,0,0,0"></ToggleButton>
                <ToggleButton x:Name="ZoomOutButton" Command="{x:Static controls:ZoomPanel.SetZoomOutModeCommand}" CommandTarget="{Binding ElementName=ImageZoomPanel}" Style="{StaticResource ZoomOutButton}" Height="40" Width="40" Margin="8,0,0,0"></ToggleButton>
                <Button Command="{x:Static controls:ZoomPanel.ResetCommand}" CommandTarget="{Binding ElementName=ImageZoomPanel}" Style="{StaticResource ResetImageButton}" Height="40" Width="40" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="8,0,0,0"></Button>
                <Button Command="{Binding FlipImage}" Style="{StaticResource FlipImageButton}" Height="40" Width="40" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="8,0,0,0"></Button>
            </StackPanel>
            <controls:ZoomPanelMiniMap TargetZoomPanel="{Binding ElementName=ImageZoomPanel}" 
                                       Height="150" Width="280" 
                                       HorizontalAlignment="Right" VerticalAlignment="Bottom" 
                                       Margin="0,0,20,0"
                                       Visibility="{Binding ShowZoomPanelMiniMap, Converter={StaticResource BooleanToVisibilityConverter}}"/>
            <Slider Name="RotationAngleSlider" Minimum="-180" Maximum="180" Width="280" Value="0" TickPlacement="BottomRight" TickFrequency="90" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,20,20,0"/>
        </StackPanel>
    </Grid>
</UserControl>

