<Window x:Class="KoloryWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"        
        xmlns:local="clr-namespace:KoloryWPF"
        mc:Ignorable="d"
        xmlns:vm="clr-namespace:KoloryWPF.ModelWidoku"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        Title="Kolory WPF" Height="480" Width="640" 
        >
        <!-- KeyDown="Window_KeyDown" Closed="Window_Closed" >-->
    <Window.DataContext>
        <vm:EdycjaKoloru />
    </Window.DataContext>
    <Window.InputBindings>
        <KeyBinding Key="R" Modifiers="Control" Command="{Binding Resetuj}" />
        <MouseBinding Gesture="Alt+MiddleClick" Command="{Binding Resetuj}" />
        <!--<KeyBinding Key="Escape" Command="{Binding ZamknijOkno}" />-->
        <KeyBinding Key="Escape" Command="{Binding ZamknijOkno}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}}" />
    </Window.InputBindings>
    <Window.Resources>
        <vm:EdycjaKoloru x:Key="edycjaKoloru" />
        <local:ByteToDoubleConverter x:Key="konwersjaByteDouble" />
        <local:ColorToSolidColorBrushConverter x:Key="konwersjaColorBrush" />
        <local:SkładoweRGBToSolidColorBrushConverter x:Key="konwersjaRGBBrush" />
        <local:SkładoweRGBDoubleToSolidColorBrushConverter x:Key="konwersjaRGBDoubleBrush" />
    </Window.Resources>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closed">
            <i:InvokeCommandAction Command="{Binding Zapisz}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <!--<Grid DataContext="{StaticResource edycjaKoloru}">-->
    <Grid>
        <!--
        <Rectangle x:Name="rectangle" Margin="10,10,10,91.4" Stroke="Black">
            <Rectangle.Fill>
                <SolidColorBrush Color="{Binding Path=Color, Mode=OneWay}" />
            </Rectangle.Fill>
        </Rectangle>
        -->
        <!--
        <Rectangle x:Name="rectangle" Margin="10,10,10,91.4" Stroke="Black"
                   Fill="{Binding Color, Converter={StaticResource konwersjaColorBrush}}" />
        -->
        <!--
        <Rectangle x:Name="rectangle" Margin="10,10,10,91.4" Stroke="Black">
            <Rectangle.Fill>
                <MultiBinding Mode="OneWay" Converter="{StaticResource konwersjaRGBBrush}">
                    <Binding Path="R" />
                    <Binding Path="G" />
                    <Binding Path="B" />
                </MultiBinding>
            </Rectangle.Fill>
        </Rectangle>
        -->
        <Rectangle x:Name="rectangle" Margin="10,10,10,121" Stroke="Black">
            <Rectangle.Fill>
                <MultiBinding Mode="OneWay" 
                              Converter="{StaticResource konwersjaRGBDoubleBrush}">
                    <Binding ElementName="sliderR" Path="Value" />
                    <Binding ElementName="sliderG" Path="Value" />
                    <Binding ElementName="sliderB" Path="Value" />
                </MultiBinding>
            </Rectangle.Fill>
        </Rectangle>
        <Slider x:Name="sliderR" Margin="10,0,40,94" Height="22" VerticalAlignment="Bottom" 
                Maximum="255" 
                Value="{Binding Path=R, Mode=TwoWay, Converter={StaticResource konwersjaByteDouble}}" />
        <TextBlock Height="22" VerticalAlignment="Bottom" 
           HorizontalAlignment="Right" Margin="10,0,10,94" 
           Text="{Binding ElementName=sliderR, Path=Value}" />
        <Slider x:Name="sliderG" Margin="10,0,40,67" Height="22" VerticalAlignment="Bottom" 
                Maximum="255" 
                Value="{Binding Path=G, Mode=TwoWay, Converter={StaticResource konwersjaByteDouble}}" />
        <TextBlock Height="22" VerticalAlignment="Bottom" 
           HorizontalAlignment="Right" Margin="10,0,10,67" 
           Text="{Binding ElementName=sliderG, Path=Value}" />
        <Slider x:Name="sliderB" Margin="10,0,40,40" Height="22" VerticalAlignment="Bottom" 
                Maximum="255" 
                Value="{Binding Path=B, Mode=TwoWay, Converter={StaticResource konwersjaByteDouble}}" />
        <TextBlock Height="22" VerticalAlignment="Bottom" 
           HorizontalAlignment="Right" Margin="10,0,10,40" 
           Text="{Binding ElementName=sliderB, Path=Value}" />
        <!--
        <Button Content="Resetuj" Height="25" Width="75" 
                VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10,0,0,10"
                Command="{Binding Resetuj}" CommandParameter="{StaticResource edycjaKoloru}" />
        -->
        <Button Content="Resetuj" Height="25" Width="75" 
                VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10,0,0,10"
                Command="{Binding Resetuj}" />
    </Grid>
</Window>
