<Page
    x:Class="PCUT.Pages.DesignCenterPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PCUT.Pages"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Background>
        <SolidColorBrush Color="White" />
    </Page.Background>

    <Page.Transitions>
        <TransitionCollection>
            <EntranceThemeTransition />
        </TransitionCollection>
    </Page.Transitions>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.22*"/>
            <RowDefinition Height="0.78*"/>
        </Grid.RowDefinitions>

        <!-- Column Definitions for the first row -->
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.6*"/>
            <ColumnDefinition Width="0.4*"/>
        </Grid.ColumnDefinitions>

        <!-- Left side content with 3 rows and 2 columns for details -->
        <Grid Grid.Row="0" Grid.Column="0" Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!-- Detail a -->
            <TextBlock Text="Name" Grid.Row="0" Grid.Column="0" Margin="5" VerticalAlignment="Center"/>
            <TextBox Text="{Binding Name, Mode=OneWay}" Grid.Row="0" Grid.Column="1" Margin="5" BorderThickness="0" IsReadOnly="True"/>

            <!-- Detail b -->
            <TextBlock Text="Type" Grid.Row="0" Grid.Column="2" Margin="5" VerticalAlignment="Center"/>
            <TextBox Text="{Binding Type, Mode=OneWay}" Grid.Row="0" Grid.Column="3" Margin="5" BorderThickness="0" IsReadOnly="True"/>

            <!-- Detail c -->
            <TextBlock Text="Brand" Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center"/>
            <TextBox Text="{Binding Brand, Mode=OneWay}" Grid.Row="1" Grid.Column="1" Margin="5" BorderThickness="0" IsReadOnly="True"/>

            <!-- Placeholder for additional detail d -->
            <TextBlock Text="Year" Grid.Row="1" Grid.Column="2" Margin="5" VerticalAlignment="Center"/>
            <TextBox Text="{Binding Year, Mode=OneWay}" Grid.Row="1" Grid.Column="3" Margin="5" BorderThickness="0" IsReadOnly="True"/>

            <!-- Placeholder for additional detail e -->
            <TextBlock Text="Model" Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center"/>
            <TextBox Text="{Binding Model, Mode=OneWay}" Grid.Row="2" Grid.Column="1" Margin="5" BorderThickness="0" IsReadOnly="True"/>

            <!-- Placeholder for additional detail f -->
            <TextBlock Text="Series" Grid.Row="2" Grid.Column="2" Margin="5" VerticalAlignment="Center"/>
            <TextBox Text="{Binding Series, Mode=OneWay}" Grid.Row="2" Grid.Column="3" Margin="5" BorderThickness="0" IsReadOnly="True"/>
        </Grid>

        <!-- Right side content -->

        <Grid Grid.Row="0" Grid.Column="1" Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.525*"/>
                <ColumnDefinition Width="0.325*"/>
                <ColumnDefinition Width="0.15*"/>
            </Grid.ColumnDefinitions>

            <TextBox
                Grid.Row="0" Grid.Column="0"
                x:Name="CuttingMachines"
                PlaceholderText="Cutting Machines"
                HorizontalAlignment="Stretch" VerticalAlignment="Center"
                Margin="5"
                IsReadOnly="True" />
            <ComboBox
                    Grid.Row="0" Grid.Column="1"
                    PlaceholderText="Port"
                    HorizontalAlignment="Stretch" VerticalAlignment="Center"
                    Margin="5"
                    ItemsSource="{Binding Ports, Mode=OneWay}" DisplayMemberPath="PortName"
                    SelectedIndex="{Binding SelectedPortIndex, Mode=TwoWay}"
                    SelectionChanged="ComboBox_SelectionChanged" />

            <StackPanel
                Grid.Row="0" Grid.Column="2"
                Orientation="Horizontal">
                <Button
                    HorizontalAlignment="Left" VerticalAlignment="Center"
                    Margin="3 5 0 5"
                    Background="{ThemeResource SystemAccentColor}"
                    Click="Refresh_Click">
                    <SymbolIcon Symbol="Refresh" />
                </Button>
                <Button
                    HorizontalAlignment="Left" VerticalAlignment="Center"
                    Margin="3 5 5 5"
                    Background="{ThemeResource SystemAccentColor}"
                    Click="SettingPort_Click">
                    <SymbolIcon Symbol="Setting" />
                </Button>

            </StackPanel>

            <Grid
                Grid.Row="1" Grid.Column="0"
                Grid.ColumnSpan="2"
                VerticalAlignment="Center"
                Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.62*" />
                    <ColumnDefinition Width="0.38*" />
                </Grid.ColumnDefinitions>
                <TextBlock
                    x:Name="WidthLabel"
                    Grid.Column="0"
                    Text="Width (mm): "
                    HorizontalAlignment="Right" VerticalAlignment="Center"
                    Margin="5,0,5,0" />
                <TextBox
                    x:Name="WidthInput"
                    Grid.Column="1"
                    Text="{Binding Width, Mode=TwoWay}"
                    InputScope="Number"
                    PlaceholderText="Width"
                    VerticalAlignment="Center"
                    Margin="5,0,0,0"
                    BeforeTextChanging="TextBox_BeforeTextChanging" />
            </Grid>
            <Grid
                Grid.Row="2" Grid.Column="0"
                Grid.ColumnSpan="2"
                VerticalAlignment="Center"
                Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.62*" />
                    <ColumnDefinition Width="0.38*" />
                </Grid.ColumnDefinitions>

                <TextBlock
                    x:Name="HeightLabel"
                    Grid.Row="0" Grid.Column="0"
                    Text="Height (mm): "
                    HorizontalAlignment="Right" VerticalAlignment="Center"
                    Margin="5,0,5,0" />
                <TextBox
                    x:Name="HeightInput"
                    Grid.Row="0" Grid.Column="1"
                    Text="{Binding Height, Mode=TwoWay}"
                    InputScope="Number"
                    PlaceholderText="Height"
                    VerticalAlignment="Center"
                    Margin="5,0,0,0"
                    BeforeTextChanging="TextBox_BeforeTextChanging"/>
                <ComboBox
                    x:Name="HeightSelector"
                    Grid.Row="0" Grid.Column="1"
                    ItemsSource="{Binding PaperSizes, Mode=OneWay}" DisplayMemberPath="Height"
                    SelectedIndex="{Binding SelectedHeightIndex, Mode=TwoWay}"
                    PlaceholderText="Height"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Stretch"
                    Margin="5,0,0,0"/>
            </Grid>


            <TextBlock
                x:Name="RecommendedHeightLabel"
                Grid.Row="3" Grid.Column="0"
                Text="Recommended Minimum Size (mm): "
                HorizontalAlignment="Right" VerticalAlignment="Center"
                Margin="5,5,5,0" />
            <TextBlock
                x:Name="RecommendedHeightValue"
                Grid.Row="3" Grid.Column="1"
                Text="{Binding MinSize, Mode=OneWay}"
                HorizontalAlignment="Left" VerticalAlignment="Center"
                Margin="5,5,5,0" />

            <Button
                Grid.Row="1" Grid.Column="2"
                HorizontalAlignment="Left" VerticalAlignment="Center"
                Margin="3 5 5 5"
                Background="{ThemeResource SystemAccentColor}"
                Click="SortFiles_Button">
                <SymbolIcon Symbol="Sort" />
            </Button>
            <Button
                Grid.Row="2" Grid.Column="2"
                HorizontalAlignment="Left" VerticalAlignment="Center"
                Margin="3 5 5 5"
                Background="{ThemeResource SystemAccentColor}"
                Click="CutFiles_Button">
                <SymbolIcon Symbol="Print" />
            </Button>
        </Grid>

        <!-- Second row content -->
        <!-- Add your content for the second row here -->
        <Frame Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Name="ContentFrame" Margin="10" />
        <StackPanel
            Grid.Row="1" Grid.Column="0"
            Orientation="Horizontal">
            <Button
                x:Name="BackButton"
                HorizontalAlignment="Left" VerticalAlignment="Top"
                Margin="5,0,5,0"
                Background="{ThemeResource SystemAccentColor}"
                Click="Back_Click">
                Back
            </Button>
        </StackPanel>
        <!-- Third row content -->
        <!-- Add your content for the third row here -->

    </Grid>
</Page>
