<!--
Copyright 2025 faddenSoft

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<Window x:Class="SourceGen.WpfGui.ReferenceTable"
        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:system="clr-namespace:System;assembly=mscorlib"
        xmlns:local="clr-namespace:SourceGen.WpfGui"
        mc:Ignorable="d"
        Title="Reference List"
        Width="400" Height="300" MinWidth="180" MinHeight="120" ResizeMode="CanResizeWithGrip"
        ShowInTaskbar="True"
        PreviewKeyDown="Window_KeyEventHandler" Closing="Window_Closing">

    <Window.Resources>
        <system:String x:Key="str_EntryCountSingleFmt">{0} entry</system:String>
        <system:String x:Key="str_EntryCountPluralFmt">{0} entries</system:String>
    </Window.Resources>

    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <DataGrid Name="tableDataGrid" IsReadOnly="True"
                ItemsSource="{Binding ReferencesList}"
                FontFamily="{StaticResource GeneralMonoFont}"
                SnapsToDevicePixels="True"
                GridLinesVisibility="Vertical"
                VerticalGridLinesBrush="#FF7F7F7F"
                AutoGenerateColumns="False"
                HeadersVisibility="Column"
                CanUserReorderColumns="False"
                SelectionMode="Single"
                MouseDoubleClick="ReferencesList_MouseDoubleClick">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Offset" Width="53" Binding="{Binding Offset}"/>
                <DataGridTextColumn Header="Addr" Width="53" Binding="{Binding Addr}"/>
                <DataGridTextColumn Header="Text" Width="*" Binding="{Binding Text}"/>
            </DataGrid.Columns>
        </DataGrid>

        <StackPanel Grid.Row="1" Margin="0,5,0,0" Orientation="Horizontal">
            <!-- Bind the checkbox directly to the window's Topmost property. -->
            <CheckBox Content="Always on top" IsChecked="{Binding Path=Topmost}"/>
            <StackPanel Orientation="Horizontal" Margin="20,0,0,0">
                <TextBlock Text="{Binding CountText, FallbackValue=MM entries}"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</Window>
