<local:ContextWindow
        x:Class="Elwig.Windows.PaymentVariantsWindow"
        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:vm="clr-namespace:Elwig.ViewModels"
        xmlns:ctrl="clr-namespace:Elwig.Controls"
        Title="Auszahlungsvarianten - Elwig" Height="480" Width="850" MinHeight="400" MinWidth="850">
    <Window.DataContext>
        <vm:PaymentVariantsViewModel/>
    </Window.DataContext>
    <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="ctrl:UnitTextBox">
            <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="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="1*"/>
            <RowDefinition Height="24"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="320"/>
            <ColumnDefinition Width="2.5*"/>
        </Grid.ColumnDefinitions>

        <Menu Grid.ColumnSpan="2" BorderThickness="0,0,0,1" BorderBrush="LightGray" Background="White">
            <MenuItem Header="Variantendaten">
                <MenuItem x:Name="Menu_SummaryShow" Header="...anzeigen (PDF)" IsEnabled="{Binding IsPaymentVariantSelected}"
                          Click="Menu_SummaryShow_Click" InputGestureText="Strg+P">
                    <MenuItem.Icon>
                        <TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xE8FF;"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem x:Name="Menu_SummarySave" Header="...speichern... (PDF)" IsEnabled="{Binding IsPaymentVariantSelected}"
                          Click="Menu_SummarySave_Click">
                    <MenuItem.Icon>
                        <TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xEA90;"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem x:Name="Menu_SummaryExport" Header="...speichern... (Excel)" IsEnabled="{Binding IsPaymentVariantSelected}"
                          Click="Menu_SummaryExport_Click">
                    <MenuItem.Icon>
                        <TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xE9F9;"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem x:Name="Menu_SummaryPrint" Header="...drucken" IsEnabled="{Binding IsPaymentVariantSelected}"
                          Click="Menu_SummaryPrint_Click" InputGestureText="Strg+Shift+P">
                    <MenuItem.Icon>
                        <TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xE749;"/>
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="Buchungsliste">
                <MenuItem x:Name="Menu_ExportSave" Header="...speichern... (Excel)" IsEnabled="{Binding ExportIsEnabled}"
                          Click="Menu_ExportSave_Click" InputGestureText="Strg+L">
                    <MenuItem.Icon>
                        <TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xE9F9;"/>
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="Überweisungsdaten">
                <MenuItem x:Name="Menu_EbicsSave" Header="...exportieren... (EBICS)" IsEnabled="{Binding ExportIsEnabled}"
                          Click="Menu_EbicsSave_Click" InputGestureText="Strg+Ü">
                    <MenuItem.Icon>
                        <TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xE792;"/>
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
        </Menu>

        <Grid Grid.Row="1">
            <ListBox x:Name="PaymentVariantList" Margin="10,10,35,10" Grid.RowSpan="2"
                     SelectionChanged="PaymentVariantList_SelectionChanged"
                     ItemsSource="{Binding PaymentVariants, Mode=TwoWay}" SelectedItem="{Binding SelectedPaymentVariant, Mode=TwoWay}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Name}" Width="200"/>
                            <TextBlock Text="{Binding Date}" Width="60"/>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <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.RowSpan="2"
                    Click="AddButton_Click"/>
            <Button x:Name="CopyButton" IsEnabled="{Binding IsPaymentVariantSelected}"
                    Content="&#xE8C8;" FontFamily="Segoe MDL2 Assets" FontSize="12" Padding="0,0,0,0" ToolTip="Ausgewählte Auszahlungsvariante duplizieren"
                    VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,0" Grid.RowSpan="2"
                    Click="CopyButton_Click"/>
            <Button x:Name="DeleteButton" IsEnabled="{Binding DeleteIsEnabled}"
                    Content="&#xF8AB;" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" ToolTip="Ausgewählte Auszahlungsvariante löschen"
                    VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,60,5,0" Grid.RowSpan="2"
                    Click="DeleteButton_Click"/>

            <TextBox x:Name="DataInput" Text="{Binding Data, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding DataIsReadOnly}"
                     Margin="10,200,35,10"
                     HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Height="auto"
                     AcceptsReturn="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto"
                     FontFamily="Cascadia Code Light" FontSize="13"
                     TextChanged="DataInput_TextChanged"/>
        </Grid>

        <Grid Grid.Column="1" Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Label Content="Name:" Margin="10,10,0,0" Grid.Column="0"/>
            <TextBox x:Name="NameInput" Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly}"
                     Width="200" Grid.Column="1" HorizontalAlignment="Left" Margin="0,10,0,0"
                     TextChanged="NameInput_TextChanged"/>

            <Label Content="Beschreibung:" Margin="10,40,0,0" Grid.Column="0"/>
            <TextBox x:Name="CommentInput" Text="{Binding Comment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly}"
                     Grid.Column="1" HorizontalAlignment="Stretch" Margin="0,40,10,0"
                     TextChanged="CommentInput_TextChanged"/>

            <Label Content="Datum:" Margin="10,70,0,0" Grid.Column="0"/>
            <TextBox x:Name="DateInput" Text="{Binding DateString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly}"
                     Grid.Column="1" Width="77" HorizontalAlignment="Left" Margin="0,70,10,0"
                     TextChanged="DateInput_TextChanged"/>

            <Label Content="Überwiesen am:" Margin="10,100,0,0" Grid.Column="0"/>
            <TextBox x:Name="TransferDateInput" Text="{Binding TransferDateString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly}"
                     Grid.Column="1" Width="77" HorizontalAlignment="Left" Margin="0,100,10,0"
                     TextChanged="TransferDateInput_TextChanged"/>

            <Label Content="Rebelzuschlag:" Margin="10,130,0,0" Grid.Column="0"/>
            <ctrl:UnitTextBox x:Name="WeightModifierInput" Text="{Binding WeightModifierString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="{Binding IsReadOnly}"
                              Grid.Column="1" Width="60" Margin="0,130,10,0" Unit="%"
                              HorizontalAlignment="Left" VerticalAlignment="Top"
                              TextChanged="WeightModifierInput_TextChanged" LostFocus="WeightModifierInput_LostFocus"/>

            <TextBlock x:Name="MatzenNote" Grid.ColumnSpan="2" Margin="20,170,10,10" HorizontalAlignment="Left" VerticalAlignment="Top">
                Ob ein Mitglied den Treuebonus<LineBreak/>
                bekommt ist in der Buchungsliste<LineBreak/>
                (Spalte Zuschlag) ersichtlich.
            </TextBlock>

            <Label Content="Berücksichtigen:" Margin="90,70,10,10" Grid.Column="1"/>
            <CheckBox x:Name="ConsiderModifiersInput" IsChecked="{Binding ConsiderModifiers, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsEnabled}"
                      Content="Zu-/Abschläge bei Lieferungen (inkl. Rebelzuschl.)"
                      Margin="110,95,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
                      Checked="ConsiderModifiersInput_Changed" Unchecked="ConsiderModifiersInput_Changed"/>
            <CheckBox x:Name="ConsiderPenaltiesInput" IsChecked="{Binding ConsiderPenalties, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsEnabled}"
                      Content="Pönalen bei Unterlieferungen (FB)"
                      Margin="110,115,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
                      Checked="ConsiderPenaltiesInput_Changed" Unchecked="ConsiderPenaltiesInput_Changed"/>
            <CheckBox x:Name="ConsiderPenaltyInput" IsChecked="{Binding ConsiderPenalty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsEnabled}"
                      Content="Strafen bei Unterlieferungen (GA)"
                      Margin="110,135,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
                      Checked="ConsiderPenaltyInput_Changed" Unchecked="ConsiderPenaltyInput_Changed"/>
            <CheckBox x:Name="ConsiderAutoInput" IsChecked="{Binding ConsiderAuto, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsEnabled}"
                      Content="Automatische Nachzeichnungen der GA"
                      Margin="110,155,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
                      Checked="ConsiderAutoInput_Changed" Unchecked="ConsiderAutoInput_Changed"/>
            <CheckBox x:Name="ConsiderCustomInput" IsChecked="{Binding ConsiderCustom, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsEnabled}"
                      Content="Benutzerdefinierte Zu-/Abschläge pro Mitglied"
                      Margin="110,175,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
                      Checked="ConsiderCustomInput_Changed" Unchecked="ConsiderCustomInput_Changed"/>
            <Label Content="&#xF0AE;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="0" Grid.Column="1" Margin="108,195,10,10"/>

            <Grid Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="50,200,10,10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="110"/>
                    <ColumnDefinition Width="27"/>
                    <ColumnDefinition Width="110"/>
                    <ColumnDefinition Width="27"/>
                    <ColumnDefinition Width="110"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="27"/>
                    <RowDefinition Height="5"/>
                    <RowDefinition Height="27"/>
                    <RowDefinition Height="5"/>
                    <RowDefinition Height="27"/>
                </Grid.RowDefinitions>

                <Grid.Resources>
                    <Style TargetType="Label">
                        <Setter Property="HorizontalAlignment" Value="Center"/>
                        <Setter Property="VerticalAlignment" Value="Center"/>
                        <Setter Property="Padding" Value="0"/>
                        <Setter Property="Height" Value="auto"/>
                    </Style>
                    <Style TargetType="Button">
                        <Setter Property="HorizontalAlignment" Value="Stretch"/>
                        <Setter Property="FontSize" Value="14"/>
                    </Style>
                </Grid.Resources>

                <Button x:Name="EditButton" IsEnabled="{Binding IsPaymentVariantSelected}"
                        Content="{Binding EditText}" Grid.Column="0" Grid.Row="2"
                        Click="EditButton_Click"/>
                <Label Content="&#xF0AF;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="2" Grid.Column="1"/>
                <Button x:Name="ModifierButton" Content="Zu-/Abschläge" Grid.Column="0" Grid.Row="4"
                        Click="ModifierButton_Click"/>
                <Label Content="&#xF0AF;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="4" Grid.Column="1" RenderTransformOrigin="0.5,0.5" >
                    <Label.RenderTransform>
                        <TransformGroup>
                            <RotateTransform Angle="-45"/>
                            <TranslateTransform Y="-5"/>
                        </TransformGroup>
                    </Label.RenderTransform>
                </Label>
                <Button x:Name="CalculateButton" IsEnabled="{Binding CalculateIsEnabled}"
                        Content="Berechnen" Grid.Column="2" Grid.Row="2"
                        Click="CalculateButton_Click"/>
                <Label Content="{Binding Arrow}" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="2" Grid.Column="3"/>
                <Button x:Name="PaymentAdjustmentButton" Content="Anpassen" Grid.Column="2" Grid.Row="4"
                        Click="PaymentAdjustmentButton_Click"/>
                <Label Content="{Binding Arrow}" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="4" Grid.Column="3" RenderTransformOrigin="0.5,0.5" >
                    <Label.RenderTransform>
                        <TransformGroup>
                            <RotateTransform Angle="-45"/>
                            <TranslateTransform Y="-5"/>
                        </TransformGroup>
                    </Label.RenderTransform>
                </Label>
                <Button x:Name="CommitButton" IsEnabled="{Binding CommitIsEnabled}" Visibility="{Binding CommitVisibility}"
                        Content="Festsetzen" Grid.Column="4" Grid.Row="2"
                        Click="CommitButton_Click"/>
                <Button x:Name="RevertButton" IsEnabled="{Binding RevertIsEnabled}" Visibility="{Binding RevertVisibility}"
                        Content="Freigeben" Grid.Column="4" Grid.Row="2"
                        Click="RevertButton_Click"/>
                <Button x:Name="SaveButton" IsEnabled="{Binding SaveIsEnabled}"
                        Content="Speichern" Grid.Column="4" Grid.Row="0"
                        Click="SaveButton_Click"/>
            </Grid>

            <Button x:Name="MailButton" IsEnabled="{Binding IsPaymentVariantSelected}"
                    FontSize="14" Width="180" Margin="10,10,10,10" Height="30"
                    Click="MailButton_Click"
                    VerticalAlignment="Bottom" HorizontalAlignment="Right" HorizontalContentAlignment="Stretch" Grid.Column="1">
                <Grid>
                    <TextBlock FontFamily="Segoe MDL2 Assets" FontSize="16" Text="&#xE715;"
                               TextAlignment="Left" HorizontalAlignment="Left" Padding="0,1.5,0,0" Margin="0,0,10,0"/>
                    <TextBlock Margin="18,0,0,0" TextAlignment="Center">Traubengutschriften</TextBlock>
                </Grid>
            </Button>
        </Grid>

        <StatusBar Grid.Row="2" Grid.ColumnSpan="2" BorderThickness="0,1,0,0" BorderBrush="Gray">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem Grid.Column="0" HorizontalContentAlignment="Stretch">
                <DockPanel>
                    <TextBlock Text="Zu-/Abschl.:"/>
                    <TextBlock Text="{Binding StatusModifierSum}" TextAlignment="Right"/>
                </DockPanel>
            </StatusBarItem>
            <Separator Grid.Column="1"/>
            <StatusBarItem Grid.Column="2" HorizontalContentAlignment="Stretch">
                <DockPanel>
                    <TextBlock Text="Gesamt:"/>
                    <TextBlock Text="{Binding StatusTotalSum}" TextAlignment="Right"/>
                </DockPanel>
            </StatusBarItem>
            <Separator Grid.Column="3"/>
            <StatusBarItem Grid.Column="4" HorizontalContentAlignment="Stretch">
                <DockPanel>
                    <TextBlock Text="MwSt.:"/>
                    <TextBlock Text="{Binding StatusVatSum}" TextAlignment="Right"/>
                </DockPanel>
            </StatusBarItem>
            <Separator Grid.Column="5"/>
            <StatusBarItem Grid.Column="6" HorizontalContentAlignment="Stretch">
                <DockPanel>
                    <TextBlock Text="Abzüge:"/>
                    <TextBlock Text="{Binding StatusDeductionSum}" TextAlignment="Right"/>
                </DockPanel>
            </StatusBarItem>
            <Separator Grid.Column="7"/>
            <StatusBarItem Grid.Column="8" HorizontalContentAlignment="Stretch">
                <DockPanel>
                    <TextBlock Text="Auszahl.:"/>
                    <TextBlock Text="{Binding StatusPaymentSum}" TextAlignment="Right"/>
                </DockPanel>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</local:ContextWindow>
