<?xml version="1.0" encoding="utf-8"?>
<UserControl
    x:Class="Sonex.Client.Controls.DataGridView.DataGridView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Sonex.Client.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:canvas="using:Microsoft.Graphics.Canvas.UI.Xaml"
    xmlns:toolkit="using:AK.Toolkit.WinUI3"
    mc:Ignorable="d"

    
    AllowFocusOnInteraction="True"
    >

    <!-- Glowny kontener kontrolki: obszar danych + paski przewijania + stopka. -->
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <!-- Powierzchnia rysowania DataGridView (naglowki, komorki, zaznaczenia). -->
        <Border Grid.Row="1" Grid.Column="1" Background="{ThemeResource ScrollBarBackground}" />
        <canvas:CanvasControl x:Name="_Canvas"

                IsHitTestVisible="True"
                IsTabStop="True"
                TabIndex="0"
                
                UseSystemFocusVisuals="True"
                Background="White"

                Grid.Row="0" Grid.Column="0">

        </canvas:CanvasControl>
        <!-- Przycisk w lewym gornym rogu otwierajacy menu kontekstowe tabeli. -->
        <Button x:Name="_CornerMenuButton"
                Grid.Row="0"
                Grid.Column="0"
                Width="26"
                Height="22"
                Padding="0"
                Margin="0"
                CornerRadius="0"
                
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                IsTabStop="False"
                AllowFocusOnInteraction="False"
                ToolTipService.ToolTip="Table menu"
                Background="{ThemeResource SolidBackgroundFillColorTertiaryBrush}"
                BorderBrush="Transparent"
                BorderThickness="0,0,1,1"
                Click="_CornerMenuButton_Click">
            <FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xE712;" FontSize="12" />
        </Button>
        <ProgressBar Margin="0,0,0,0" Visibility="Collapsed" IsIndeterminate="True" ShowPaused="False" ShowError="False" VerticalAlignment="Top" />
        <ProgressRing x:Name="_ProgressRing" IsActive="False">
        </ProgressRing>
        <!-- Prawy pionowy pasek przewijania. -->
        <Border  Grid.Row="0" Grid.Column="1" BorderThickness="0.5, 0, 0, 0" BorderBrush="{ThemeResource SurfaceStrokeColorFlyoutBrush}">
            <ScrollBar x:Name="_ScrollVertical"  
                    
                    toolkit:ScrollBarExtensions.KeepVerticalExpanded="True"
                    toolkit:ScrollBarExtensions.KeepHorizontalExpanded="True"
                   Orientation="Vertical" 
                   IndicatorMode="MouseIndicator" 
                   CanBeScrollAnchor="True" 
                   Width="18" 
                   Visibility="Visible" 
                   Opacity="1" 
                   Padding="0" 
                   IsTabStop="False"
                   AllowFocusOnInteraction="False"
                   Background="Transparent" />
        </Border>
        <!-- Dolna stopka: statystyki oraz poziomy pasek przewijania. -->
        <Border Grid.Row="1" Grid.Column="0" BorderThickness="0, 0.5, 0, 0" BorderBrush="{ThemeResource SurfaceStrokeColorFlyoutBrush}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <TextBlock x:Name="_FooterText1"  Grid.Column="0" Text="Rows: 0/0"  FontSize="12" Padding="8 0 8 0"  VerticalAlignment="Center"/>
                <TextBlock x:Name="_FooterText2" Grid.Column="1" Text="Selected: 0 rows"  FontSize="12" Padding="8 0 8 0"  VerticalAlignment="Center"/>
                <TextBlock x:Name="_FooterText3" Grid.Column="2" Text="Filtered: 0 | Sum: 0.00" FontSize="12"  Padding="8 0 8 0"  VerticalAlignment="Center"/>
                <ScrollBar  
                                        toolkit:ScrollBarExtensions.KeepVerticalExpanded="True"
                    toolkit:ScrollBarExtensions.KeepHorizontalExpanded="True"
                        x:Name="_ScrollHorizontal"
                        Grid.Column="3"
                        Orientation="Horizontal"
                        IndicatorMode="MouseIndicator"
                        CanBeScrollAnchor="True"
                        Height="26"
                        Visibility="Visible"
                        Opacity="1"
                        IsTabStop="False"
                        AllowFocusOnInteraction="False"
                        Background="Transparent"
                        HorizontalAlignment="Stretch"/>
            </Grid>

        </Border>

    </Grid>
</UserControl>
