<local:ContextWindow
        x:Class="Elwig.Windows.ChartWindow"
        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:Elwig.Windows"
        xmlns:ctrl="clr-namespace:Elwig.Controls"
        xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF"
        mc:Ignorable="d"
        Title="Auszahlung - Elwig" Height="700" Width="1500" MinWidth="1000" MinHeight="500"
        Loaded="Window_Loaded"
        Closing="Window_Closing">

    <Window.Resources>
        <Style TargetType="Label">
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="Padding" Value="2,4,2,4"/>
            <Setter Property="Height" Value="25"/>
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="IsReadOnly" Value="True"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>
        </Style>
        <Style TargetType="ctrl:UnitTextBox">
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Padding" Value="2"/>
            <Setter Property="IsReadOnly" Value="True"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>
        </Style>
        <Style TargetType="ComboBox">
            <Setter Property="IsEnabled" Value="False"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
        </Style>
        <Style TargetType="Button">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Padding" Value="9,3"/>
            <Setter Property="Height" Value="27"/>
        </Style>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="200"/>
        </Grid.ColumnDefinitions>

        <Grid Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="560"/>
                <ColumnDefinition Width="100"/>
            </Grid.ColumnDefinitions>

            <Label Content="Für:" Margin="10,-2,0,0" FontSize="14" Grid.Column="0" VerticalAlignment="Center"/>
            <ctrl:CheckComboBox x:Name="VaributeInput" Margin="50,0,0,0" Grid.Column="0" Width="500" Height="25" HorizontalAlignment="Left"
                                IsSelectAllActive="True" SelectAllContent="Alle Sorten" Delimiter=", " AllItemsSelectedContent="Alle Sorten"
                                IsEnabled="False" SelectionChanged="VaributeInput_Changed">
                <ctrl:CheckComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Variety.Name}" Foreground="{Binding Variety.Color}" Width="150"/>
                            <TextBlock Text="{Binding Variety.Type}" Foreground="{Binding Variety.Color}" Width="30"/>
                            <TextBlock Text="{Binding Attribute.Name}" Width="80"/>
                            <TextBlock Text="{Binding Cultivation.Name}" Width="80"/>
                            <TextBlock Text="{Binding AssignedGraphId}" Width="30"/>
                            <TextBlock Text="{Binding AssignedAbgewGraphId}" Width="30"/>
                        </StackPanel>
                    </DataTemplate>
                </ctrl:CheckComboBox.ItemTemplate>
            </ctrl:CheckComboBox>

            <CheckBox x:Name="AbgewertetInput" Content="Abgewertet" IsEnabled="False" Checked="AbgewertetInput_Changed" Unchecked="AbgewertetInput_Changed"
                      VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Column="1"/>
        </Grid>

        <ListBox x:Name="GraphList" Margin="10,10,35,42" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" SelectionChanged="GraphList_SelectionChanged">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Id}" Foreground="{Binding Color}" Width="30"/>
                        <TextBlock Text="{Binding VaributeStringSimple}" Foreground="{Binding Color}"  ToolTip="{Binding VaributeString}"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <Button x:Name="SaveButton" Content="Speichern &amp; Berechnen" IsEnabled="False"
            HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="10,5,35,10" Grid.Column="0" Grid.Row="2"
            Click="SaveButton_Click"/>

        <Button x:Name="AddButton" Content="&#xF8AA;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" ToolTip="Neue Auszahlungsvariante hinzufügen"
            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,60" Grid.Column="0" Grid.RowSpan="2" Grid.Row="0"
            Click="AddButton_Click"/>
        <Button x:Name="CopyButton" Content="&#xE8C8;" FontFamily="Segoe MDL2 Assets" FontSize="12" Padding="0,0,0,0" IsEnabled="False" ToolTip="Ausgewählte Auszahlungsvariante duplizieren"
            VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="0,0,5,0" Grid.Column="0" Grid.RowSpan="2" Grid.Row="0"
            Click="CopyButton_Click"/>
        <Button x:Name="DeleteButton" Content="&#xF8AB;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False" ToolTip="Ausgewählte Auszahlungsvariante löschen"
                VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,60,5,0" Grid.Column="0" Grid.RowSpan="2" Grid.Row="0"
                Click="DeleteButton_Click"/>

        <Grid Grid.Row="1" Grid.Column="1" Margin="0,0,10,10">
            <ScottPlot:WpfPlot x:Name="OechslePricePlot" IsEnabled="False"
                               MouseWheel="OechslePricePlot_MouseWheel" MouseMove="OechslePricePlot_MouseMove" MouseDown="OechslePricePlot_MouseDown"/>
        </Grid>

        <Grid Grid.Row="1" Grid.Column="2" Margin="0,0,5,36">
            <Grid.RowDefinitions>
                <RowDefinition Height="120"/>
                <RowDefinition Height="90"/>
                <RowDefinition Height="210"/>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="110"/>
            </Grid.RowDefinitions>

            <GroupBox Header="Datenpunkt" Grid.Row="0" Margin="0,5,5,5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="65"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Label Content="Oechsle:" Margin="10,10,0,0" Grid.Column="0"/>
                    <ctrl:UnitTextBox x:Name="OechsleInput" Unit="°Oe" TextChanged="OechsleInput_TextChanged" IsEnabled="False"
                                      Grid.Column="1" Width="52" Margin="0,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                    <CheckBox x:Name="GebInput" Content="Geb." IsEnabled="False"
                              Grid.Column="1" Margin="0,15,10,0" HorizontalAlignment="Right" VerticalAlignment="Top"
                              Checked="GebInput_Changed" Unchecked="GebInput_Changed"/>

                    <Label Content="Preis:" Margin="10,40,0,0" Grid.Column="0"/>
                    <ctrl:UnitTextBox x:Name="PriceInput" Unit="€/kg" TextChanged="PriceInput_TextChanged" IsEnabled="False"
                                      Grid.Column="1" Margin="0,40,10,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Gebunden Aufschlag" Grid.Row="1" Margin="0,5,5,5">
                <Grid>

                    <StackPanel Margin="10,10,0,0">
                        <RadioButton x:Name="GebundenTypeFixed" GroupName="GebundenType" Checked="GebundenType_Checked" IsEnabled="False">Fix</RadioButton>
                        <RadioButton x:Name="GebundenTypeGraph" GroupName="GebundenType" Checked="GebundenType_Checked" IsEnabled="False">Frei</RadioButton>
                        <RadioButton x:Name="GebundenTypeNone" GroupName="GebundenType" Checked="GebundenType_Checked" IsEnabled="False">Nein</RadioButton>
                    </StackPanel>

                    <ctrl:UnitTextBox x:Name="GebundenFlatBonus" Unit="€/kg" TextChanged="GebundenFlatBonus_TextChanged" IsEnabled="False"
                                      Width="90" Margin="5,5,5,5" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Aktionen" Grid.Row="2" Margin="0,5,5,5">
                <Grid>
                    <Button x:Name="LeftFlatButton" Content="Links flach" Click="LeftFlatButton_Click" IsEnabled="False"
                            HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,10,10,10"/>
                    <Button x:Name="RightFlatButton" Content="Rechts flach" Click="RightFlatButton_Click" IsEnabled="False"
                            HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,45,10,10"/>
                    <Button x:Name="InterpolateButton" Content="Interpolieren" Click="InterpolateButton_Click" IsEnabled="False"
                            HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,80,10,10"/>
                    <Button x:Name="LinearIncreaseButton" Content="Linear wachsen" Click="LinearIncreaseButton_Click" IsEnabled="False"
                            HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="10,115,10,10"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Optionen" Grid.Row="4" Margin="0,5,5,5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <CheckBox x:Name="FreeZoomInput" Content="Freier Zoom" IsEnabled="False"
                            Checked="FreeZoomInput_Changed" Unchecked="FreeZoomInput_Changed"
                            HorizontalAlignment="Left" Margin="10,10,10,0" VerticalAlignment="Top"/>

                    <CheckBox x:Name="GradationLinesInput" Content="Gradationslinien anzeigen" IsEnabled="False"
                            Checked="GradationLinesInput_Changed" Unchecked="GradationLinesInput_Changed"
                            HorizontalAlignment="Left" Margin="10,30,10,0" VerticalAlignment="Top" IsChecked="True"/>

                    <CheckBox x:Name="TooltipInput" Content="Tooltips anzeigen" IsEnabled="False"
                            HorizontalAlignment="Left" Margin="10,50,10,0" VerticalAlignment="Top" IsChecked="True"/>
                </Grid>
            </GroupBox>
        </Grid>
    </Grid>
</local:ContextWindow>
