<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="Sonex.Client.AppWindows.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Sonex.Client"
    xmlns:sc="using:Sonex.Client.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:helpers="using:Sonex.Client.Dialogs"
    mc:Ignorable="d"
    xmlns:ic="using:FluentIcons.WinUI"
    Title="Sonex"
    SizeChanged="MainWindow_SizeChanged"
    >
    <Window.SystemBackdrop>
        <MicaBackdrop />
    </Window.SystemBackdrop>

    <Grid >
        <Grid.Resources>
            <Style x:Key="RoundButtonStyle" TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}">
                <Setter Property="Width" Value="36" />
                <Setter Property="Height" Value="36" />
                <Setter Property="Padding" Value="0" />
                <Setter Property="HorizontalContentAlignment" Value="Center" />
                <Setter Property="VerticalContentAlignment" Value="Center" />
                <Setter Property="CornerRadius" Value="18" />
                <Setter Property="Foreground" Value="{StaticResource SystemColorGrayTextBrush}"/>
                <Setter Property="FontWeight" Value="Bold"/>

            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <TitleBar
            x:Name="titleBar"
            BackRequested="TitleBar_BackRequested"
            IsBackButtonVisible="{x:Bind navFrame.CanGoBack, Mode=OneWay}"
            IsPaneToggleButtonVisible="True"
            PaneToggleRequested="TitleBar_PaneToggleRequested"
            Margin="0"
            Padding="0"
            HorizontalContentAlignment="Left"
            >

            <TitleBar.LeftHeader>
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="8">
                    <Image x:Name="Logo" Source="/Assets/sonex_logo.svg"  Height="22" Margin="8 0 0 0"/>
                </StackPanel>
            </TitleBar.LeftHeader>
            <TitleBar.Content>
                <BreadcrumbBar
                        x:Name="BreadcrumbBar1"
                        Margin="170,0,0,0"
                        FontWeight="Bold"
                        ItemClicked="BreadcrumbBar1_ItemClicked">
                    <BreadcrumbBar.ItemTemplate>
                        <DataTemplate>
                            <TextBlock
                                    Text="{Binding Title}"
                                    AutomationProperties.Name="{Binding Title}"
                                    FontSize="18"
                                    />
                        </DataTemplate>
                    </BreadcrumbBar.ItemTemplate>
                </BreadcrumbBar>
            </TitleBar.Content>
            <TitleBar.RightHeader >
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Spacing="8" HorizontalAlignment="Right">
                    <TeachingTip
                                x:Name="ProfileButtonTeachingTip"
                                PreferredPlacement="Bottom"
                                CloseButtonContent="Logout"
                                CloseButtonClick="ProfileButtonTeachingTip_CloseButtonClick"
                                ActionButtonContent="Change password"
                                ActionButtonClick="ProfileButtonTeachingTip_ActionButtonClick"
                                IsLightDismissEnabled="True"

                                Target="{x:Bind ProfileButton}">
                        <TeachingTip.IconSource>
                            <SymbolIconSource Symbol="Contact" />
                        </TeachingTip.IconSource>
                    </TeachingTip>
                    <Button x:Name="ProfileButton" Style="{StaticResource  RoundButtonStyle}" Click="ProfileButton_Click">
                        <TextBlock x:Name="InitialsTextBox"/>
                    </Button>

                    <Button Style="{StaticResource  RoundButtonStyle}" ToolTipService.Placement="Bottom" ToolTipService.ToolTip="Alerts">
                        <PathIcon Translation="-1.5 0 0" Data="M12 1.996a7.49 7.49 0 0 1 7.496 7.25l.004.25v4.097l1.38 3.156a1.25 1.25 0 0 1-1.145 1.75L15 18.502a3 3 0 0 1-5.995.177L9 18.499H4.275a1.25 1.25 0 0 1-1.147-1.747L4.5 13.594V9.496c0-4.155 3.352-7.5 7.5-7.5M13.5 18.5l-3 .002a1.5 1.5 0 0 0 2.993.145zM12 3.496c-3.32 0-6 2.674-6 6v4.41L4.656 17h14.697L18 13.907V9.509l-.003-.225A5.99 5.99 0 0 0 12 3.496" />
                    </Button>
                    <Button x:Name="LogoutButton" Click="LogoutButton_Click" Style="{StaticResource  RoundButtonStyle}" ToolTipService.Placement="Bottom" ToolTipService.ToolTip="Logout">
                        <PathIcon Translation="-2 -2 0" Data="M12 3.25a.75.75 0 0 1 0 1.5a7.25 7.25 0 0 0 0 14.5a.75.75 0 0 1 0 1.5a8.75 8.75 0 1 1 0-17.5 M16.47 9.53a.75.75 0 0 1 1.06-1.06l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H10a.75.75 0 0 1 0-1.5h8.19z" />
                    </Button>


                </StackPanel>
            </TitleBar.RightHeader>
        </TitleBar>
        <NavigationView
            x:Name="navView"
            Grid.Row="1"
            
            IsBackButtonVisible="Collapsed"
            IsPaneToggleButtonVisible="False"
            IsSettingsVisible="False"
            
            SelectionChanged="navView_SelectionChanged">
            <NavigationView.Resources>
                <CornerRadius x:Key="NavigationViewContentGridCornerRadius">12,0,0,0</CornerRadius>
                <SolidColorBrush x:Key="NavigationViewContentGridBorderBrush" Color="Transparent" />
                <SolidColorBrush x:Key="NavigationViewContentGridBackgroundBrush" Color="DimGray" />
            </NavigationView.Resources>

            
            <NavigationView.MenuItems>
                <sc:NavigationViewImageItem Content="Diagrams" IconPath="Assets/icons8/icons8-portraits-48.png" Tag="Diagrams"/>

                <sc:NavigationViewImageItem Content="Warehouse" IconPath="Assets/icons8/icons8-warehouse-48.png" Tag="Warehouse.Products" SelectsOnInvoked="False" IsExpanded="True" >
                    <NavigationViewItem.MenuItems>
                        <sc:NavigationViewImageItem Content="Products" IconPath="Assets/icons8/icons8-portraits-48.png" Tag="Warehouse.Products"/>
                    </NavigationViewItem.MenuItems>
                </sc:NavigationViewImageItem>

                <sc:NavigationViewImageItem Content="Laboratory" IconPath="Assets/icons8/icons8-services-48.png" Tag="Laboratory.SceneCanvasLab" SelectsOnInvoked="False">
                    <NavigationViewItem.MenuItems>
                        <sc:NavigationViewImageItem Content="SceneCanvas Lab" IconPath="Assets/icons8/icons8-portraits-48.png" Tag="Laboratory.SceneCanvasLab"/>
                    </NavigationViewItem.MenuItems>
                </sc:NavigationViewImageItem>

                <NavigationViewItemSeparator/>
                <NavigationViewItemHeader Content="Administrator"/>
                
                <sc:NavigationViewImageItem Content="Access Control" IconPath="Assets/icons8/icons8-user-shield-48.png" Tag="Administrator.Users.Users" SelectsOnInvoked="False" >
                    <NavigationViewItem.MenuItems>
                        <sc:NavigationViewImageItem Content="Accounts"  IconPath="Assets/icons8/icons8-person-48.png" Tag="Administrator.Accounts.Accounts"/>
                        <sc:NavigationViewImageItem Content="Groups"  IconPath="Assets/icons8/icons8-group-48.png"  Tag="Administrator.Accounts.Groups"/>
                        <sc:NavigationViewImageItem Content="Sessions"  IconPath="Assets/icons8/icons8-connect-48.png"  Tag="Administrator.Accounts.Sessions"/>
                    </NavigationViewItem.MenuItems>
                </sc:NavigationViewImageItem>

                <sc:NavigationViewImageItem Content="System Logs" IconPath="Assets/icons8/icons8-log-48.png" Tag="Administrator.SystemLogs.ApplicationErrors" SelectsOnInvoked="False">
                    <NavigationViewItem.MenuItems>
                        <sc:NavigationViewImageItem Content="Application Errors" IconPath="Assets/icons8/icons8-event-log-48.png" Tag="Administrator.SystemLogs.ApplicationErrors"/>
                        <sc:NavigationViewImageItem Content="Data Changes" IconPath="Assets/icons8/icons8-edit-property-48.png" Tag="Administrator.SystemLogs.DataChanges"/>
                    </NavigationViewItem.MenuItems>
                </sc:NavigationViewImageItem>

                <sc:NavigationViewImageItem Content="System" IconPath="Assets/icons8/icons8-database-server-48.png" Tag="Administrator.System.Services" SelectsOnInvoked="False">
                    <NavigationViewItem.MenuItems>
                        <sc:NavigationViewImageItem Content="Services" IconPath="Assets/icons8/icons8-services-48.png" Tag="Administrator.System.Services"/>
                    </NavigationViewItem.MenuItems>
                </sc:NavigationViewImageItem>
                
            </NavigationView.MenuItems>

            <Frame x:Name="navFrame" IsNavigationStackEnabled="False" Navigated="NavFrame_Navigated"  Background="Transparent">
                <Frame.ContentTransitions>
                    <TransitionCollection>
                        <NavigationThemeTransition  />
                    </TransitionCollection>
                </Frame.ContentTransitions>
            </Frame>

        </NavigationView>
    </Grid>
</Window>
