<!--
Copyright 2019 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.Export"
        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"
        mc:Ignorable="d"
        Title="Export Source"
        SizeToContent="WidthAndHeight" ResizeMode="NoResize"
        ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
        Loaded="Window_Loaded">
    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <GroupBox Grid.Row="0" Header="General Options" Padding="2,4">
            <StackPanel>
                <CheckBox Content="Include only selected lines" IsChecked="{Binding SelectionOnly}"/>
                <CheckBox Content="Include notes" Margin="0,2,0,0" IsChecked="{Binding IncludeNotes}"/>
                <CheckBox Content="Show Offset column" Margin="0,2,0,0" IsChecked="{Binding ShowOffset}"/>
                <CheckBox Content="Show Address column" Margin="0,2,0,0" IsChecked="{Binding ShowAddress}"/>
                <CheckBox Content="Show Bytes column" Margin="0,2,0,0" IsChecked="{Binding ShowBytes}"/>
                <CheckBox Content="Show Flags column" Margin="0,2,0,0" IsChecked="{Binding ShowFlags}"/>
                <CheckBox Content="Show Attributes column" Margin="0,2,0,0" IsChecked="{Binding ShowAttr}"/>

                <TextBlock Text="Column widths (label, opcode, operand, comment):" Margin="0,4,0,0"/>
                <StackPanel Orientation="Horizontal" Margin="0,4,0,0">
                    <TextBox Name="asmLabelColWidthTextBox" Width="60" Margin="0,0,4,0"
                             TextChanged="AsmColWidthTextBox_TextChanged">
                        <TextBox.Text>
                            <Binding Path="AsmLabelColWidth" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <local:AsmColWidthRule ValidatesOnTargetUpdated="True"/>
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox.Text>
                    </TextBox>
                    <TextBox Name="asmOpcodeColWidthTextBox" Width="60" Margin="0,0,4,0"
                             TextChanged="AsmColWidthTextBox_TextChanged">
                        <TextBox.Text>
                            <Binding Path="AsmOpcodeColWidth" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <local:AsmColWidthRule ValidatesOnTargetUpdated="True"/>
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox.Text>
                    </TextBox>
                    <TextBox Name="asmOperandColWidthTextBox" Width="60" Margin="0,0,4,0"
                             TextChanged="AsmColWidthTextBox_TextChanged">
                        <TextBox.Text>
                            <Binding Path="AsmOperandColWidth" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <local:AsmColWidthRule ValidatesOnTargetUpdated="True"/>
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox.Text>
                    </TextBox>
                    <TextBox Name="asmCommentColWidthTextBox" Width="60" Margin="0,0,8,0"
                             TextChanged="AsmColWidthTextBox_TextChanged">
                        <TextBox.Text>
                            <Binding Path="AsmCommentColWidth" UpdateSourceTrigger="PropertyChanged">
                                <Binding.ValidationRules>
                                    <local:AsmColWidthRule ValidatesOnTargetUpdated="True"/>
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox.Text>
                    </TextBox>
                </StackPanel>

                <CheckBox Content="Put long labels on separate line" Margin="0,8,0,0"
                              IsChecked="{Binding LongLabelNewLine}"/>
            </StackPanel>
        </GroupBox>

        <GroupBox Grid.Row="1" Header="Text Options" Padding="2,4">
            <StackPanel>
                <RadioButton Content="Plain text (UTF-8)" GroupName="TextMode" IsChecked="{Binding TextModePlain}"/>
                <RadioButton Content="CSV" GroupName="TextMode" Margin="0,2,0,0" IsChecked="{Binding TextModeCsv}"/>
            </StackPanel>
        </GroupBox>

        <GroupBox Grid.Row="2" Header="HTML Options" Padding="2,4">
            <StackPanel>
                <CheckBox Content="Generate image files" Margin="0,2,0,0" IsChecked="{Binding GenerateImageFiles}"/>
                <CheckBox Content="Overwrite CSS file" Margin="0,2,0,0" IsChecked="{Binding OverwriteCss}"/>
            </StackPanel>
        </GroupBox>

        <Grid Grid.Row="3" Margin="0,8,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Button Grid.Column="0" Content="Generate HTML" Width="100"
                    IsEnabled="{Binding IsValid}" Click="GenerateHtmlButton_Click"/>
            <Button Grid.Column="1" Content="Generate Text" Width="100" Margin="8,0,0,0"
                    IsEnabled="{Binding IsValid}" Click="GenerateTextButton_Click"/>
            <Button Grid.Column="2" Content="Cancel" IsCancel="True" Width="70" Margin="8,0,0,0"
                    HorizontalAlignment="Right"/>
        </Grid>
    </Grid>
</Window>
