<mah:MetroWindow x:Class="ZKuP.Cards"
        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:mah="http://metro.mahapps.com/winfx/xaml/controls"
        xmlns:local="clr-namespace:ZKuP"
        mc:Ignorable="d"
        Title="Karten" Height="530" Width="943.5" Loaded="Window_Loaded" LocationChanged="Window_LocationChanged">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button x:Name="btnGreenRed" Grid.Column="0" FontFamily="Segoe UI" Padding="0" FontSize="28" Foreground="YellowGreen" BorderBrush="Beige" BorderThickness="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#252F3B" Click="GruenRot_Click">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/Resources/AusweisGruen_small.png" Height="30" Margin="0,0,20,0">
                            <Image.LayoutTransform>
                                <RotateTransform Angle="-5"/>
                            </Image.LayoutTransform>
                        </Image>
                        <TextBlock Text="Grün/Rot Karten"/>
                        <Image Source="/Resources/AusweisRot_small.png" Height="30" Margin="20,0,0,0">
                            <Image.LayoutTransform>
                                <RotateTransform Angle="5"/>
                            </Image.LayoutTransform>
                        </Image>
                    </StackPanel>
                </Button.Content>
            </Button>
            <Button x:Name="btnMcFit" BorderBrush="Beige" BorderThickness="1" Grid.Column="1" Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#252F3B" Click="McFit_Click">
                <Button.Content>
                    <Image Source="/Resources/mcfit.png" Height="39" Width="265"/>
                </Button.Content>
            </Button>
        </Grid>
        <TabControl x:Name="tabcontrol" TabStripPlacement="Top" Grid.Row="1" SelectionChanged="tabcontrol_SelectionChanged">
            <TabItem>
                <TabItem.Style>
                    <Style TargetType="TabItem" BasedOn="{StaticResource MahApps.Styles.TabItem}">
                        <Setter Property="HorizontalAlignment" Value="Left"/>
                    </Style>
                </TabItem.Style>
                <Grid Margin="5,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="60"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <DataGrid x:Name="dgCards" Grid.Row="1" Grid.ColumnSpan="2" Margin="0,10" EnableRowVirtualization="False" ItemsSource="{Binding Path=., Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" CanUserAddRows="False" AutoGenerateColumns="False" CanUserDeleteRows="False" PreviewKeyDown="dgCards_PreviewKeyDown" SelectionChanged="dgCards_SelectionChanged">
                        <DataGrid.Columns>
                            <DataGridCheckBoxColumn Binding="{Binding Path=[IsChecked], Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" CanUserSort="False">
                                <DataGridCheckBoxColumn.CellStyle>
                                    <Style TargetType="DataGridCell">
                                        <Style.Triggers>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter Property="IsEditing" Value="True"/>
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </DataGridCheckBoxColumn.CellStyle>
                                <DataGridCheckBoxColumn.Header>
                                    <TextBlock Text="☑" Background="Transparent" MouseLeftButtonDown="CheckBoxHeader_MouseLeftButtonDown"/>
                                </DataGridCheckBoxColumn.Header>
                                <!--<DataGridCheckBoxColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding Path=[IsChecked], Mode=TwoWay}" HorizontalAlignment="Center" Click="CheckBox_Click"/>
                                    </DataTemplate>
                                </DataGridCheckBoxColumn.CellTemplate>-->
                            </DataGridCheckBoxColumn>
                            <DataGridTextColumn Binding="{Binding kartennr}" ClipboardContentBinding="{x:Null}" Header="Kartennummer" Width="*"/>
                            <DataGridTextColumn Binding="{Binding farbe}" ClipboardContentBinding="{x:Null}" Header="Farbe" Width="80">
                                <DataGridTextColumn.HeaderStyle>
                                    <Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource MahApps.Styles.DataGridColumnHeader}">
                                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                                    </Style>
                                </DataGridTextColumn.HeaderStyle>
                                <DataGridTextColumn.ElementStyle>
                                    <Style TargetType="TextBlock">
                                        <Setter Property="TextAlignment" Value="Center"/>
                                    </Style>
                                </DataGridTextColumn.ElementStyle>
                            </DataGridTextColumn>
                            <DataGridTextColumn Binding="{Binding benutzer}" ClipboardContentBinding="{x:Null}" Header="Firma / Benutzer" Width="*"/>
                            <DataGridTextColumn Binding="{Binding telnr}" ClipboardContentBinding="{x:Null}" Header="Telefonnummer" Width="*"/>
                            <DataGridTextColumn Binding="{Binding AusgegebenDurch}" ClipboardContentBinding="{x:Null}" Header="Ausgegeben durch" Width="*"/>
                            <DataGridTextColumn Binding="{Binding AusgegebenTimestamp, StringFormat=\{0:dd.MM.yyyy HH:mm\}}" SortDirection="Descending" ClipboardContentBinding="{x:Null}" Header="Ausgegeben am" Width="*"/>
                        </DataGrid.Columns>
                    </DataGrid>
                    <Button x:Name="btnAdd" Grid.Row="0" Grid.Column="0" Margin="0,10,10,0" VerticalAlignment="Stretch" Click="btnAdd_Click" HorizontalAlignment="Stretch">
                        <Button.Content>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Karte ausgeben" FontSize="20" VerticalAlignment="Center" Margin="0,0,20,0"/>
                                <Image Source="/Resources/KarteAusgeben_small.png"/>
                            </StackPanel>
                        </Button.Content>
                    </Button>
                    <Button x:Name="btnDelete" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" Margin="10,10,0,0" VerticalAlignment="Stretch" IsEnabled="False" Click="btnDelete_Click">
                        <Button.Content>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Markierte Karte(n) zurücknehmen" VerticalAlignment="Center" Margin="0,0,20,0" FontSize="20"/>
                                <Image Source="/Resources/KarteZuruecknehmen_small.png"/>
                            </StackPanel>
                        </Button.Content>
                    </Button>
                </Grid>
            </TabItem>



            <TabItem>
                <Grid>

                    <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="110" Margin="5,8,0,0" VerticalAlignment="Top" Width="915" Background="#19FF0000"/>

                    <TextBlock Text="McFIT Karte ausgeben" Margin="10,10" FontWeight="Bold"/>


                    <TextBlock Text="Karte" Margin="10,30,0,0"/>
                    <TextBlock Text="Vorname" Margin="321,30,0,0"/>
                    <TextBlock Text="Name" Margin="160,30,0,0"/>
                    <TextBlock Text="Abteilung" Margin="479,30,0,0"/>
                    <TextBlock Text="Handynummer" Margin="571,30,0,0"/>
                    <TextBlock Text="Email" Margin="731,30,0,0"/>

                    <ComboBox x:Name="cBNameAusgabe" Height="22" Width="154" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="160,48,0,0" SelectionChanged="cBNameAusgabe_SelectionChanged"/>

                    <TextBox x:Name="tbAusVorname" Width="155" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="322,48,0,0" IsEnabled="False"/>
                    <TextBox x:Name="tbAusNachname" Width="155" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="161,48,0,0" TextChanged="tbAusNachname_TextChanged"/>
                    <TextBox x:Name="tbAusAbteilung" Width="87" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="480,48,0,0" IsEnabled="False"/>
                    <TextBox x:Name="tbAusHandy" Width="155" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="572,48,0,0" IsEnabled="False"/>
                    <TextBox x:Name="tbAusEmail" Width="176" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="732,48,0,0" IsEnabled="False"/>

                    <ComboBox x:Name="cBAusKarte" HorizontalAlignment="Left" Margin="10,48" VerticalAlignment="Top" Width="120" IsReadOnly="False">
                        <ComboBoxItem Content=""/>
                        <ComboBoxItem Content="Karte 1"/>
                        <ComboBoxItem Content="Karte 2"/>
                        <ComboBoxItem Content="Karte 3"/>
                        <ComboBoxItem Content="Karte 4"/>
                        <ComboBoxItem Content="Karte 5"/>
                    </ComboBox>
                    <Button x:Name="btnAusgebenUnterschrift" Content="Unterschrift / Karte ausgeben" Margin="6,87,3,0" Height="30" VerticalAlignment="Top" Click="btnAusgebenUnterschrift_Click"/>

                    <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="110" Margin="5,123,0,0" VerticalAlignment="Top" Width="915" Background="#1900A016"/>

                    <TextBlock Text="McFIT Karte zurücknehmen" FontWeight="Bold" Margin="10,125"/>

                    <TextBlock Text="Karte" Margin="10,151,0,0"/>
                    <TextBlock Text="Vorname" Margin="321,151,0,0"/>
                    <TextBlock Text="Name" Margin="160,151,0,0"/>
                    <TextBlock Text="Abteilung" Margin="479,151,0,0"/>
                    <TextBlock Text="Handynummer" Margin="571,151,0,0"/>
                    <TextBlock Text="Email" Margin="731,151,0,0"/>

                    <TextBox x:Name="tbZurVorname" Width="155" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="322,169,0,0" IsReadOnly="True" Background="{x:Null}"/>
                    <TextBox x:Name="tbZurNachname" Width="155" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="161,169,0,0" IsReadOnly="True" Background="{x:Null}"/>
                    <TextBox x:Name="tbZurAbteilung" Width="87" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="480,169,0,0" IsReadOnly="True" Background="{x:Null}"/>
                    <TextBox x:Name="tbZurHandy" Width="155" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="572,169,0,0" IsReadOnly="True" Background="{x:Null}"/>
                    <TextBox x:Name="tbZurEmail" Width="176" Height="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="732,169,0,0" IsReadOnly="True" Background="{x:Null}"/>

                    <ComboBox x:Name="cBZurKarte" HorizontalAlignment="Left" Margin="10,169,0,0" VerticalAlignment="Top" Width="120" IsReadOnly="True" SelectionChanged="cBZurKarte_SelectionChanged">
                        <ComboBoxItem Content=""/>
                        <ComboBoxItem Content="Karte 1"/>
                        <ComboBoxItem Content="Karte 2"/>
                        <ComboBoxItem Content="Karte 3"/>
                        <ComboBoxItem Content="Karte 4"/>
                        <ComboBoxItem Content="Karte 5"/>
                    </ComboBox>
                    <Button x:Name="btnZuruecknehmen" Content="Karte zurückgenommen" Margin="6,202,3,0" Height="30" VerticalAlignment="Top" Click="btnZuruecknehmen_Click"/>

                    <DataGrid x:Name="dgMcFit" Margin="5,254,5,5" ItemsSource="{Binding Path=., Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="True" CanUserAddRows="False" AutoGenerateColumns="False" CanUserDeleteRows="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding Kartennr}" ClipboardContentBinding="{x:Null}" Header="Nr" Width="38"/>
                            <DataGridTextColumn Binding="{Binding Vorname}" ClipboardContentBinding="{x:Null}" Header="Vorname" Width="*"/>
                            <DataGridTextColumn Binding="{Binding Nachname}" ClipboardContentBinding="{x:Null}" Header="Name" Width="*"/>
                            <DataGridTextColumn Binding="{Binding Abteilung}" ClipboardContentBinding="{x:Null}" Header="Abteilung" Width="85"/>
                            <DataGridTextColumn Binding="{Binding Handynr}" ClipboardContentBinding="{x:Null}" Header="Handy" Width="*"/>
                            <DataGridTextColumn Binding="{Binding Email}" ClipboardContentBinding="{x:Null}" Header="Email" Width="*"/>
                            <DataGridTextColumn Binding="{Binding AusgabeTimestamp, StringFormat=\{0:dd.MM.yyyy HH:mm\}}" ClipboardContentBinding="{x:Null}" Header="Ausgegeben" Width="100">
                                <DataGridTextColumn.ElementStyle>
                                    <Style TargetType="{x:Type TextBlock}">
                                        <Setter Property="TextAlignment" Value="Center" />
                                    </Style>
                                </DataGridTextColumn.ElementStyle>
                            </DataGridTextColumn>
                            <DataGridTextColumn Binding="{Binding ZurueckTimestamp, StringFormat=\{0:dd.MM.yyyy HH:mm\}}" ClipboardContentBinding="{x:Null}" Header="Zurückgegeben" Width="120">
                                <DataGridTextColumn.ElementStyle>
                                    <Style TargetType="{x:Type TextBlock}">
                                        <Setter Property="TextAlignment" Value="Center" />
                                    </Style>
                                </DataGridTextColumn.ElementStyle>
                            </DataGridTextColumn>
                            <DataGridCheckBoxColumn Binding="{Binding AktuellAusgegeben}" ToolTipService.InitialShowDelay="20" ClipboardContentBinding="{x:Null}" Width="40">
                                <DataGridCheckBoxColumn.Header>
                                    <TextBlock Text="AA" ToolTip="Aktuell Ausgegeben?" ToolTipService.InitialShowDelay="20"/>
                                </DataGridCheckBoxColumn.Header>
                            </DataGridCheckBoxColumn>
                            <DataGridTemplateColumn ClipboardContentBinding="{x:Null}" Header="Unterschrift" Width="110">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button x:Name="btnSignature" Content="Unterschrift" Click="btnSignature_Click"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
        </TabControl>

        <Grid x:Name="gridSpinner" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Grid.RowSpan="2">
            <local:ucSpinnerPiston HorizontalAlignment="Center" VerticalAlignment="Center">
                <local:ucSpinnerPiston.LayoutTransform>
                    <ScaleTransform ScaleX="2" ScaleY="2"/>
                </local:ucSpinnerPiston.LayoutTransform>
            </local:ucSpinnerPiston>
        </Grid>
    </Grid>
</mah:MetroWindow>
