<!--
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.EditNote"
        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="Edit Note"
        SizeToContent="WidthAndHeight" ResizeMode="NoResize"
        ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
        Loaded="Window_Loaded"
        Closing="Window_Closing">

    <Window.Resources>
        <RoutedUICommand x:Key="CloseCmd">
            <RoutedUICommand.InputGestures>
                <KeyGesture>Ctrl+Enter</KeyGesture>
            </RoutedUICommand.InputGestures>
        </RoutedUICommand>
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="{StaticResource CloseCmd}" Executed="CloseCmd_Executed"/>
    </Window.CommandBindings>

    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Text="Enter note:"/>

        <TextBox Name="inputTextBox" Grid.Row="1" Width="551" Height="120"
                 Text="{Binding UserInput, UpdateSourceTrigger=PropertyChanged,
                     FallbackValue=01234567890123456789012345678901234567890123456789012345678901234567890123456789}"
                 FontFamily="{StaticResource GeneralMonoFont}"
                 VerticalScrollBarVisibility="Auto"
                 AcceptsReturn="True" TextWrapping="Wrap"/>

        <GroupBox Grid.Row="2" Header="Select Highlight Color" Width="270" HorizontalAlignment="Left">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="8"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <RadioButton Name="colorDefaultRadio" Grid.Column="0" Grid.Row="0" Margin="0,6,0,0"
                             Content="_None"/>
                <RadioButton Name="colorGreenRadio" Grid.Column="0" Grid.Row="1" Margin="0,6,0,0"
                             Content="_Green" Background="LightGreen"/>
                <RadioButton Name="colorBlueRadio" Grid.Column="0" Grid.Row="2" Margin="0,6,0,0"
                             Content="_Blue" Background="LightBlue"/>
                <RadioButton Name="colorYellowRadio" Grid.Column="1" Grid.Row="0" Margin="0,6,0,0"
                             Content="_Yellow" Background="Yellow"/>
                <RadioButton Name="colorPinkRadio" Grid.Column="1" Grid.Row="1" Margin="0,6,0,0"
                             Content="_Pink" Background="LightPink"/>
                <RadioButton Name="colorOrangeRadio" Grid.Column="1" Grid.Row="2" Margin="0,6,0,0"
                             Content="_Orange" Background="Orange"/>
                <RadioButton Name="colorCustomRadio" Grid.Column="3" Grid.Row="0" Margin="0,6,0,0"
                             Content="_Custom" IsChecked="{Binding IsCustomChecked}"/>
                <TextBox Name="customColorBox" Grid.Column="3" Grid.Row="1" MaxLength="12" Width="100" Margin="18,2,0,0">
                    <TextBox.Text>
                        <Binding Path="CustomColorStr" UpdateSourceTrigger="PropertyChanged" FallbackValue="#008800">
                            <Binding.ValidationRules>
                                <local:ColorRule ValidatesOnTargetUpdated="True"/>
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
                <Rectangle Grid.Column="3" Grid.Row="2" Fill="{Binding CustomColorBrush}" Margin="18,4,0,0"/>
            </Grid>
        </GroupBox>

        <StackPanel Grid.Row="2" Orientation="Horizontal"
                    HorizontalAlignment="Right" VerticalAlignment="Bottom">
            <Button Content="OK" IsDefault="True" Width="70" Click="OkButton_Click"/>
            <Button Content="Cancel" IsCancel="True" Width="70" Margin="4,0,0,0"/>
        </StackPanel>
    </Grid>
</Window>
