<local:AdministrationWindow x:Class="Elwig.Windows.DeliveryAdminWindow"
        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:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="Lieferungen - Elwig" Height="720" Width="1100" MinHeight="720" MinWidth="1000"
        Loaded="Window_Loaded">
    <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="Height" Value="25"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>
        </Style>
        <Style TargetType="ComboBox">
            <Setter Property="Height" Value="25"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
        </Style>
        <Style TargetType="xctk:CheckComboBox">
            <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="19"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="24"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" MinWidth="400"/>
            <ColumnDefinition Width="5"/>
            <ColumnDefinition Width="2*" MinWidth="560"/>
        </Grid.ColumnDefinitions>

        <Menu Grid.ColumnSpan="3" BorderThickness="0,0,0,1" BorderBrush="LightGray" Background="White">
            <MenuItem Header="Drucken">
                <MenuItem x:Name="Menu_Print_ShowDeliveryNote" Header="Lieferschein anzeigen" IsEnabled="False"
                          Click="Menu_Print_ShowDeliveryNote_Click"/>
                <MenuItem x:Name="Menu_Print_PrintDeliveryNote" Header="Lieferschein drucken" IsEnabled="False"
                          Click="Menu_Print_PrintDeliveryNote_Click"/>
                <MenuItem x:Name="Menu_Print_DeliveryJournal" Header="Lieferjournal">
                    <MenuItem x:Name="Menu_Print_DeliveryJournal_ShowToday" Header="von heute anzeigen"
                              Click="Menu_Print_DeliveryJournal_ShowToday_Click"/>
                    <MenuItem x:Name="Menu_Print_DeliveryJournal_PrintToday" Header="von heute drucken"
                              Click="Menu_Print_DeliveryJournal_PrintToday_Click"/>
                    <MenuItem x:Name="Menu_Print_DeliveryJournal_ShowFilter" Header="aus Filtern anzeigen"
                              Click="Menu_Print_DeliveryJournal_ShowFilter_Click"/>
                    <MenuItem x:Name="Menu_Print_DeliveryJournal_PrintFilter" Header="aus Filtern drucken"
                              Click="Menu_Print_DeliveryJournal_PrintFilter_Click"/>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="Exportieren">
                <MenuItem x:Name="Menu_Export_Bki" Header="Traubentransportscheinliste (BKI)"/>
            </MenuItem>
            <MenuItem Header="Einstellungen">
                <MenuItem x:Name="Menu_Settings_EnableFreeEditing" Header="Freie Bearbeitung aktivieren"
                          IsCheckable="True" Checked="Menu_Settings_EnableFreeEditing_Checked" Unchecked="Menu_Settings_EnableFreeEditing_Unchecked"/>
            </MenuItem>
        </Menu>

        <Grid Grid.Row="1" Margin="5,0,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="42"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="42"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <TextBox x:Name="SearchInput" Grid.ColumnSpan="3" Margin="5,10,161,0" IsReadOnly="False"
                     TextChanged="SearchInput_TextChanged">
                <TextBox.ToolTip>
                    <TextBlock>
                        Lieferungen filtern und durchsuchen. Die Filter sind beliebig kombinierbar.<LineBreak/>
                        Groß- und Kleinschreibung ist in den meisten Fällen egal.<LineBreak/>
                        <LineBreak/>
                        Filtern nach:<LineBreak/>
                        <Bold>Sorte</Bold>: z.B. GV, ZW, rr, sa, !gv (ausgenommen GV), ...<LineBreak/>
                        <Bold>Rot/Weiß</Bold>: z.B. r, Rot, w, weiß, ...<LineBreak/>
                        <Bold>Qualitätsstufe</Bold>: z.B. QUW, kab, !ldw (ausgenommen LDW), abgew[ertet], ...<LineBreak/>
                        <Bold>Gradation</Bold>: z.B. &gt;73, &lt;15, 17-18, 15-, &gt;17,5, 62-75, ...<LineBreak/>
                        <Bold>Mitglied</Bold>: z.B. 1234, 987, ...<LineBreak/>
                        <Bold>Saison</Bold>: z.B. 2020, &gt;2015, 2017-2019, &lt;2005, 2019-, ...<LineBreak/>
                        <Bold>Zweigstelle</Bold>: z.B. musterort, ...<LineBreak/>
                        <Bold>Attribut</Bold>: z.B. kabinett, !kabinett (alle außer kabinett), ...<LineBreak/>
                        <Bold>Bewirtschaftung</Bold>: z.B. bio, !kip (alle außer KIP), ...<LineBreak/>
                        <Bold>Datum</Bold>: z.B. 1.9., 15.9.-10.10., -15.10.2020, ...<LineBreak/>
                        <Bold>Uhrzeit</Bold>: z.B. 06:00-08:00, 18:00-, ...<LineBreak/>
                        <Bold>Freitext</Bold>: z.B. Lieferscheinnummern, Anmerkung, "quw" (sucht nach dem Text "quw")
                    </TextBlock>
                </TextBox.ToolTip>
            </TextBox>
            <xctk:IntegerUpDown x:Name="SeasonInput" Grid.ColumnSpan="3" Height="25" Width="56" FontSize="14" Minimum="1000" Maximum="9999"
                                Margin="0,10,100,0" VerticalAlignment="Top" HorizontalAlignment="Right"
                                ValueChanged="SeasonInput_ValueChanged"/>
            <CheckBox x:Name="TodayOnlyInput" Content="Nur heute"
                      HorizontalAlignment="Right" Margin="0,7,18,0" VerticalAlignment="Top" Grid.Column="1" Grid.ColumnSpan="2"
                      Checked="TodayOnlyInput_Changed" Unchecked="TodayOnlyInput_Changed"/>
            <CheckBox x:Name="AllSeasonsInput" Content="Jede Saison" IsEnabled="False"
                      HorizontalAlignment="Right" Margin="0,24,10,0" VerticalAlignment="Top" Grid.Column="1" Grid.ColumnSpan="2"
                      Checked="AllSeasonsInput_Changed" Unchecked="AllSeasonsInput_Changed"/>
            <DataGrid x:Name="DeliveryList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
                      SelectionChanged="DeliveryList_SelectionChanged"
                      CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False"
                      Margin="5,0,5,0" Grid.Row="1" FontSize="14" Grid.ColumnSpan="3">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="MgNr." Binding="{Binding MgNr, StringFormat='{}{0} '}" Width="50">
                        <DataGridTextColumn.CellStyle>
                            <Style>
                                <Setter Property="TextBlock.TextAlignment" Value="Right"/>
                            </Style>
                        </DataGridTextColumn.CellStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Datum" Binding="{Binding Date, StringFormat='dd.MM.yy'}" Width="70">
                        <DataGridTextColumn.CellStyle>
                            <Style>
                                <Setter Property="TextBlock.TextAlignment" Value="Center"/>
                            </Style>
                        </DataGridTextColumn.CellStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Zeit" Binding="{Binding Time, StringFormat='HH:mm'}" Width="50">
                        <DataGridTextColumn.CellStyle>
                            <Style>
                                <Setter Property="TextBlock.TextAlignment" Value="Center"/>
                            </Style>
                        </DataGridTextColumn.CellStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Sorte" Binding="{Binding FilteredSortIdString}" Width="50">
                        <DataGridTextColumn.CellStyle>
                            <Style>
                                <Setter Property="TextBlock.TextAlignment" Value="Center"/>
                            </Style>
                        </DataGridTextColumn.CellStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Gewicht" Binding="{Binding FilteredWeight, StringFormat='{}{0:N0} kg '}" Width="75">
                        <DataGridTextColumn.CellStyle>
                            <Style>
                                <Setter Property="TextBlock.TextAlignment" Value="Right"/>
                            </Style>
                        </DataGridTextColumn.CellStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Gradation" Binding="{Binding FilteredKmw, StringFormat='{}{0:N1}° '}" Width="50">
                        <DataGridTextColumn.CellStyle>
                            <Style>
                                <Setter Property="TextBlock.TextAlignment" Value="Right"/>
                            </Style>
                        </DataGridTextColumn.CellStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="LsNr." Binding="{Binding LsNr}" Width="120"/>
                    <DataGridTextColumn Header="Mitglied" Binding="{Binding Member.AdministrativeName}" Width="180"/>
                </DataGrid.Columns>
            </DataGrid>

            <Button x:Name="FinishButton" Content="Abschließen" IsEnabled="False" Visibility="Hidden"
                    ToolTip="Übernahme abschließen und Lieferschein drucken"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
                    Click="FinishButton_Click"/>
            <Button x:Name="NewDeliveryPartButton" Content="Neue Teil-Lfrg." IsEnabled="False" Visibility="Hidden"
                    ToolTip="Neue Teillieferung auf selben Lieferschein hinzufügen"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
                    Click="NewDeliveryPartButton_Click"/>
            <Button x:Name="CancelCreatingButton" Content="Abbrechen" IsEnabled="False" Visibility="Hidden"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
                    Click="CancelCreatingButton_Click"/>

            <Button x:Name="NewDeliveryButton" Content="Neu" IsEnabled="False" Visibility="Hidden"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
                    Click="NewDeliveryButton_Click"/>
            <Button x:Name="AbwertenButton" Content="Abwerten" IsEnabled="False" 
                    ToolTip="Ausgewählte Teillieferung vollständig oder teilweise abwerten"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
                    Click="AbwertenButton_Click"/>
            <Button x:Name="EditDeliveryButton" Content="Bearbeiten" IsEnabled="False"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
                    Click="EditDeliveryButton_Click"/>
            <Button x:Name="DeleteDeliveryButton" Content="Löschen" IsEnabled="False"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
                    Click="DeleteDeliveryButton_Click"/>

            <Button x:Name="SaveButton" Content="Speichern" IsEnabled="False" Visibility="Hidden"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,5,2.5,10" Grid.Column="0" Grid.Row="2"
                    Click="SaveButton_Click"/>
            <Button x:Name="ResetButton" Content="Zurücksetzen" IsEnabled="False" Visibility="Hidden"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,2.5,10" Grid.Column="1" Grid.Row="2"
                    Click="ResetButton_Click"/>
            <Button x:Name="CancelButton" Content="Abbrechen" IsEnabled="False" Visibility="Hidden" IsCancel="True"
                    HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,5,5,10" Grid.Column="2" Grid.Row="2"
                    Click="CancelButton_Click"/>
        </Grid>

        <GridSplitter Grid.Column="1" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

        <Grid Grid.Row="1" Grid.Column="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="0.625*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <GroupBox Header="Mitglied" Grid.Column="0" Grid.Row="0" Margin="5,5,5,5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="70"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <Label Content="Mitglied:" Margin="10,10,0,0" Grid.Column="0"/>
                    <TextBox x:Name="MgNrInput" Width="48" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" HorizontalAlignment="Left" TextAlignment="Right"
                             TextChanged="MgNrInput_TextChanged" LostFocus="MgNrInput_LostFocus" KeyUp="Input_KeyUp"/>
                    <ComboBox x:Name="MemberInput" Grid.Column="1" Margin="53,10,40,10" IsEditable="True"
                              ItemTemplate="{StaticResource MemberAdminNameTemplate}" TextSearch.TextPath="AdministrativeName"
                              SelectionChanged="MemberInput_SelectionChanged" KeyUp="Input_KeyUp"/>
                    <Button x:Name="MemberReferenceButton" Grid.Column="1" Height="25" Width="25" FontFamily="Segoe MDL2 Assets" Content="&#xEE35;" Padding="0,0,0,0"
                            Margin="10,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Right" ToolTip="Zu Mitglied springen"
                            Click="MemberReferenceButton_Click"/>

                    <Label Content="Wohnort:" Margin="10,38,0,0" Grid.Column="0"/>
                    <TextBox x:Name="MemberAddressField" Grid.Column="1" Margin="0,40,10,10" FontSize="12" Height="22"
                             IsReadOnly="True" IsTabStop="False"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Lieferung" Grid.Column="0" Grid.Row="1" Margin="5,5,5,5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <Label Content="LieferscheinNr.:" Margin="10,10,0,0" Grid.Column="0"/>
                    <TextBox x:Name="LsNrInput" Width="126" Grid.Column="1" HorizontalAlignment="Left" Margin="0,10,0,0"
                             IsReadOnly="True" IsTabStop="False"
                             TextChanged="TextBox_TextChanged"/>

                    <Label Content="Datum/Uhrzeit:" Margin="10,40,0,0" Grid.Column="0"/>
                    <TextBox x:Name="DateInput" Width="77" Grid.Column="1" HorizontalAlignment="Left" Margin="0,40,0,0"
                             IsReadOnly="True"
                             TextChanged="DateInput_TextChanged" LostFocus="DateInput_LostFocus"/>
                    <TextBox x:Name="TimeInput" Width="44" Grid.Column="1" HorizontalAlignment="Left" Margin="82,40,0,0"
                             IsReadOnly="True"
                             TextChanged="TimeInput_TextChanged" LostFocus="TimeInput_LostFocus"/>

                    <Label Content="Zweigstelle:" Margin="10,70,0,0" Grid.Column="0"/>
                    <ComboBox x:Name="BranchInput" Width="126" Margin="0,70,10,0" Grid.Column="1" HorizontalAlignment="Left"
                              IsEnabled="False"
                              SelectionChanged="BranchInput_SelectionChanged"
                              DisplayMemberPath="Name" TextSearch.TextPath="Name"/>

                    <Label Content="Anmerkung:" Margin="10,100,0,10"/>
                    <TextBox x:Name="CommentInput" Grid.Column="1" Margin="0,100,10,10"
                             TextChanged="TextBox_TextChanged"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Sorte" Grid.Column="1" Grid.Row="0" Margin="5,5,5,5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="80"/>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <Label Content="Sorte:" Margin="10,10,0,0" Grid.Column="0"/>
                    <TextBox x:Name="SortIdInput" Width="36" Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" HorizontalAlignment="Left"
                             TextChanged="SortIdInput_TextChanged" LostFocus="SortIdInput_LostFocus" KeyUp="Input_KeyUp"/>
                    <ComboBox x:Name="WineVarietyInput" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="41,10,10,10"
                              ItemTemplate="{StaticResource WineVarietyTemplate}" TextSearch.TextPath="Name"
                              SelectionChanged="WineVarietyInput_SelectionChanged" KeyUp="Input_KeyUp"/>

                    <Label Content="Attr./Bewirt.:" Margin="10,40,0,0" Grid.Column="0"/>
                    <ComboBox x:Name="AttributeInput" Grid.Row="1" Grid.Column="1" Margin="0,40,5,10"
                              DisplayMemberPath="Name"
                              SelectionChanged="AttributeInput_SelectionChanged" KeyUp="Input_KeyUp"/>
                    <ComboBox x:Name="CultivationInput" Grid.Row="1" Grid.Column="2" Margin="0,40,10,10"
                              DisplayMemberPath="Name"
                              SelectionChanged="CultivationInput_SelectionChanged" KeyUp="Input_KeyUp"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Gradation" Grid.Column="1" Grid.Row="1" Margin="5,5,5,5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Label Content="Gradation:" Margin="10,10,10,10"/>
                    <ctrl:UnitTextBox x:Name="GradationOeInput" Unit="°Oe" TextChanged="GradationOeInput_TextChanged" KeyUp="Input_KeyUp"
                                      Grid.Column="1" Width="54" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                    <Label Content="=" Margin="60,10,10,10" Grid.Column="1"/>
                    <ctrl:UnitTextBox x:Name="GradationKmwInput" Unit="°KMW" TextChanged="GradationKmwInput_TextChanged" KeyUp="Input_KeyUp"
                                      Grid.Column="1" Width="68" Margin="78,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                    <Label Content="Qualitätsstufe:" Margin="10,40,10,10"/>
                    <ComboBox x:Name="WineQualityLevelInput" Width="146" Margin="0,40,10,10" Grid.Column="1" HorizontalAlignment="Left"
                              ItemTemplate="{StaticResource WineQualityLevelTemplate}"
                              SelectionChanged="WineQualityLevelInput_SelectionChanged" KeyUp="Input_KeyUp"/>

                    <CheckBox x:Name="AbgewertetInput" Content="Abgewertet" IsEnabled="False"
                              VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Gewicht" Grid.Column="1" Grid.Row="2" Margin="5,5,5,5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="70"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <Label Content="Gewicht:" Margin="10,10,10,10"/>
                    <ctrl:UnitTextBox x:Name="WeightInput" Unit="kg" TextChanged="WeightInput_TextChanged"
                                      Grid.Column="1" Width="70" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>

                    <CheckBox x:Name="ManualWeighingInput" Content="Handwiegung" IsEnabled="False"
                              VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,45,10,10" Grid.Column="0" Grid.ColumnSpan="2"
                              Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>

                    <CheckBox x:Name="GerebeltGewogenInput" Content="Netto (gerebelt gewogen)"
                              VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"
                              Checked="GerebeltGewogenInput_Changed" Unchecked="GerebeltGewogenInput_Changed"/>

                    <Button x:Name="WeighingAButton" Content="Wiegen A" Width="120"
                            Click="WeighingButton_Click"
                            VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/>
                    <Button x:Name="WeighingBButton" Content="Wiegen B" Width="120"
                            Click="WeighingButton_Click"
                            VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,42,10,10" Grid.Column="2"/>
                    <Button x:Name="WeighingCButton" Content="Wiegen C" Width="120"
                            Click="WeighingButton_Click"
                            VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,74,10,10" Grid.Column="2"/>
                    <Button x:Name="WeighingDButton" Content="Wiegen D" Width="120"
                            Click="WeighingButton_Click"
                            VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,106,10,10" Grid.Column="2"/>
                    <Button x:Name="WeighingManualButton" Content="Handwiegung" Width="120"
                            Click="WeighingManualButton_Click"
                            VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,138,10,10" Grid.Column="2"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Sonstiges" Grid.Column="1" Grid.Row="3" Margin="5,5,5,10">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="65"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <Label Content="Zu-/Abschläge:" Margin="10,10,0,10"/>
                    <xctk:CheckComboBox x:Name="ModifiersInput" Margin="0,10,10,10" Grid.Column="1" Grid.ColumnSpan="2"
                                        ItemTemplate="{StaticResource ModifierTemplate}" Delimiter=", " AllItemsSelectedContent="Alle"
                                        ItemSelectionChanged="ModifiersInput_SelectionChanged"/>

                    <Label Content="Anmerkung:" Margin="10,40,0,10"/>
                    <TextBox x:Name="PartCommentInput" Grid.Column="1" Margin="0,40,10,10" Grid.ColumnSpan="2"
                             TextChanged="TextBox_TextChanged"/>

                    <Label Content="Temperatur:" Margin="10,70,0,10"/>
                    <ctrl:UnitTextBox x:Name="TemperatureInput" Unit="°C"
                                      TextChanged="TemperatureAcidInput_TextChanged" LostFocus="TemperatureAcidInput_LostFocus"
                                      Grid.Column="1" Margin="0,70,10,10" VerticalAlignment="Top"/>

                    <Label Content="Säure:" Margin="10,100,0,10"/>
                    <ctrl:UnitTextBox x:Name="AcidInput" Unit="g/l"
                                      TextChanged="TemperatureAcidInput_TextChanged" LostFocus="TemperatureAcidInput_LostFocus"
                                      Grid.Column="1" Margin="0,100,10,10" VerticalAlignment="Top"/>

                    <CheckBox x:Name="LesewagenInput" Content="Lesewagen" Margin="10,75,0,0" Grid.Column="2"
                              VerticalAlignment="Top" HorizontalAlignment="Left"
                              Checked="LesewagenInput_Changed" Unchecked="LesewagenInput_Changed"/>
                    <CheckBox x:Name="HandPickedInput" Content="Handlese" Margin="10,105,0,0" Grid.Column="2" IsThreeState="True"
                              VerticalAlignment="Top" HorizontalAlignment="Left"
                              Checked="HandPickedInput_Changed" Unchecked="HandPickedInput_Changed"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Teillieferungen" Grid.Column="0" Grid.Row="2" Margin="5,5,5,5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <ListBox x:Name="DeliveryPartList" Margin="5,5,5,38" Grid.ColumnSpan="2"
                             SelectionChanged="DeliveryPartList_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding DPNr}" Width="20"/>
                                    <TextBlock Text="{Binding SortId}" Width="30"/>
                                    <TextBlock Text="{Binding Kmw, StringFormat='{}{0:0.0}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"/>
                                    <TextBlock Text="{Binding QualId}" Width="30"/>
                                    <TextBlock Text="{Binding Weight, StringFormat='{}{0:N0} kg'}" Width="60" TextAlignment="Right" Padding="0,0,10,0"/>
                                    <TextBlock Text="{Binding Attribute.Name}" Width="60"/>
                                    <TextBlock Text="{Binding Cultivation.Name}" Width="50"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    <Button x:Name="ExtractDeliveryPartButton" Content="Extrahieren" IsEnabled="False"
                            ToolTip="Ausgewählte Teillieferung aus aktueller Lieferung entfernen und entweder anderer oder neuer Lieferung zuordnen"
                            HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="5,10,2.5,5" Grid.Column="0" Grid.Row="2"
                            Click="ExtractDeliveryPartButton_Click"/>
                    <Button x:Name="DeleteDeliveryPartButton" Content="Löschen" IsEnabled="False"
                            HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="2.5,10,5,5" Grid.Column="1" Grid.Row="2"
                            Click="DeleteDeliveryPartButton_Click"/>
                </Grid>
            </GroupBox>

            <GroupBox Header="Herkunft" Grid.Column="0" Grid.Row="3" Margin="5,5,5,10">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <Label Content="Weinbaugebiet:" Margin="10,10,0,10" Grid.Column="0"/>
                    <ComboBox x:Name="WineOriginInput" Margin="0,10,10,10" Grid.Column="1"
                              ItemTemplate="{StaticResource WineOriginComboTemplate}"/>

                    <Label Content="Weinbau-KG:" Margin="10,40,0,10" Grid.Column="0"/>
                    <ComboBox x:Name="WineKgInput" Margin="0,40,10,10" Grid.Column="1"
                              DisplayMemberPath="Name"
                              SelectionChanged="WineKgInput_SelectionChanged"/>

                    <Label Content="Ried:" Margin="10,70,0,10" Grid.Column="0"/>
                    <ComboBox x:Name="WineRdInput" Margin="0,70,10,10" Grid.Column="1"
                              DisplayMemberPath="Name"/>

                    <CheckBox x:Name="GebundenInput" Content="Gebunden" Margin="10,105,0,0" Grid.Column="0" Grid.ColumnSpan="2" IsThreeState="True"
                              VerticalAlignment="Top" HorizontalAlignment="Left"
                              Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
                </Grid>
            </GroupBox>
        </Grid>

        <StatusBar Grid.Row="5" Grid.ColumnSpan="3" BorderThickness="0,1,0,0" BorderBrush="Gray">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="2*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="3*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="3*"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem>
                <TextBlock x:Name="StatusMembers" Text="Mitglieder: -"/>
            </StatusBarItem>
            <Separator Grid.Column="1"/>
            <StatusBarItem Grid.Column="2">
                <TextBlock x:Name="StatusDeliveries" Text="Lieferungen: -"/>
            </StatusBarItem>
            <Separator Grid.Column="3"/>
            <StatusBarItem Grid.Column="4">
                <TextBlock x:Name="StatusVarieties" Text="Sorten: -"/>
            </StatusBarItem>
            <Separator Grid.Column="5"/>
            <StatusBarItem Grid.Column="6">
                <TextBlock x:Name="StatusWeight" Text="Gewicht: -">
                    <TextBlock.ToolTip>
                        <Grid x:Name="StatusWeightToolTip">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="10"/>
                                <ColumnDefinition Width="60"/>
                                <ColumnDefinition Width="80"/>
                                <ColumnDefinition Width="50"/>
                                <ColumnDefinition Width="50"/>
                            </Grid.ColumnDefinitions>
                        </Grid>
                    </TextBlock.ToolTip>
                </TextBlock>
            </StatusBarItem>
            <Separator Grid.Column="7"/>
            <StatusBarItem Grid.Column="8">
                <TextBlock x:Name="StatusGradation" Text="Gradation: -">
                    <TextBlock.ToolTip>
                        <Grid x:Name="StatusGradationToolTip">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="10"/>
                                <ColumnDefinition Width="60"/>
                                <ColumnDefinition Width="35"/>
                                <ColumnDefinition Width="35"/>
                                <ColumnDefinition Width="35"/>
                            </Grid.ColumnDefinitions>
                        </Grid>
                    </TextBlock.ToolTip>
                </TextBlock>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</local:AdministrationWindow>
