<Window x:Class="OpenGptChat.AppWindow"
        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:OpenGptChat"
        xmlns:controls="clr-namespace:OpenGptChat.Controls"
        xmlns:tb="http://www.hardcodet.net/taskbar"
        xmlns:utils="clr-namespace:OpenGptChat.Utilities"
        xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:mybehaviors="clr-namespace:OpenGptChat.Behaviors"
        xmlns:hotkey="https://wpf.elecho.org/globalhotkey"
        d:DataContext="{d:DesignInstance Type=local:AppWindow}"
        mc:Ignorable="d" Icon="assets/images/openai.png" 
        Title="{Binding ViewModel.ApplicationTitle}"  FontSize="{DynamicResource NormalFontSize}"
        Height="600" Width="880" 
        Foreground="{DynamicResource FontForeground}" Background="{DynamicResource GeneralBackground}"
        Topmost="{Binding ViewModel.Configuration.WindowAlwaysOnTop}">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="bool2visbility"/>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Modifiers="Ctrl" Key="H" Command="{x:Static local:App.HideAppCommand}"/>
        <KeyBinding Modifiers="Ctrl+Shift" Key="H" Command="{x:Static local:App.ShowAppCommand}"
                    hotkey:GlobalHotkey.IsRegistered="True"/>
    </Window.InputBindings>
    <behaviors:Interaction.Behaviors>
        <mybehaviors:WindowStyleManagerBehavior/>
    </behaviors:Interaction.Behaviors>

    <Grid>
        <Frame Name="appFrame" NavigationUIVisibility="Hidden"/>

        <controls:NoteControl x:Name="appNote"
                              Text="{Binding NoteService.Data.Text}" Show="{Binding NoteService.Data.Show}" Background="{DynamicResource BoxBackground}"
                              VerticalAlignment="Top" HorizontalAlignment="Center" Margin="50 0" BorderThickness="1 0 1 1" Visibility="Hidden">

            <behaviors:Interaction.Triggers>
                <behaviors:EventTrigger EventName="MouseDown">
                    <behaviors:CallMethodAction TargetObject="{Binding NoteService}" MethodName="Close"/>
                </behaviors:EventTrigger>
            </behaviors:Interaction.Triggers>

            <controls:NoteControl.Style>
                <Style TargetType="controls:NoteControl">
                    <Setter Property="BorderBrush" Value="{DynamicResource BoxBorder}"/>
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="BorderBrush" Value="IndianRed"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </controls:NoteControl.Style>

        </controls:NoteControl>

        <tb:TaskbarIcon Name="appIcon"
                        IconSource="assets/images/openai.ico"
                        ToolTipText="{x:Null}"
                        LeftClickCommand="{x:Static local:App.ShowAppCommand}"
                        DoubleClickCommand="{x:Static local:App.ShowAppCommand}"
                        DataContext="{Binding}">

            <tb:TaskbarIcon.ContextMenu>
                <ContextMenu utils:UiUtils.CornerRadius="3">
                    <MenuItem Header="Show" Command="{x:Static local:App.ShowAppCommand}"/>
                    <MenuItem Header="Hide" Command="{x:Static local:App.HideAppCommand}"/>
                    <MenuItem Header="Close" Command="{x:Static local:App.CloseAppCommand}"/>
                </ContextMenu>
            </tb:TaskbarIcon.ContextMenu>

        </tb:TaskbarIcon>
    </Grid>
</Window>