<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:vms="clr-namespace:MauiTestApp.ViewModels"
             xmlns:graph="clr-namespace:MauiTestApp.Graphing"
             x:Class="MauiTestApp.Pages.SIGPage"
             Title="SIGPage">
    <ContentPage.BindingContext>
        <vms:SIGViewModel x:Name="Binder"/>
    </ContentPage.BindingContext>

    <ContentPage.Resources>
        <graph:Graph x:Key="KeypairGraph" x:Name="KeypairGraph"/>
        <graph:Graph x:Key="SignGraph" x:Name="SignGraph"/>
    </ContentPage.Resources>

    <ScrollView>
        <VerticalStackLayout>
            <Picker Margin="10" Grid.Row="0" Title="Select a SIG algorithm..." ItemsSource="{Binding Algorithms}" SelectedItem="{Binding SelectedAlgorithm}"/>
            <Button Margin="10" Grid.Row="1" Text="Perform test" Command="{Binding TestCommand}"/>

            <!--Lengths-->
            <Label Text="Data lengths" VerticalOptions="Center" HorizontalOptions="Center" />
            <Grid ColumnSpacing="-3" RowSpacing="-4" Margin="10,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Border Grid.Row="0" Grid.Column="0">
                    <Label Text="Signature" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="0" Grid.Column="1">
                    <Label Text="Secret key" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="0" Grid.Column="2">
                    <Label Text="Public key" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="0">
                    <Label Text="{Binding SignatureLength}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="1">
                    <Label Text="{Binding SecretKeyLength}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="2">
                    <Label Text="{Binding PublicKeyLength}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
            </Grid>

            <Label Text="Key Pairs" VerticalOptions="Center" HorizontalOptions="Center" />
            <Grid ColumnSpacing="-3" RowSpacing="-4" Margin="10,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Border Grid.Row="0" Grid.Column="0">
                    <Label Text="Memory" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="0" Grid.Column="1">
                    <Label Text="CPU" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="0" Grid.Column="2">
                    <Label Text="Time" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="0">
                    <Label Text="{Binding KeypairData.Memory}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="1">
                    <Label Text="{Binding KeypairData.CPU}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="2">
                    <Label Text="{Binding KeypairData.Time}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
            </Grid>
            
            <GraphicsView Margin="10,30,10,0" x:Name="KeypairCanvas" HorizontalOptions="Center" Drawable="{StaticResource KeypairGraph}" HeightRequest="200"/>

            <!--Signing-->
            <Label Text="Signing" VerticalOptions="Center" HorizontalOptions="Center" />
            <Grid ColumnSpacing="-3" RowSpacing="-4" Margin="10,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Border Grid.Row="0" Grid.Column="0">
                    <Label Text="Memory" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="0" Grid.Column="1">
                    <Label Text="CPU" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="0" Grid.Column="2">
                    <Label Text="Time" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="0">
                    <Label Text="{Binding SignData.Memory}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="1">
                    <Label Text="{Binding SignData.CPU}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
                <Border Grid.Row="1" Grid.Column="2">
                    <Label Text="{Binding SignData.Time}" VerticalOptions="Center" HorizontalOptions="Center" />
                </Border>
            </Grid>
            <GraphicsView Margin="10,30,10,30" x:Name="SignCanvas" HorizontalOptions="Center" Drawable="{StaticResource SignGraph}" HeightRequest="200"/>

        </VerticalStackLayout>
    </ScrollView>
</ContentPage>