<Window x:Class="CefFlashBrowser.Views.Dialogs.AddFavoriteDialog"
        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:CefFlashBrowser.Views.Dialogs"
        xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:hc="https://handyorg.github.io/handycontrol"
        xmlns:behaviors="clr-namespace:CefFlashBrowser.Views.Behaviors"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:utils="clr-namespace:CefFlashBrowser.Utils"
        xmlns:vm="clr-namespace:CefFlashBrowser.ViewModels"
        mc:Ignorable="d"
        
        Width="350"
        SizeToContent="Height"
        ResizeMode="NoResize"
        WindowStartupLocation="CenterOwner"
        Title="{DynamicResource dialog_addFavorite}"
        utils:DialogHelper.DialogResult="{Binding DialogResult, Mode=OneWay}">

    <d:Window.DataContext>
        <vm:AddFavoriteDialogViewModel/>
    </d:Window.DataContext>

    <Window.InputBindings>
        <KeyBinding Gesture="Ctrl+W"
                    Command="{Binding ElementName=windowBehavior, Path=CloseWindowCommand}"/>
        <KeyBinding Gesture="Esc"
                    Command="{Binding CancelCommand}"/>
        <KeyBinding Gesture="Enter"
                    Command="{Binding ConfirmCommand}"/>
    </Window.InputBindings>

    <i:Interaction.Behaviors>
        <behaviors:WindowBehavior x:Name="windowBehavior"/>
    </i:Interaction.Behaviors>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <StackPanel Margin="15">
                <hc:TextBox x:Name="nameTextBox"
                            hc:TitleElement.Title="{DynamicResource favorites_name}"
                            Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}">
                    <i:Interaction.Behaviors>
                        <behaviors:TextBoxSelectAllOnFocus/>
                    </i:Interaction.Behaviors>
                </hc:TextBox>
                <hc:TextBox Margin="0,5,0,0"
                            hc:TitleElement.Title="{DynamicResource favorites_url}"
                            Text="{Binding Url, UpdateSourceTrigger=PropertyChanged}">
                    <i:Interaction.Behaviors>
                        <behaviors:TextBoxSelectAllOnFocus/>
                    </i:Interaction.Behaviors>
                </hc:TextBox>
            </StackPanel>
        </Grid>

        <Grid Grid.Row="1">
            <StackPanel Margin="0,0,15,15"
                        Orientation="Horizontal"
                        HorizontalAlignment="Right">
                <Button MinWidth="70"
                        Content="{DynamicResource dialog_cancel}"
                        Command="{Binding CancelCommand}"/>
                <Button MinWidth="70"
                        Margin="10,0,0,0"
                        Content="{DynamicResource dialog_ok}"
                        Style="{StaticResource ButtonPrimary}"
                        Command="{Binding ConfirmCommand}"/>
            </StackPanel>
        </Grid>
    </Grid>
</Window>
