<!--
Copyright 2020 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.Tools.Omf.WpfGui.OmfViewer"
        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:local="clr-namespace:SourceGen.Tools.Omf.WpfGui"
        mc:Ignorable="d"
        Title="OMF File Viewer"
        SizeToContent="Height" Width="600" ResizeMode="NoResize"
        ShowInTaskbar="False" WindowStartupLocation="CenterOwner">

    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVis"/>
    </Window.Resources>

    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        
        <DockPanel Grid.Row="0">
            <TextBlock DockPanel.Dock="Left" Text="File:" Margin="0,1,0,0"/>
            <TextBox DockPanel.Dock="Left" IsReadOnly="True" Margin="8,0,0,0" Text="C:\\File\Name\Here"/>
        </DockPanel>

        <TextBlock Grid.Row="1" Text="File is a {something}, with {N} segments" Margin="0,8,0,0"/>

        <DataGrid Name="segmentList" Grid.Row="2" Height="200" Margin="0,8,0,0"
                  IsReadOnly="True"
                  ItemsSource="{Binding SegmentListItems}"
                  FontFamily="{StaticResource GeneralMonoFont}"
                  SnapsToDevicePixels="True"
                  GridLinesVisibility="Vertical"
                  VerticalGridLinesBrush="#FF7F7F7F"
                  AutoGenerateColumns="False"
                  HeadersVisibility="Column"
                  CanUserReorderColumns="False"
                  SelectionMode="Single"
                  MouseDoubleClick="SegmentList_MouseDoubleClick">
            <DataGrid.Resources>
                <!-- make the no-focus color the same as the in-focus color -->
                <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}"
                                     Color="{x:Static SystemColors.HighlightColor}"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}"
                                     Color="{x:Static SystemColors.HighlightTextColor}"/>
            </DataGrid.Resources>
            <DataGrid.Columns>
                <DataGridTextColumn Header="Num" Width="50" Binding="{Binding SegNum}"/>
                <DataGridTextColumn Header="Type" Width="72" Binding="{Binding Value}"/>
                <DataGridTextColumn Header="LoadName" Width="100" Binding="{Binding Type}"/>
                <DataGridTextColumn Header="SegName" Width="100" Binding="{Binding Width}"/>
                <DataGridTextColumn Header="File Size" Width="100" Binding="{Binding Comment}"/>
                <DataGridTextColumn Header="Mem Size Size" Width="100" Binding="{Binding Comment}"/>
            </DataGrid.Columns>
        </DataGrid>

        <TextBlock Grid.Row="3" Text="File notes:" Margin="0,8,0,0"/>
        <TextBox Grid.Row="4" Margin="0,4,0,0" Height="50"
                 Text="Test&#x0d;stuff1&#x0d;stuff2&#x0d;stuff3"
                 IsReadOnly="True" VerticalScrollBarVisibility="Auto">
        </TextBox>

        <DockPanel Grid.Row="5" LastChildFill="False" Margin="0,16,0,0">
            <Button DockPanel.Dock="Left" Content="Convert to SourceGen Project" Padding="4,0"/>
            <Button DockPanel.Dock="Right" Content="Cancel" Width="70" IsCancel="True"/>
        </DockPanel>
    </Grid>
</Window>
