<!--
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.WpfGui.EditDataBank"
        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.WpfGui"
        xmlns:system="clr-namespace:System;assembly=mscorlib"
        mc:Ignorable="d"
        Title="Edit Data Bank Register"
        SizeToContent="WidthAndHeight" ResizeMode="NoResize"
        ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
        ContentRendered="Window_ContentRendered">

    <Window.Resources>
        <system:String x:Key="str_OtherBank">(other)</system:String>
    </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>

        <StackPanel Grid.Row="0" Orientation="Horizontal">
            <TextBlock Text="Data bank:"/>
            <TextBox Name="bankValueBox" Margin="8,1,0,0" Width="30" MaxLength="3"
                     Text="{Binding DataBankStr, UpdateSourceTrigger=PropertyChanged, FallbackValue=$00}"
                     FontFamily="{StaticResource GeneralMonoFont}"/>
        </StackPanel>
        <TextBlock Grid.Row="1" Margin="0,4,0,0" Text="• Enter two-digit hex value, or 'K' to track PBR"/>
        <TextBlock Grid.Row="2" Margin="0,0,0,0" Text="• Leave blank to reset to default"/>

        <TextBlock Grid.Row="3" Text="Alternatively, select from list of in-use banks:" Margin="0,16,0,0"/>
        <ComboBox Grid.Row="4" Name="bankCombo" Margin="0,4,0,0"
                  FontFamily="{StaticResource GeneralMonoFont}"
                  ItemsSource="{Binding BankLabels}" DisplayMemberPath="Label"
                  SelectionChanged="bankCombo_SelectionChanged"/>

        <StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,16,0,0">
            <Button Content="OK" IsDefault="True" Width="70"
                    IsEnabled="{Binding IsValid}" Click="OkButton_Click"/>
            <Button Content="Cancel" IsCancel="True" Width="70" Margin="4,0,0,0"/>
        </StackPanel>
    </Grid>
</Window>
