<p:CustomPopupBase x:Class="FasdDesktopUi.Pages.CustomMessageBox.CustomMessageBox"
        xmlns:p="clr-namespace:FasdDesktopUi.Pages"
        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="CustomMessageBoxView"
        AllowsTransparency="True"
        WindowStyle="None"
        ResizeMode="NoResize"
        SizeToContent="Height"
        MaxWidth="475"
        Background="Transparent"
        WindowStartupLocation="CenterOwner"
        DataContext="{Binding RelativeSource={RelativeSource Self}}"
        PreviewKeyDown="CustomMessageBox_PreviewKeyDown"
        IsVisibleChanged="BlurInvoker_IsActiveChanged"
        >

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

    <p:CustomPopupBase.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
        <vc:NullValueToVisibilityConverter x:Key="NullToVisibility" />
        <vc:BoolOrToVisibilityConverter x:Key="BoolOrToVisibilityConverter" />
    </p:CustomPopupBase.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=CustomMessageBoxView, Path=ActualWidth}"
                        Height="{Binding ElementName=CustomMessageBoxView, Path=ActualHeight}" />
                <Decorator x:Name="FocusDecorator" />

            </Canvas>

            <DockPanel Grid.Row="0"
                       Margin="0 0 0 10"
                       >
                <ico:AdaptableIcon DockPanel.Dock="Right"
                                   HorizontalAlignment="Right"
                                   Style="{DynamicResource SettingsPage.Close.Icon}"
                                   MouseLeftButtonUp="Close_MouseLeftButtonUp"
                                   TouchDown="Close_TouchDown"
                                   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"
                                   Visibility="Collapsed">
                </ico:AdaptableIcon>

                <TextBlock Text="{Binding Caption}"
                           TextTrimming="CharacterEllipsis"
                           FontSize="18"
                           VerticalAlignment="Center"
                           FontFamily="Calibri"
                           FontWeight="Bold"
                           Foreground="{DynamicResource FontColor.SlimPage.WidgetCollection.Header}"
                           Visibility="{Binding Caption, Converter={StaticResource NullToVisibility}}"/>
            </DockPanel>

            <Border Grid.Row="1" Background="{DynamicResource BackgroundColor.Menu.MainCategory}"
                        CornerRadius="7.5"
                        Padding="10"
                        Visibility="{Binding Message, Converter={StaticResource NullToVisibility}}">
                <TextBlock Text="{Binding Message}"
                               FontSize="16"
                               TextWrapping="Wrap"
                               Visibility="{Binding Message, Converter={StaticResource NullToVisibility}}"
                               Style="{DynamicResource SlimPage.Widget.Title}" />
            </Border>

            <uc:YesNoButton x:Name="YesNoButtonControl" x:FieldModifier="private"
                            Grid.Row="2"
                            HasYesNoButtons="{Binding ElementName=CustomMessageBoxView, Path=HasYesNoButtons}"
                            HasYesNoText="{Binding ElementName=CustomMessageBoxView, Path=HasYesNoText}"
                            ButtonHasBeenClicked="YesNoButton_ButtonHasBeenClicked"
                            >
                <uc:YesNoButton.Visibility>
                    <MultiBinding Converter="{StaticResource BoolOrToVisibilityConverter}">
                        <Binding Path="HasYesNoButtons" ElementName="CustomMessageBoxView"/>
                        <Binding Path="HasYesNoText" ElementName="CustomMessageBoxView"/>
                    </MultiBinding>
                </uc:YesNoButton.Visibility>
            </uc:YesNoButton>
            <uc:MultiButton HorizontalAlignment="Center"
                x:Name="MultiButtons"
                Grid.Row="2"
                Visibility="Collapsed" ResultChanged="MultiButtons_ResultChanged"
                Margin="0,10,0,0"
                >
            </uc:MultiButton>
        </Grid>
    </Border>
</p:CustomPopupBase>
