<ui:FluentWindow x:Class="DesktopMagic.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
        xmlns:tray="http://schemas.lepo.co/wpfui/2022/xaml/tray"
        xmlns:pages="clr-namespace:DesktopMagic.Pages"
        xmlns:plugins="clr-namespace:DesktopMagic.Plugins"
        mc:Ignorable="d"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:dataContext="clr-namespace:DesktopMagic.DataContexts"
        d:DataContext="{d:DesignInstance Type=dataContext:MainWindowDataContext}"
        ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
        ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
        Foreground="{DynamicResource TextFillColorPrimaryBrush}"
        WindowCornerPreference="Round"
        WindowBackdropType="Tabbed"    
        Closing="Window_Closing"
        Closed="Window_Closed"
        Height="560"
        Width="900"
        MinHeight="600"
        MinWidth="940"
        ExtendsContentIntoTitleBar="True"
        WindowState="Minimized"
        Loaded="Window_Loaded">

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

        <ui:TitleBar x:Name="TitleBar" Title="{Binding Title}">
            <ui:TitleBar.Icon>
                <ui:ImageIcon Source="{StaticResource Icon}" />
            </ui:TitleBar.Icon>
        </ui:TitleBar>

        <tray:NotifyIcon Grid.Row="0" FocusOnLeftClick="True" MenuOnRightClick="True" TooltipText="{Binding AppName}" Icon="{StaticResource Icon}" LeftClick="NotifyIcon_LeftClick">
            <tray:NotifyIcon.Menu>
                <ContextMenu>
                    <MenuItem Header="Settings" Click="SettingsMenuItem_Click" />
                    <MenuItem Header="Edit Layout" Click="EditLayoutMenuItem_Click" />
                    <MenuItem Header="Quit" Click="QuitMenuItem_Click" />
                </ContextMenu>
            </tray:NotifyIcon.Menu>
        </tray:NotifyIcon>

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

            <ui:NavigationView x:Name="NavigationView" Grid.Row="0" IsBackButtonVisible="Collapsed" IsPaneToggleVisible="True" OpenPaneLength="200"  Loaded="NavigationView_Loaded">
                <ui:NavigationView.MenuItems>
                    <ui:NavigationViewItem Content="{DynamicResource plugins}" TargetPageType="{x:Type pages:MainPage}">
                        <ui:NavigationViewItem.Icon>
                            <ui:SymbolIcon Symbol="Apps24" />
                        </ui:NavigationViewItem.Icon>
                    </ui:NavigationViewItem>
                    <ui:NavigationViewItem Content="{DynamicResource themes}" TargetPageType="{x:Type pages:ThemePage}">
                        <ui:NavigationViewItem.Icon>
                            <ui:SymbolIcon Symbol="Color24" />
                        </ui:NavigationViewItem.Icon>
                    </ui:NavigationViewItem>
                    <ui:NavigationViewItem Content="{DynamicResource pluginManager}" TargetPageType="{x:Type plugins:PluginManager}">
                        <ui:NavigationViewItem.Icon>
                            <ui:SymbolIcon Symbol="AppsAddIn24" />
                        </ui:NavigationViewItem.Icon>
                    </ui:NavigationViewItem>
                </ui:NavigationView.MenuItems>

                <ui:NavigationView.FooterMenuItems>
                    <ui:NavigationViewItem Content="{DynamicResource requestFeature}" Click="ReportBugNavigationViewItem_Click">
                        <ui:NavigationViewItem.Icon>
                            <ui:SymbolIcon Symbol="ChatHelp24"/>
                        </ui:NavigationViewItem.Icon>
                    </ui:NavigationViewItem>
                    <ui:NavigationViewItem Content="{DynamicResource reportBug}" Click="ReportBugNavigationViewItem_Click">
                        <ui:NavigationViewItem.Icon>
                            <ui:SymbolIcon Symbol="Bug24"/>
                        </ui:NavigationViewItem.Icon>
                    </ui:NavigationViewItem>
                </ui:NavigationView.FooterMenuItems>
            </ui:NavigationView>

            <Border Grid.Row="1" Background="{DynamicResource ControlFillColorDefaultBrush}" BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}" BorderThickness="0,1,0,0" Padding="5 2 5 5">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <StackPanel Orientation="Horizontal" Grid.Column="0">
                        <ui:HyperlinkButton FontWeight="Bold" Content="{DynamicResource developedBy}" NavigateUri="https://me.stone-red.net"/>
                    </StackPanel>

                    <ui:ToggleSwitch x:Name="autoStartCheckBox" Style="{StaticResource ToggleSwitchContentLeftStyle}" Grid.Column="2" Margin="0 0 5 0" Content="{DynamicResource autoStart}" IsChecked="{Binding IsAutoStartEnabled}" VerticalAlignment="Center"/>
                </Grid>
            </Border>
        </Grid>
        <ContentPresenter x:Name="rootContentDialog" Grid.Row="1" Grid.RowSpan="2" />
    </Grid>
</ui:FluentWindow>