<ui:FluentWindow x:Class="InvLock.MainWindow"
    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:local="clr-namespace:InvLock"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:tray="http://schemas.lepo.co/wpfui/2022/xaml/tray"
    xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
    xmlns:dataContext="clr-namespace:InvLock.DataContexts"
    mc:Ignorable="d"
    d:DataContext="{d:DesignInstance Type=dataContext:MainWindowDataContext}"
    d:DesignHeight="450"
    d:DesignWidth="800"
    ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
    ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
    ExtendsContentIntoTitleBar="True"
    Foreground="{DynamicResource TextFillColorPrimaryBrush}"
    WindowBackdropType="Mica"
    WindowCornerPreference="Round"
    WindowStartupLocation="CenterScreen"
    WindowState="Minimized"
    Loaded="Window_Loaded"
    Closing="FluentWindow_Closing"
    Closed="FluentWindow_Closed"
    Width="1100"
    Height="660">

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

        <ui:TitleBar Title="{Binding Title}">
            <ui:TitleBar.Icon>
                <ui:ImageIcon Source="pack://application:,,,/Assets/logo.ico" />
            </ui:TitleBar.Icon>
        </ui:TitleBar>

        <tray:NotifyIcon Grid.Row="0" FocusOnLeftClick="True" MenuOnRightClick="True" LeftClick="NotifyIcon_LeftClick" TooltipText="{Binding AppName}">
            <tray:NotifyIcon.Menu>
                <ContextMenu>
                    <MenuItem Header="Settings" Click="SettingsMenuItem_Click" />
                    <MenuItem Header="Quit" Click="QuitMenuItem_Click" />
                </ContextMenu>
            </tray:NotifyIcon.Menu>
            <tray:NotifyIcon.Icon>
                <BitmapImage UriSource="pack://application:,,,/Assets/logo.ico" />
            </tray:NotifyIcon.Icon>
        </tray:NotifyIcon>

        <ui:DynamicScrollViewer Grid.Row="1" VirtualizingPanel.ScrollUnit="Pixel">
            <StackPanel Margin="24 0 24 24">
                <ui:TextBlock TextWrapping="Wrap" Margin="0 0 0 10" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}">
                    InvLock is a simple lock screen application for Windows 10/11.
                    It is designed to be lightweight and easy to use.
                    <LineBreak />
                    If you have any issues or feature requests, please report them on GitHub.
                </ui:TextBlock>

                <ui:TextBlock Margin="0,0,0,8" FontTypography="BodyStrong" Text="Appearance &amp; behavior" />
                <ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Color24}" Height="75">
                    <ui:CardControl.Header>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <ui:TextBlock Grid.Row="0" FontTypography="Body" Text="App theme" />
                            <ui:HyperlinkButton Grid.Row="1" Margin="0" Padding="1" FontSize="12" NavigateUri="ms-settings:colors">
                                <ui:TextBlock Text="Windows color settings" />
                            </ui:HyperlinkButton>
                        </Grid>
                    </ui:CardControl.Header>
                    <ComboBox Grid.Column="1" MinWidth="200" SelectedIndex="0" SelectedValue="{Binding Settings.Theme}" SelectedValuePath="Content">
                        <ComboBoxItem Content="Windows default" />
                        <ComboBoxItem Content="Light" />
                        <ComboBoxItem Content="Dark" />
                    </ComboBox>
                </ui:CardControl>

                <ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=Window24}" Height="75">
                    <ui:CardControl.Header>
                        <ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Show desktop while locked" />
                    </ui:CardControl.Header>
                    <ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.HideWindows}" OffContent="Off" OnContent="On" />
                </ui:CardControl>

                <ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=WindowShield24}" Height="75">
                    <ui:CardControl.Header>
                        <ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Use windows lock screen to unlock" />
                    </ui:CardControl.Header>
                    <ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.UseWindowsLockScreen}" OffContent="Off" OnContent="On" />
                </ui:CardControl>

                <ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=LockClosed24}" Height="75">
                    <ui:CardControl.Header>
                        <ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Lock text" />
                    </ui:CardControl.Header>
                    <ui:TextBox Grid.Column="1" MinWidth="200" Text="{Binding Settings.LockText, UpdateSourceTrigger=PropertyChanged}" PlaceholderText="Type your lock text here" />
                </ui:CardControl>

                <ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=LockClosed24}" Height="75">
                    <ui:CardControl.Header>
                        <ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Lock shortcut" />
                    </ui:CardControl.Header>
                    <ui:Button Grid.Column="1" Command="{Binding RecordLockShortcutCommand}" MinWidth="200" Icon="{ui:SymbolIcon Symbol=Edit24}" Content="{Binding Settings.LockShortcutText}" />
                </ui:CardControl>

                <ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=LockOpen24}" Height="75">
                    <ui:CardControl.Header>
                        <ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Unlock text" />
                    </ui:CardControl.Header>
                    <ui:TextBox Grid.Column="1" MinWidth="200" Text="{Binding Settings.UnlockText, UpdateSourceTrigger=PropertyChanged}" PlaceholderText="Type your unlock text here" />
                </ui:CardControl>

                <ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=LockOpen24}" Height="75">
                    <ui:CardControl.Header>
                        <ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Unlock shortcut" />
                    </ui:CardControl.Header>
                    <ui:Button Grid.Column="1" Command="{Binding RecordUnlockShortcutCommand}" MinWidth="200" Icon="{ui:SymbolIcon Symbol=Edit24}" Content="{Binding Settings.UnlockShortcutText}" />
                </ui:CardControl>

                <ui:TextBlock Margin="0,24,0,8" FontTypography="BodyStrong" Text="About" />
                <ui:CardExpander ContentPadding="0">
                    <ui:CardExpander.Header>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ui:TextBlock Grid.Row="0" Grid.Column="0" FontTypography="Body" Text="{Binding AppName}" />
                            <ui:TextBlock Grid.Row="1" Grid.Column="0" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" FontSize="12" Text="Stone_Red | MIT" />
                            <TextBlock Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" Margin="0,0,16,0" VerticalAlignment="Center" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="{Binding AppVersion, Mode=OneWay}" />
                        </Grid>
                    </ui:CardExpander.Header>
                    <StackPanel>
                        <ui:Anchor Margin="0" Padding="16" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Background="Transparent" CornerRadius="0" BorderThickness="0" NavigateUri="https://github.com/Stone-Red-Code/InvLock/issues/new/choose">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" Text="Report an issue or request a feature" />
                                <StackPanel Grid.Column="1" Orientation="Horizontal">
                                    <ui:SymbolIcon Margin="0 0 6 0" Symbol="Link24" />
                                    <TextBlock Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="https://github.com/Stone-Red-Code/InvLock/issues" />
                                </StackPanel>
                            </Grid>
                        </ui:Anchor>

                        <Separator />

                        <ui:Anchor Margin="0" Padding="16" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Background="Transparent" CornerRadius="0" BorderThickness="0" NavigateUri="https://github.com/Stone-Red-Code/InvLock">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" Text="GitHub" />
                                <StackPanel Grid.Column="1" Orientation="Horizontal">
                                    <ui:SymbolIcon Margin="0 0 6 0" Symbol="Link24" />
                                    <TextBlock Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="https://github.com/Stone-Red-Code/InvLock" />
                                </StackPanel>
                            </Grid>
                        </ui:Anchor>

                        <Separator />

                        <Grid Margin="16">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="Version" />
                            <TextBlock Grid.Column="1" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="{Binding AppVersion}" />
                        </Grid>
                    </StackPanel>
                </ui:CardExpander>
            </StackPanel>
        </ui:DynamicScrollViewer>
    </Grid>
</ui:FluentWindow>