<UserControl x:Class="FasdDesktopUi.Basics.UserControls.Notepad"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:FasdDesktopUi.Basics.UserControls"
             xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
             xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
             mc:Ignorable="d"
             d:DesignHeight="450"
             d:DesignWidth="800"
             d:Background="White"
             MinHeight="225"
             MinWidth="255"
             x:Name="NotepadUc">
    
    <UserControl.Resources>
        <Style TargetType="ico:AdaptableIcon"
               BasedOn="{StaticResource Menu.MenuBar.PinnedIcon }">
            <Setter Property="CommandTarget"
                    Value="{Binding ElementName=NotepadRichTextBox}" />
            <Setter Property="FocusManager.FocusedElement"
                    Value="{Binding ElementName=NotepadRichTextBox}" />
        </Style>
        <vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
    </UserControl.Resources>

    <Border Padding="10"
            CornerRadius="10"
            Background="{DynamicResource BackgroundColor.Menu.Categories}">

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition x:Name="TopRow"
                               Height="Auto" />
                <RowDefinition x:Name="BottomRow"
                               Height="*" />
            </Grid.RowDefinitions>

            <DockPanel>

                <!--<DockPanel.Resources>
                    <Style TargetType="ico:AdaptableIcon">
                        <Setter Property="IconWidth"
                                Value="20" />
                        <Setter Property="IconHeight"
                                Value="20" />
                        <Setter Property="BorderPadding"
                                Value="5" />
                        <Setter Property="IconBackgroundColor"
                                Value="Transparent" />
                        <Setter Property="Margin"
                                Value="0, 0, 10, 0" />
                        <Setter Property="PrimaryIconColor"
                                Value="{DynamicResource Color.Menu.Icon}" />
                        <Setter Property="Cursor"
                                Value="Hand" />
                        <Setter Property="WindowChrome.IsHitTestVisibleInChrome"
                                Value="True" />
                        <Style.Triggers>
                            <Trigger Property="IsMouseOver"
                                     Value="True">
                                <Setter Property="PrimaryIconColor"
                                        Value="{DynamicResource Color.Menu.Icon.Hover}" />
                                <Setter Property="IconBackgroundColor"
                                        Value="{DynamicResource Background.Menu.Icon.Hover}" />
                            </Trigger>
                        </Style.Triggers>

                    </Style>
                </DockPanel.Resources>-->

                <ico:AdaptableIcon  x:Name="CloseNotepadIcon" x:FieldModifier="private"
                                    DockPanel.Dock="Right"
                                    SelectedInternIcon="window_minimize"
                                    Style="{DynamicResource SettingsPage.Close.Icon}"
                                    WindowChrome.IsHitTestVisibleInChrome ="True"
                                    Margin="0 8 0 0"
                                    Tag="close" MouseUp="CloseNotepadIcon_MouseUp" TouchDown="CloseNotepadIcon_TouchDown"/>

                <ico:AdaptableIcon  x:Name="LockNotepadIcon" x:FieldModifier="private"
                                    DockPanel.Dock="Right"
                                    Style="{DynamicResource Menu.Notepad.Icon.Lock}"
                                    MouseLeave="LockNotepadIcon_MouseLeave"
                                    WindowChrome.IsHitTestVisibleInChrome ="True"
                                    Tag="lock" MouseUp="LockNotepadIcon_MouseUp" TouchDown="LockNotepadIcon_TouchDown"/>

                <ico:AdaptableIcon  DockPanel.Dock="Left"
                                    VerticalAlignment="Center"
                                    SelectedMaterialIcon="ic_edit"
                                    PrimaryIconColor="{DynamicResource Color.FunctionMarker}"
                                    BorderPadding="0"
                                    IconHeight="15"
                                    IconWidth="15"
                                    Style="{x:Null}">
                    
                </ico:AdaptableIcon>

                <TextBlock      DockPanel.Dock="Left"
                                Style="{DynamicResource DetailsPage.DataHistory.TitleColumn.OverviewTitle}"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Left"
                                Margin="10" 
                                Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Notepad.Heading.Notes}">
                    
                </TextBlock>

            </DockPanel>

            <DockPanel Grid.Row="2">

                <Border  DockPanel.Dock="Top"
                        Margin="0 0 0 10"
                        Background="{DynamicResource BackgroundColor.DetailsPage.Widget.Title}"
                        Padding="5"
                        CornerRadius="7.5">
                    <DockPanel>

                        <ico:AdaptableIcon x:Name="ToggleDockButton" x:FieldModifier="private"
                                           DockPanel.Dock="Right"
                                           SelectedMaterialIcon="ic_zoom_out_map"
                                           MouseLeftButtonUp="ToggleDockButton_MouseLeftButtonUp"
                                           TouchDown="ToggleDockButton_TouchDown" />

                        <StackPanel Orientation="Horizontal">
                            <ico:AdaptableIcon x:Name="UndoIcon" x:FieldModifier="private"
                                               SelectedMaterialIcon="ic_undo"
                                               Command="ApplicationCommands.Undo" 
                                               Style="{DynamicResource Menu.MenuBar.PinnedIcon.Disabled}"/>
                            <ico:AdaptableIcon x:Name="RedoIcon" x:FieldModifier="private"
                                               SelectedMaterialIcon="ic_redo"
                                               Command="ApplicationCommands.Redo"
                                               Style="{DynamicResource Menu.MenuBar.PinnedIcon.Disabled}"/>
                            <ico:AdaptableIcon x:Name="CopyIcon"
                                               SelectedInternIcon="menuBar_copy"
                                               TouchDown="CopyIcon_TouchDown"
                                               MouseLeftButtonUp="CopyIcon_MouseLeftButtonUp" />
                            <ico:AdaptableIcon x:Name="BoldIcon" x:FieldModifier="private"
                                               SelectedMaterialIcon="ic_format_bold"
                                               Command="EditingCommands.ToggleBold"
                                               MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
                            <ico:AdaptableIcon x:Name="ItalicIcon" x:FieldModifier="private"
                                               SelectedMaterialIcon="ic_format_italic"
                                               Command="EditingCommands.ToggleItalic"
                                               MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
                            <ico:AdaptableIcon x:Name="UnderlineIcon" x:FieldModifier="private"
                                               SelectedMaterialIcon="ic_format_underlined"
                                               Command="EditingCommands.ToggleUnderline"
                                               MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
                            <ico:AdaptableIcon x:Name="BulletsIcon" x:FieldModifier="private"
                                               SelectedMaterialIcon="ic_format_list_bulleted"
                                               Command="EditingCommands.ToggleBullets"
                                               MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
                            <ico:AdaptableIcon x:Name="NumberingIcon" x:FieldModifier="private"
                                               SelectedMaterialIcon="ic_format_list_numbered"
                                               Command="EditingCommands.ToggleNumbering"
                                               MouseLeftButtonUp="TextBoxIcon_MouseLeftButtonUp" />
                        </StackPanel>

                    </DockPanel>
                </Border>

                <ScrollViewer    VerticalScrollBarVisibility="Auto">
                    <RichTextBox x:Name="NotepadRichTextBox" x:FieldModifier="private"
                                 VerticalAlignment="Stretch"
                                 Padding="2.5 5"
                                 TextChanged="NotepadRichTextBox_TextChanged"
                                 Foreground="{DynamicResource FontColor.DetailsPage.Widget}"
                                 Background="{DynamicResource BackgroundColor.DetailsPage.Widget.Title}"
                                 SelectionChanged="NotepadRichTextBox_SelectionChanged"
                                 IsVisibleChanged="NotepadRichTextBox_IsVisibleChanged"
                                 GotKeyboardFocus="NotepadRichTextBox_GotKeyboardFocus">
                        <RichTextBox.Resources>
                            <Style TargetType="Border">
                                <Setter Property="CornerRadius"
                                        Value="7.5" />
                            </Style>
                        </RichTextBox.Resources>
                    </RichTextBox>
                </ScrollViewer>

            </DockPanel>
        </Grid>
    </Border>
</UserControl>
