<detailspagebase:SupportCasePageBase xmlns:detailspagebase="clr-namespace:FasdDesktopUi.Pages"
                                     x:Class="FasdDesktopUi.Pages.DetailsPage.DetailsPageView"
                                     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.DetailsPage"
                                     xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
                                     xmlns:uc="clr-namespace:FasdDesktopUi.Pages.DetailsPage.UserControls"
                                     xmlns:buc="clr-namespace:FasdDesktopUi.Basics.UserControls"
                                     xmlns:quc="clr-namespace:FasdDesktopUi.Basics.UserControls.QuickTip"
                                     xmlns:vm="clr-namespace:FasdDesktopUi.Pages.DetailsPage.ViewModels"
                                     xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
                                     mc:Ignorable="d"
                                     Title="First Aid Service Desk"
                                     x:Name="DetailsPage"
                                     Height="1024"
                                     Width="680"
                                     MinHeight="1024"
                                     MinWidth="680"
                                     Background="{DynamicResource Color.AppBackground}"
                                     Initialized="DetailsPage_Initialized"
                                     Closing="Window_Closing"
                                     IsVisibleChanged="Window_IsVisibleChanged"
                                     PreviewKeyDown="Window_PreviewKeyDown"
                                     WindowState="Normal"
                                     PreviewMouseWheel="Window_PreviewMouseWheel"
                                     SizeChanged="Window_SizeChanged"
                                     ResizeMode="CanResize"
                                     WindowStyle="None"
                                     Loaded="DetailsPage_Loaded"
                                     SourceInitialized="DetailsPage_SourceInitialized"
                                     PreviewKeyUp="Window_PreviewKeyUp">
    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="20" />
    </WindowChrome.WindowChrome>
    <Window.DataContext>
        <vm:DetailsPageViewModel />
    </Window.DataContext>
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
        <vc:PercentToDecimalConverter x:Key="PercentToDecimal" />
        <vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
    </Window.Resources>

    <Grid Margin="10 10 10 10">
        <Grid x:Name="MainContent"
              x:FieldModifier="private"
              Margin="10 0 10 10">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

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

                <Decorator x:Name="FocusDecorator"
                           x:FieldModifier="private">
                    <Decorator.LayoutTransform>
                        <ScaleTransform CenterX="0"
                                        CenterY="0"
                                        ScaleX="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}"
                                        ScaleY="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}" />
                    </Decorator.LayoutTransform>
                </Decorator>
            </Canvas>

            <Border x:Name="Header"
                    Grid.Row="0"
                    Panel.ZIndex="2"
                    PreviewMouseLeftButtonDown="Header_PreviewMouseLeftButtonDown">
                <DockPanel LastChildFill="False"
                           Margin="0,-7,0,0">

                    <Border x:Name="DialogCloseElement"
                            x:FieldModifier="private"
                            DockPanel.Dock="Bottom"
                            HorizontalAlignment="Right"
                            Cursor="Hand"
                            CornerRadius="5"
                            Margin="0 2.5 7.5 -30"
                            Padding="10 2.5"
                            Background="{DynamicResource  BackgroundColor.DetailsPage.Widget.Value}"
                            MouseLeftButtonUp="CloseCaseWithTicketIcon_MouseLeftButtonUp"
                            TouchDown="CloseCaseWithTicketIcon_TouchDown">
                        <StackPanel Orientation="Horizontal"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center">
                            <ico:AdaptableIcon x:Name="CloseCaseWithTicketIcon"
                                               x:FieldModifier="private"
                                               HorizontalAlignment="Left"
                                               VerticalAlignment="Center"
                                               Margin="0 0 5 0"
                                               Panel.ZIndex="2"
                                               BorderPadding="0"
                                               IconHeight="25"
                                               IconWidth="25"
                                               SelectedMaterialIcon="ic_mail">
                                <ico:AdaptableIcon.Resources>
                                    <Style TargetType="ico:AdaptableIcon">
                                        <Setter Property="PrimaryIconColor"
                                                Value="{DynamicResource FontColor.Menu.Categories}" />

                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Border}, Path=IsMouseOver}"
                                                         Value="True">
                                                <Setter Property="PrimaryIconColor"
                                                        Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </ico:AdaptableIcon.Resources>
                            </ico:AdaptableIcon>

                            <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Dialog.CloseCase}">
                                <TextBlock.Resources>
                                    <Style TargetType="TextBlock">
                                        <Setter Property="VerticalAlignment"
                                                Value="Center" />
                                        <Setter Property="FontSize"
                                                Value="16" />
                                        <Setter Property="Foreground"
                                                Value="{DynamicResource FontColor.Menu.Categories}" />

                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Border}, Path=IsMouseOver}"
                                                         Value="True">
                                                <Setter Property="Foreground"
                                                        Value="{DynamicResource FontColor.Menu.Categories.Hover}" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBlock.Resources>
                            </TextBlock>
                        </StackPanel>
                    </Border>

                    <StackPanel DockPanel.Dock="Right"
                                Orientation="Horizontal"
                                HorizontalAlignment="Right">

                        <Border x:Name="ZoomValueBorder"
                                Grid.Row="1"
                                Margin="0 10 10 0"
                                Opacity="0"
                                CornerRadius="7.5"
                                Padding="10 5"
                                Background="{DynamicResource Color.SoftContrast}">
                            <TextBlock x:Name="ZoomValueTextBlock"
                                       Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
                                       FontWeight="Bold"
                                       FontSize="20" />
                        </Border>

                        <uc:DetailsPageWindowStateBar x:Name="WindowStateBarUserControl" />
                    </StackPanel>

                </DockPanel>
            </Border>

            <Border x:Name="Body"
                    Padding="10"
                    Grid.Row="1">
                <Border.LayoutTransform>
                    <ScaleTransform CenterX="0"
                                    CenterY="0"
                                    ScaleX="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}"
                                    ScaleY="{Binding ZoomInPercent, Converter={StaticResource PercentToDecimal}}" />
                </Border.LayoutTransform>

                <Grid x:Name="MainGrid"
                      Grid.IsSharedSizeScope="True">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="42" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <Border x:Name="BlurBorder"
                            Background="{DynamicResource Color.BlurBorder}"
                            Grid.RowSpan="999"
                            Opacity="0.3"
                            Margin="-30 -65"
                            Visibility="{Binding ElementName=DetailsPage, Path=IsBlurred, Converter={StaticResource BoolToVisibility}}"
                            Panel.ZIndex="3"
                            MouseUp="BlurBorder_MouseUp"
                            TouchDown="BlurBorder_TouchDown">
                    </Border>
                    <buc:BlurInvokerContainer x:Name="OverlayBorder"
                                              x:FieldModifier="private"
                                              HorizontalAlignment="Center"
                                              MaxWidth="990"
                                              Grid.RowSpan="999"
                                              Panel.ZIndex="4"
                                              Padding="75 25" />

                    <uc:DetailsPageNavigationHeading x:Name="NavigationHeadingUc"
                                                     Grid.Row="0"
                                                     VerticalAlignment="Top"
                                                     HorizontalAlignment="Left"
                                                     Grid.RowSpan="3"
                                                     Panel.ZIndex="1"/>

                    <uc:DetailsPageWidgetCollection x:Name="WidgetCollection"
                                                    Grid.Row="1"
                                                    Margin="0 35 0 10"
                                                    WidgetGeometryList="{Binding WidgetGeometryList}" />

                    <uc:DetailsPageRefreshControl x:Name="RefreshControl"
                                                  Grid.Row="2"
                                                  Margin="0 10 5.5 0"
                                                  VerticalAlignment="Top" />

                    <DockPanel LastChildFill="False"
                               Grid.Row="2">

                        <buc:QuickActionSelector x:Name="QuickActionSelectorUc"
                                                 DockPanel.Dock="Right"
                                                 Margin="15 27.5 0 0"
                                                 MaxWidth="300"
                                                 MinWidth="280"
                                                 VerticalAlignment="Top"
                                                 IsVisibleChanged="DynamicElement_IsVisibleChanged" />

                        <DockPanel LastChildFill="True">

                            <Decorator x:Name="QuickActionDecorator"
                                       DockPanel.Dock="Right"
                                       MaxWidth="400"
                                       Margin="19 27.5 0 0"
                                       Visibility="Collapsed"
                                       IsVisibleChanged="DynamicElement_IsVisibleChanged" />

                            <Decorator x:Name="NotepadDecorator"
                                       DockPanel.Dock="Right"
                                       MaxWidth="400"
                                       Margin="19 27.5 0 0"
                                       Visibility="Visible"
                                       IsVisibleChanged="DynamicElement_IsVisibleChanged" />

                            <Decorator x:Name="QuickTipDecorator"
                                       DockPanel.Dock="Right"
                                       MaxWidth="400"
                                       Margin="19 27.5 0 0"
                                       Visibility="Visible">

                                <quc:QuickTipStatusMonitor x:Name="QuickTipStatusMonitorUc"
                                                           Visibility="Collapsed"
                                                           IsVisibleChanged="QuickTipStatusMonitorUc_IsVisibleChanged" />

                            </Decorator>

                            <uc:DetailsPageDataHistoryCollection x:Name="DataHistoryCollectionUserControl"
                                                                 DockPanel.Dock="Left"
                                                                 HorizontalAlignment="Left"
                                                                 DetailsGeometry="{Binding DetailsGeometry}" />

                            <uc:CustomizableSection x:Name="CustomizableSectionUc"
                                                    DockPanel.Dock="Left"
                                                    HorizontalAlignment="Left"
                                                    Visibility="Collapsed"
                                                    IsVisibleChanged="DynamicElement_IsVisibleChanged" />

                        </DockPanel>

                    </DockPanel>

                    <Border x:Name="SearchResultBorder"
                            Grid.Row="1"
                            Grid.RowSpan="2"
                            Padding="10"
                            Margin="0 -30 -10 0"
                            Panel.ZIndex="2"
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Right"
                            CornerRadius="10"
                            Background="{DynamicResource BackgroundColor.Menu.Categories}">
                        <buc:CustomSearchResultCollection x:Name="SearchResultsUc"
                                                          x:FieldModifier="private" />
                    </Border>

                </Grid>

            </Border>

            <Border x:Name="Footer"
                    Grid.Row="2"
                    Panel.ZIndex="2"
                    HorizontalAlignment="Stretch"
                    PreviewMouseLeftButtonDown="Footer_PreviewMouseLeftButtonDown">
                <Grid HorizontalAlignment="Stretch">
                    <buc:MenuBar x:Name="MenuBarUserControl"
                                 x:FieldModifier="private"
                                 MenuBarItemData="{Binding MenuBarData}" />
                    <buc:SearchBar x:Name="SearchBarUserControl"
                                   x:FieldModifier="private"
                                   Visibility="Collapsed"
                                   HorizontalAlignment="Right" />

                    <StackPanel x:Name="IconTimerPanel"
                                Orientation="Horizontal"
                                PreviewMouseLeftButtonDown="IconTimerPanel_PreviewMouseLeftButtonDown">
                        <ico:AdaptableIcon x:Name="F4SDIcon"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Bottom"
                                           PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
                                           BorderPadding="0"
                                           MouseLeftButtonUp="F4SDIcon_MouseLeftButtonUp"
                                           SelectedInternIcon="f4sd_outline" />

                        <buc:TimerView x:Name="CaseTimer"
                                       VerticalAlignment="Bottom"
                                       Margin="15 -2.5"
                                       OnPauseStarted="CaseTimer_OnPauseStarted" />

                    </StackPanel>
                </Grid>
            </Border>
        </Grid>

        <Grid x:Name="PauseOverlay"
              x:FieldModifier="private"
              Grid.RowSpan="999"
              Grid.ColumnSpan="999"
              Panel.ZIndex="999"
              Visibility="Collapsed"
              Margin="-10">
            <Border Background="{DynamicResource Color.BlurBorder}"
                    Opacity="0.25"
                    CornerRadius="5">
            </Border>
            <buc:PauseCaseOverlay HorizontalAlignment="Center"
                                  VerticalAlignment="Center"
                                  OnPauseEnd="PauseCaseOverlay_OnPauseEnd" />
        </Grid>
    </Grid>
</detailspagebase:SupportCasePageBase>
