<Window x:Class="FasdDesktopUi.Pages.TicketCompletion.TicketCompletion"
        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:FasdDesktopUi.Pages.CustomMessageBox"
        xmlns:uc="clr-namespace:FasdDesktopUi.Basics.UserControls"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
        xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
        mc:Ignorable="d"
        x:Name="TicketCompletionView"
        AllowsTransparency="True"
        WindowStyle="None"
        ResizeMode="NoResize"
        SizeToContent="Height"
        MaxWidth="475"
        Background="Transparent"
        WindowStartupLocation="CenterOwner"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        KeyDown="CustomMessageBox_KeyDown"
        IsVisibleChanged="BlurInvoker_IsActiveChanged">

    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="40" />
    </WindowChrome.WindowChrome>

    <Window.Resources>
        <BlurEffect x:Key="BlurEffecStyle"
                    Radius="4"
                    KernelType="Gaussian" />
        <Style x:Key="BlurablePanel"
               TargetType="Panel">
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=TicketCompletionView, Path=WaitForClosing}"
                             Value="True">
                    <Setter Property="Effect"
                            Value="{StaticResource BlurEffecStyle}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
        <vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
        <vc:BoolOrToVisibilityConverter x:Key="BoolOrToVisibilityConverter" />
        <vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
    </Window.Resources>

    <Border Background="{DynamicResource BackgroundColor.Menu.Categories}"
            CornerRadius="7.5"
            Padding="10">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Canvas Grid.RowSpan="999"
                    Panel.ZIndex="5"
                    Margin="-10 -10">
                <Border x:Name="FocusBorder"
                        Background="{DynamicResource Color.BlurBorder}"
                        Grid.RowSpan="999"
                        Opacity="0.4"
                        Visibility="Collapsed"
                        Panel.ZIndex="-1"
                        Width="{Binding ElementName=TicketCompletionView, Path=ActualWidth}"
                        Height="{Binding ElementName=TicketCompletionView, Path=ActualHeight}" />
                <Decorator x:Name="FocusDecorator" />

            </Canvas>

            <DockPanel Grid.Row="0"
                       Margin="0 0 0 10"
                       Style="{StaticResource BlurablePanel}">
                <ico:AdaptableIcon DockPanel.Dock="Right"
                                   HorizontalAlignment="Right"
                                   Style="{DynamicResource SettingsPage.Close.Icon}"
                                   MouseLeftButtonUp="CloseButton_Click"
                                   TouchDown="CloseButton_Click"
                                   SelectedInternIcon="window_close" />

                <ico:AdaptableIcon x:Name="StatusIcon"
                                   DockPanel.Dock="Left"
                                   SecondaryIconColor="{DynamicResource Color.AppBackground}"
                                   HorizontalAlignment="Right"
                                   BorderPadding="0 7.5 7.5 7.5"
                                   SelectedInternIcon="misc_ticket">
                </ico:AdaptableIcon>

                <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Dialog.CloseCase.Title}"
                           TextTrimming="CharacterEllipsis"
                           FontSize="18"
                           VerticalAlignment="Center"
                           FontFamily="Calibri"
                           FontWeight="Bold"
                           Foreground="{DynamicResource FontColor.SlimPage.WidgetCollection.Header}" />
            </DockPanel>

            <StackPanel Grid.Row="1"
                        Style="{StaticResource BlurablePanel}">

                <uc:CloseCaseDialogWithTicket x:Name="CloseCaseDialogUc" />

            </StackPanel>

            <Border x:Name="BlurOverlayBoarder"
                    x:FieldModifier="private"
                    Grid.RowSpan="2"
                    Background="{DynamicResource Color.BlurBorder}"
                    CornerRadius="7.5"
                    Opacity="0.4"
                    Visibility="{Binding ElementName=TicketCompletionView, Path=WaitForClosing, Converter={StaticResource BoolToVisibility}}" />

            <Grid x:Name="GridPanel"
                  Grid.Row="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Border Grid.Row="2"
                        Grid.Column="0"
                        Margin="40 10 0 0"
                        Padding="10 0 10 0"
                        HorizontalAlignment="Right"
                        Height="Auto">
                    <Border.Style>
                        <Style TargetType="Border">
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver"
                                         Value="True">
                                    <Setter Property="Background"
                                            Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
                                    <Setter Property="CornerRadius"
                                            Value="5" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                    <TextBlock x:Name="SafeText"
                               Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Dialog.CloseCase.Save}"
                               Grid.Column="0"
                               Padding="10 10 10 10"
                               FontWeight="Bold"
                               Cursor="Hand"
                               MouseLeftButtonUp="SafeText_Click"
                               TouchDown="SafeText_Click">
                        <TextBlock.Style>
                            <Style TargetType="TextBlock">
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver"
                                             Value="True">
                                        <Setter Property="Foreground"
                                                Value="{DynamicResource Color.Green}" />
                                    </Trigger>
                                    <Trigger Property="IsMouseOver"
                                             Value="False">
                                        <Setter Property="Foreground"
                                                Value="{DynamicResource FontColor.Menu.Categories}" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                </Border>

                <Border Grid.Row="2"
                        Grid.Column="1"
                        Margin="170 10 0 0"
                        Padding="10 0 10 0"
                        HorizontalAlignment="Right"
                        Height="Auto">
                    <Border.Style>
                        <Style TargetType="Border">
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver"
                                         Value="True">
                                    <Setter Property="Background"
                                            Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
                                    <Setter Property="CornerRadius"
                                            Value="5" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                    <TextBlock x:Name="AbortText"
                               Grid.Column="1"
                               Padding="10 10 10 10"
                               Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Dialog.CloseCase.Abort}"
                               FontWeight="Bold"
                               Cursor="Hand"
                               MouseLeftButtonUp="AbortText_Click"
                               TouchDown="AbortText_Click">
                        <TextBlock.Style>
                            <Style TargetType="TextBlock">
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver"
                                             Value="True">
                                        <Setter Property="Foreground"
                                                Value="{DynamicResource Color.Red}" />

                                    </Trigger>
                                    <Trigger Property="IsMouseOver"
                                             Value="False">
                                        <Setter Property="Foreground"
                                                Value="{DynamicResource FontColor.Menu.Categories}" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                </Border>

                <ico:AdaptableIcon Grid.ColumnSpan="999"
                                   BorderPadding="0"
                                   VerticalAlignment="Center"
                                   HorizontalAlignment="Center"
                                   IconHeight="20"
                                   IconWidth="20"
                                   SelectedInternGif="loadingSpinner"
                                   Margin="50 10 0 0"
                                   Visibility="{Binding Path=IsClosingBusy, Converter={StaticResource BoolToVisibility}}" />
            </Grid>
        </Grid>
    </Border>
</Window>

