<UserControl x:Class="Machinations.WPF.PaintingCanvas"
             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" 
             mc:Ignorable="d"
             DataContext="{Binding RelativeSource={RelativeSource Self}}"
             >
    <UserControl.CommandBindings>
        <CommandBinding Command="Copy" Executed="CopyCommand" />
        <CommandBinding Command="Paste" Executed="PasteCommand" />
    </UserControl.CommandBindings>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <ScrollViewer Name ="ScrollViewer"
                      Grid.Column="0"
                      Grid.Row="0"
                      MaxWidth="{Binding ScrollViewerWidth}"
                      MaxHeight="{Binding ScrollViewerHeight}"
                      HorizontalScrollBarVisibility="Auto"
                      VerticalScrollBarVisibility="Auto">
            <Viewbox Stretch ="Uniform" Width="{Binding ViewBoxWidth}" Height="{Binding ViewBoxHeight}">
                <Canvas x:Name="RealCanvas"
                    Background="AntiqueWhite"
                    MouseLeftButtonDown="PaintingCanvas_OnMouseLeftButtonDown"
                    MouseMove="PaintingCanvas_OnMouseMove"
                    MouseLeftButtonUp="UIElement_OnMouseLeftButtonUp"
                    MouseRightButtonDown="RealCanvas_OnMouseRightButtonDown"
                    Width="{Binding CanvasWidth}"
                    Height="{Binding CanvasHeight}">
                    
                    <Canvas.InputBindings>
                        <KeyBinding Key="C" Modifiers="Control" Command="Copy" />
                        <KeyBinding Key="V" Modifiers="Control" Command="Copy" />
                    </Canvas.InputBindings>
                </Canvas>
            </Viewbox>
        </ScrollViewer>
        <Slider Grid.Row="1" Minimum="-1" Maximum="9" Value="{Binding ZoomValue}"/> 
    </Grid>
</UserControl>
