<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="NickvisionTagger.WinUI.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:NickvisionTagger.WinUI.Views"
    xmlns:nickvision="using:NickvisionTagger.WinUI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:wct="using:CommunityToolkit.WinUI.Controls"
    mc:Ignorable="d" Activated="Window_Activated">

    <Window.SystemBackdrop>
        <MicaBackdrop />
    </Window.SystemBackdrop>

    <Grid x:Name="MainGrid" AllowDrop="True" ActualThemeChanged="Window_ActualThemeChanged" Drop="OnDrop" DragOver="OnDragOver" Loaded="Window_Loaded">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid x:Name="TitleBar" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="48">
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="LeftPaddingColumn" Width="0"/>
                <ColumnDefinition x:Name="IconColumn" Width="Auto"/>
                <ColumnDefinition x:Name="TitleColumn" Width="Auto"/>
                <ColumnDefinition x:Name="LeftDragColumn" Width="0"/>
                <ColumnDefinition x:Name="MenuColumn" Width="Auto"/>
                <ColumnDefinition x:Name="RightDragColumn" Width="*"/>
                <ColumnDefinition x:Name="RightPaddingColumn" Width="0"/>
            </Grid.ColumnDefinitions>

            <Image x:Name="TitleBarIcon" Grid.Column="1" Margin="8,0,0,0" Width="16" Height="16" Source="../Resources/org.nickvision.tagger.ico"/>

            <TextBlock x:Name="TitleBarTitle" Grid.Column="2" VerticalAlignment="Center" Margin="4,0,0,0" Style="{ThemeResource CaptionTextBlockStyle}"/>

            <StackPanel Grid.Column="4" Margin="4,0,4,0" Orientation="Horizontal" Spacing="4">
                <MenuBar x:Name="MainMenu" IsEnabled="False">
                    <MenuBarItem x:Name="MenuFile">
                        <MenuFlyoutItem x:Name="MenuOpenFolder" Click="OpenFolder">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE838;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Control" Key="O"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutItem x:Name="MenuOpenPlaylist" Click="OpenPlaylist">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE142;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Control,Shift" Key="O"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutSeparator/>

                        <MenuFlyoutItem x:Name="MenuReloadLibrary" IsEnabled="False" Click="ReloadLibrary">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE149;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="None" Key="F5"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutItem x:Name="MenuCloseLibrary" IsEnabled="False" Click="CloseLibrary">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE8F6;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Control" Key="W"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutSeparator/>

                        <MenuFlyoutItem x:Name="MenuExit" Click="Exit">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE106;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Menu" Key="F4"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>
                    </MenuBarItem>

                    <MenuBarItem x:Name="MenuEdit">
                        <MenuFlyoutSubItem x:Name="MenuSortFilesBy">
                            <MenuFlyoutSubItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE174;"/>
                            </MenuFlyoutSubItem.Icon>

                            <ToggleMenuFlyoutItem x:Name="MenuSortFilesFileName" Click="SortFilesBy"/>

                            <ToggleMenuFlyoutItem x:Name="MenuSortFilesFilePath" Click="SortFilesBy"/>

                            <ToggleMenuFlyoutItem x:Name="MenuSortFilesTitle" Click="SortFilesBy"/>

                            <ToggleMenuFlyoutItem x:Name="MenuSortFilesArtist" Click="SortFilesBy"/>

                            <ToggleMenuFlyoutItem x:Name="MenuSortFilesAlbum" Click="SortFilesBy"/>

                            <ToggleMenuFlyoutItem x:Name="MenuSortFilesYear" Click="SortFilesBy"/>

                            <ToggleMenuFlyoutItem x:Name="MenuSortFilesTrack" Click="SortFilesBy"/>

                            <ToggleMenuFlyoutItem x:Name="MenuSortFilesGenre" Click="SortFilesBy"/>
                        </MenuFlyoutSubItem>
                        
                        <MenuFlyoutSeparator/>

                        <MenuFlyoutItem x:Name="MenuSettings" Click="Settings">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE713;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Control" Key="K"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>
                    </MenuBarItem>
                    
                    <MenuBarItem x:Name="MenuPlaylist">
                        <MenuFlyoutItem x:Name="MenuCreatePlaylist" IsEnabled="False" Click="CreatePlaylist">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE142;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Control" Key="P"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutSeparator/>

                        <MenuFlyoutItem x:Name="MenuAddToPlaylist" IsEnabled="False" Click="AddToPlaylist">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE710;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Menu" Key="O"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutItem x:Name="MenuRemoveFromPlaylist" IsEnabled="False" Click="RemoveFromPlaylist">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE108;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Menu" Key="Delete"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>
                    </MenuBarItem>

                    <MenuBarItem x:Name="MenuTag" IsEnabled="False">
                        <MenuFlyoutItem x:Name="MenuSaveTag" IsEnabled="False" Click="SaveTag">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE105;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Control" Key="S"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutItem x:Name="MenuDiscardChanges" Click="DiscardUnappliedChanges">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE10E;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Control" Key="Z"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutItem x:Name="MenuDeleteTag" Click="DeleteTag">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE107;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Shift" Key="Delete"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutSeparator/>

                        <MenuFlyoutItem x:Name="MenuManageLyrics" Click="ManageLyrics">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE7BC;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="Control" Key="L"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>

                        <MenuFlyoutSubItem x:Name="MenuAlbumArt">
                            <MenuFlyoutSubItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE8B9;"/>
                            </MenuFlyoutSubItem.Icon>

                            <MenuFlyoutSubItem x:Name="MenuAlbumArtFront">
                                <MenuFlyoutSubItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE93C;"/>
                                </MenuFlyoutSubItem.Icon>

                                <MenuFlyoutItem x:Name="MenuAlbumArtFrontInsert" Click="InsertAlbumArt">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE710;"/>
                                    </MenuFlyoutItem.Icon>

                                    <MenuFlyoutItem.KeyboardAccelerators>
                                        <KeyboardAccelerator Modifiers="Control" Key="I"/>
                                    </MenuFlyoutItem.KeyboardAccelerators>
                                </MenuFlyoutItem>

                                <MenuFlyoutItem x:Name="MenuAlbumArtFrontRemove" Click="RemoveAlbumArt">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE108;"/>
                                    </MenuFlyoutItem.Icon>

                                    <MenuFlyoutItem.KeyboardAccelerators>
                                        <KeyboardAccelerator Modifiers="Control" Key="Delete"/>
                                    </MenuFlyoutItem.KeyboardAccelerators>
                                </MenuFlyoutItem>

                                <MenuFlyoutItem x:Name="MenuAlbumArtFrontExport" Click="ExportAlbumArt">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE118;"/>
                                    </MenuFlyoutItem.Icon>

                                    <MenuFlyoutItem.KeyboardAccelerators>
                                        <KeyboardAccelerator Modifiers="Control" Key="E"/>
                                    </MenuFlyoutItem.KeyboardAccelerators>
                                </MenuFlyoutItem>

                                <MenuFlyoutItem x:Name="MenuAlbumArtFrontInfo" Click="AlbumArtInfo">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE946;"/>
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                            </MenuFlyoutSubItem>

                            <MenuFlyoutSubItem x:Name="MenuAlbumArtBack">
                                <MenuFlyoutSubItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE93C;"/>
                                </MenuFlyoutSubItem.Icon>

                                <MenuFlyoutItem x:Name="MenuAlbumArtBackInsert" Click="InsertAlbumArt">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE710;"/>
                                    </MenuFlyoutItem.Icon>

                                    <MenuFlyoutItem.KeyboardAccelerators>
                                        <KeyboardAccelerator Modifiers="Control,Shift" Key="I"/>
                                    </MenuFlyoutItem.KeyboardAccelerators>
                                </MenuFlyoutItem>

                                <MenuFlyoutItem x:Name="MenuAlbumArtBackRemove" Click="RemoveAlbumArt">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE108;"/>
                                    </MenuFlyoutItem.Icon>

                                    <MenuFlyoutItem.KeyboardAccelerators>
                                        <KeyboardAccelerator Modifiers="Control,Shift" Key="Delete"/>
                                    </MenuFlyoutItem.KeyboardAccelerators>
                                </MenuFlyoutItem>

                                <MenuFlyoutItem x:Name="MenuAlbumArtBackExport" Click="ExportAlbumArt">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE118;"/>
                                    </MenuFlyoutItem.Icon>

                                    <MenuFlyoutItem.KeyboardAccelerators>
                                        <KeyboardAccelerator Modifiers="Control,Shift" Key="E"/>
                                    </MenuFlyoutItem.KeyboardAccelerators>
                                </MenuFlyoutItem>

                                <MenuFlyoutItem x:Name="MenuAlbumArtBackInfo" Click="AlbumArtInfo">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE946;"/>
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                            </MenuFlyoutSubItem>

                            <MenuFlyoutItem x:Name="MenuSwitchAlbumArt" Click="SwitchAlbumArt">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE13C;"/>
                                </MenuFlyoutItem.Icon>

                                <MenuFlyoutItem.KeyboardAccelerators>
                                    <KeyboardAccelerator Modifiers="Control,Shift" Key="S"/>
                                </MenuFlyoutItem.KeyboardAccelerators>
                            </MenuFlyoutItem>
                        </MenuFlyoutSubItem>

                        <MenuFlyoutSubItem x:Name="MenuCustomProperties">
                            <MenuFlyoutSubItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE771;"/>
                            </MenuFlyoutSubItem.Icon>

                            <MenuFlyoutItem x:Name="MenuCustomPropertiesAdd" Click="AddCustomProperty">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE710;"/>
                                </MenuFlyoutItem.Icon>
                            </MenuFlyoutItem>
                        </MenuFlyoutSubItem>

                        <MenuFlyoutSubItem x:Name="MenuConvert">
                            <MenuFlyoutSubItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE15E;"/>
                            </MenuFlyoutSubItem.Icon>

                            <MenuFlyoutItem x:Name="MenuFilenameToTag" Click="FilenameToTag">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE13E;"/>
                                </MenuFlyoutItem.Icon>

                                <MenuFlyoutItem.KeyboardAccelerators>
                                    <KeyboardAccelerator Modifiers="Control" Key="F"/>
                                </MenuFlyoutItem.KeyboardAccelerators>
                            </MenuFlyoutItem>

                            <MenuFlyoutItem x:Name="MenuTagToFilename" Click="TagToFilename">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE1CB;"/>
                                </MenuFlyoutItem.Icon>

                                <MenuFlyoutItem.KeyboardAccelerators>
                                    <KeyboardAccelerator Modifiers="Control" Key="T"/>
                                </MenuFlyoutItem.KeyboardAccelerators>
                            </MenuFlyoutItem>
                        </MenuFlyoutSubItem>

                        <MenuFlyoutSubItem x:Name="MenuWebServices">
                            <MenuFlyoutSubItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE12B;"/>
                            </MenuFlyoutSubItem.Icon>

                            <MenuFlyoutItem x:Name="MenuDownloadMusicBrainz" Click="DownloadMusicBrainzMetadata">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xEBD3;"/>
                                </MenuFlyoutItem.Icon>

                                <MenuFlyoutItem.KeyboardAccelerators>
                                    <KeyboardAccelerator Modifiers="Control" Key="M"/>
                                </MenuFlyoutItem.KeyboardAccelerators>
                            </MenuFlyoutItem>

                            <MenuFlyoutItem x:Name="MenuDownloadLyrics" Click="DownloadLyrics">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xEBD3;"/>
                                </MenuFlyoutItem.Icon>

                                <MenuFlyoutItem.KeyboardAccelerators>
                                    <KeyboardAccelerator Modifiers="Control,Shift" Key="L"/>
                                </MenuFlyoutItem.KeyboardAccelerators>
                            </MenuFlyoutItem>

                            <MenuFlyoutItem x:Name="MenuSubmitToAcoustId" Click="SubmitToAcoustId">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE11C;"/>
                                </MenuFlyoutItem.Icon>

                                <MenuFlyoutItem.KeyboardAccelerators>
                                    <KeyboardAccelerator Modifiers="Control" Key="U"/>
                                </MenuFlyoutItem.KeyboardAccelerators>
                            </MenuFlyoutItem>
                        </MenuFlyoutSubItem>
                    </MenuBarItem>
                    
                    <MenuBarItem x:Name="MenuHelp">
                        <MenuFlyoutItem x:Name="MenuCheckForUpdates" Click="CheckForUpdates">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE117;"/>
                            </MenuFlyoutItem.Icon>
                        </MenuFlyoutItem>

                        <MenuFlyoutSeparator />

                        <MenuFlyoutItem x:Name="MenuDocumentation" Click="Documentation">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE11B;"/>
                            </MenuFlyoutItem.Icon>
                        </MenuFlyoutItem>

                        <MenuFlyoutItem x:Name="MenuGitHubRepo" Click="GitHubRepo">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE8F1;"/>
                            </MenuFlyoutItem.Icon>
                        </MenuFlyoutItem>

                        <MenuFlyoutItem x:Name="MenuReportABug" Click="ReportABug">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xEBE8;"/>
                            </MenuFlyoutItem.Icon>
                        </MenuFlyoutItem>

                        <MenuFlyoutItem x:Name="MenuDiscussions" Click="Discussions">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE8F2;"/>
                            </MenuFlyoutItem.Icon>
                        </MenuFlyoutItem>

                        <MenuFlyoutSeparator />

                        <MenuFlyoutItem x:Name="MenuAbout" Click="About">
                            <MenuFlyoutItem.Icon>
                                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE946;"/>
                            </MenuFlyoutItem.Icon>

                            <MenuFlyoutItem.KeyboardAccelerators>
                                <KeyboardAccelerator Modifiers="None" Key="F1"/>
                            </MenuFlyoutItem.KeyboardAccelerators>
                        </MenuFlyoutItem>
                    </MenuBarItem>
                </MenuBar>

                <TextBlock x:Name="TitlePreview" VerticalAlignment="Center" Margin="10,0,0,0" Style="{ThemeResource NavigationViewItemHeaderTextStyle}" Foreground="Gray" FontSize="12"/>
            </StackPanel>
        </Grid>

        <Grid Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <nickvision:ViewStack x:Name="ViewStack" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <nickvision:ViewStack.Pages>
                    <nickvision:ViewStackPage PageName="Startup">
                        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical" Spacing="64">
                            <Image Width="128" Height="128" Source="../Resources/org.nickvision.tagger.ico"/>

                            <ProgressRing />
                        </StackPanel>
                    </nickvision:ViewStackPage>

                    <nickvision:ViewStackPage PageName="Loading">
                        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical" Spacing="24">
                            <ProgressRing />

                            <TextBlock x:Name="LblLoading" HorizontalAlignment="Center" Style="{ThemeResource NavigationViewItemHeaderTextStyle}"/>

                            <ProgressBar x:Name="ProgLoading" MinWidth="300"/>

                            <TextBlock x:Name="LblLoadingProgress" HorizontalAlignment="Center"/>
                        </StackPanel>
                    </nickvision:ViewStackPage>

                    <nickvision:ViewStackPage PageName="Home">
                        <Grid>
                            <nickvision:StatusPage x:Name="StatusPageHome" HorizontalAlignment="Center" VerticalAlignment="Center" UseAppIcon="True">
                                <nickvision:StatusPage.Child>
                                    <StackPanel Orientation="Horizontal" Spacing="6">
                                        <Button Style="{ThemeResource AccentButtonStyle}" Click="OpenFolder">
                                            <Button.Content>
                                                <StackPanel Orientation="Horizontal" Spacing="6">
                                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE838;"/>

                                                    <TextBlock x:Name="HomeOpenFolderButtonLabel" TextWrapping="WrapWholeWords"/>
                                                </StackPanel>
                                            </Button.Content>
                                        </Button>

                                        <Button Click="OpenPlaylist">
                                            <Button.Content>
                                                <StackPanel Orientation="Horizontal" Spacing="6">
                                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE142;"/>

                                                    <TextBlock x:Name="HomeOpenPlaylistButtonLabel" TextWrapping="WrapWholeWords"/>
                                                </StackPanel>
                                            </Button.Content>
                                        </Button>
                                    </StackPanel>
                                </nickvision:StatusPage.Child>
                            </nickvision:StatusPage>

                            <TextBlock x:Name="LblHomeHelp" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,12" Foreground="Gray" TextWrapping="WrapWholeWords"/>
                        </Grid>
                    </nickvision:ViewStackPage>

                    <nickvision:ViewStackPage PageName="Library">
                        <nickvision:ViewStack x:Name="FilesViewStack" Margin="6,0,0,0">
                            <nickvision:ViewStack.Pages>
                                <nickvision:ViewStackPage PageName="NoFiles">
                                    <nickvision:StatusPage x:Name="StatusPageNoFiles" HorizontalAlignment="Center" VerticalAlignment="Center" Glyph="&#xE93C;"/>
                                </nickvision:ViewStackPage>

                                <nickvision:ViewStackPage PageName="Files">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="360"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>

                                        <Grid Grid.Column="0" RowSpacing="6">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="*"/>
                                            </Grid.RowDefinitions>

                                            <Grid Grid.Row="0" ColumnSpacing="6">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="*"/>
                                                    <ColumnDefinition Width="Auto"/>
                                                </Grid.ColumnDefinitions>

                                                <AutoSuggestBox x:Name="SearchMusicFiles" Grid.Column="0" QueryIcon="Find" TextChanged="SearchMusicFiles_TextChanged"/>

                                                <Button x:Name="BtnAdvancedSearchInfo" Grid.Column="1" Margin="0,0,6,0" VerticalAlignment="Center" Visibility="Collapsed" Click="AdvancedSearchInfo">
                                                    <Button.Content>
                                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE11B;"/>
                                                    </Button.Content>
                                                </Button>
                                            </Grid>

                                            <ListView x:Name="ListMusicFiles" Grid.Row="1" ItemsSource="{x:Bind ListMusicFilesCVS.View, Mode=OneWay}" SelectionMode="Extended" SelectionChanged="ListMusicFiles_SelectionChanged">
                                                <ListView.Resources>
                                                    <CollectionViewSource x:Name="ListMusicFilesCVS" IsSourceGrouped="True"/>
                                                </ListView.Resources>
                                                
                                                <ListView.ItemsPanel>
                                                    <ItemsPanelTemplate>
                                                        <ItemsStackPanel AreStickyGroupHeadersEnabled="False"/>
                                                    </ItemsPanelTemplate>
                                                </ListView.ItemsPanel>

                                                <ListView.GroupStyle>
                                                    <GroupStyle>
                                                        <GroupStyle.HeaderTemplate>
                                                            <DataTemplate>
                                                                <Border Visibility="{Binding TitleVisibility}">
                                                                    <TextBlock Text="{Binding Title}" Style="{ThemeResource NavigationViewItemHeaderTextStyle}"/>
                                                                </Border>
                                                            </DataTemplate>
                                                        </GroupStyle.HeaderTemplate>
                                                    </GroupStyle>
                                                </ListView.GroupStyle>
                                            </ListView>
                                        </Grid>

                                        <Border Grid.Column="1" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1" CornerRadius="8">
                                            <nickvision:ViewStack x:Name="SelectedViewStack" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                                <nickvision:ViewStack.Pages>
                                                    <nickvision:ViewStackPage PageName="NoSelected">
                                                        <nickvision:StatusPage x:Name="StatusPageNoSelected" HorizontalAlignment="Center" VerticalAlignment="Center" Glyph="&#xE14E;"/>
                                                    </nickvision:ViewStackPage>

                                                    <nickvision:ViewStackPage PageName="Selected">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            
                                                            <wct:DockPanel Grid.Row="0" LastChildFill="False">
                                                                <CommandBar wct:DockPanel.Dock="Left" DefaultLabelPosition="Right">
                                                                    <AppBarButton x:Name="CmdBtnSaveTag" Click="SaveTag">
                                                                        <AppBarButton.Icon>
                                                                            <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE105;"/>
                                                                        </AppBarButton.Icon>
                                                                    </AppBarButton>

                                                                    <AppBarButton x:Name="CmdBtnDeleteTag" Click="DeleteTag">
                                                                        <AppBarButton.Icon>
                                                                            <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE107;"/>
                                                                        </AppBarButton.Icon>
                                                                    </AppBarButton>

                                                                    <AppBarButton x:Name="CmdBtnDiscardChanges" Click="DiscardUnappliedChanges">
                                                                        <AppBarButton.Icon>
                                                                            <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE10E;"/>
                                                                        </AppBarButton.Icon>
                                                                    </AppBarButton>

                                                                    <AppBarSeparator/>

                                                                    <AppBarButton x:Name="CmdBtnManageLyrics" Click="ManageLyrics">
                                                                        <AppBarButton.Icon>
                                                                            <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE7BC;"/>
                                                                        </AppBarButton.Icon>
                                                                    </AppBarButton>

                                                                    <AppBarButton x:Name="CmdBtnFilenameToTag" Click="FilenameToTag">
                                                                        <AppBarButton.Icon>
                                                                            <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE13E;"/>
                                                                        </AppBarButton.Icon>
                                                                    </AppBarButton>

                                                                    <AppBarButton x:Name="CmdBtnTagToFilename" Click="TagToFilename">
                                                                        <AppBarButton.Icon>
                                                                            <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE1CB;"/>
                                                                        </AppBarButton.Icon>
                                                                    </AppBarButton>

                                                                    <AppBarButton x:Name="CmdBtnDownloadMusicBrainz" Click="DownloadMusicBrainzMetadata">
                                                                        <AppBarButton.Icon>
                                                                            <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xEBD3;"/>
                                                                        </AppBarButton.Icon>
                                                                    </AppBarButton>
                                                                </CommandBar>

                                                                <CommandBar wct:DockPanel.Dock="Right" DefaultLabelPosition="Right">
                                                                    <AppBarButton x:Name="CmdBtnExtrasPane" Icon="ClosePane" Click="ExtrasPaneToggle"/>
                                                                </CommandBar>
                                                            </wct:DockPanel>

                                                            <MenuFlyoutSeparator Grid.Row="1"/>

                                                            <Grid Grid.Row="2" Margin="12,6,12,6" ColumnSpacing="6">
                                                                <Grid.ColumnDefinitions>
                                                                    <ColumnDefinition Width="*"/>
                                                                    <ColumnDefinition Width="Auto"/>
                                                                    <ColumnDefinition Width="Auto"/>
                                                                </Grid.ColumnDefinitions>

                                                                <ScrollView x:Name="PropertiesPane" Grid.Column="0" SizeChanged="PropertiesPane_SizeChanged">
                                                                    <StackPanel Orientation="Vertical" Spacing="6">
                                                                        <wct:SettingsCard x:Name="CardFilename">
                                                                            <TextBox x:Name="TxtFilename" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <MenuFlyoutSeparator/>

                                                                        <TextBlock x:Name="LblMainProperties" VerticalAlignment="Center" Style="{ThemeResource NavigationViewItemHeaderTextStyle}"/>

                                                                        <wct:SettingsCard x:Name="CardTitle">
                                                                            <TextBox x:Name="TxtTitle" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardArtist">
                                                                            <TextBox x:Name="TxtArtist" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardAlbum">
                                                                            <TextBox x:Name="TxtAlbum" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardAlbumArtist">
                                                                            <TextBox x:Name="TxtAlbumArtist" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardGenre">
                                                                            <AutoSuggestBox x:Name="TxtGenre" MinWidth="300" MaxWidth="400" TextChanged="TxtGenre_TextChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardYear">
                                                                            <TextBox x:Name="TxtYear" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardTrack">
                                                                            <StackPanel Orientation="Horizontal" Spacing="12">
                                                                                <TextBox x:Name="TxtTrack" MinWidth="150" TextChanged="TagPropertyChanged"/>

                                                                                <TextBlock VerticalAlignment="Center" Text="/"/>

                                                                                <TextBox x:Name="TxtTrackTotal" MinWidth="150" TextChanged="TagPropertyChanged"/>
                                                                            </StackPanel>
                                                                        </wct:SettingsCard>

                                                                        <MenuFlyoutSeparator/>

                                                                        <TextBlock x:Name="LblAdditionProperties" Style="{ThemeResource NavigationViewItemHeaderTextStyle}"/>

                                                                        <wct:SettingsCard x:Name="CardComment">
                                                                            <TextBox x:Name="TxtComment" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardBPM">
                                                                            <TextBox x:Name="TxtBPM" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardComposer">
                                                                            <TextBox x:Name="TxtComposer" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardDescription">
                                                                            <TextBox x:Name="TxtDescription" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardDisc">
                                                                            <StackPanel Orientation="Horizontal" Spacing="12">
                                                                                <TextBox x:Name="TxtDiscNumber" MinWidth="150" TextChanged="TagPropertyChanged"/>

                                                                                <TextBlock VerticalAlignment="Center" Text="/"/>

                                                                                <TextBox x:Name="TxtDiscTotal" MinWidth="150" TextChanged="TagPropertyChanged"/>
                                                                            </StackPanel>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardPublisher">
                                                                            <TextBox x:Name="TxtPublisher" MinWidth="300" MaxWidth="400" TextChanged="TagPropertyChanged"/>
                                                                        </wct:SettingsCard>

                                                                        <wct:SettingsCard x:Name="CardPublishingDate">
                                                                            <StackPanel Orientation="Horizontal" Spacing="6">
                                                                                <CalendarDatePicker x:Name="DatePublishingDate" MinWidth="300" MaxWidth="400" DateChanged="DatePublishingDate_DateChanged"/>

                                                                                <Button x:Name="BtnClearPublishingDate" Height="32" Click="ClearPublishingDate">
                                                                                    <Button.Content>
                                                                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE106;"/>
                                                                                    </Button.Content>
                                                                                </Button>
                                                                            </StackPanel>
                                                                        </wct:SettingsCard>

                                                                        <MenuFlyoutSeparator/>

                                                                        <Grid x:Name="CustomPropertiesHeader">
                                                                            <Grid.ColumnDefinitions>
                                                                                <ColumnDefinition Width="*"/>
                                                                                <ColumnDefinition Width="Auto"/>
                                                                            </Grid.ColumnDefinitions>

                                                                            <TextBlock x:Name="LblCustomProperties" Grid.Column="0" VerticalAlignment="Center" Style="{ThemeResource NavigationViewItemHeaderTextStyle}"/>

                                                                            <Button x:Name="BtnAddCustomProperty" Grid.Column="1" Click="AddCustomProperty">
                                                                                <Button.Content>
                                                                                    <StackPanel Orientation="Horizontal" Spacing="6">
                                                                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE710;"/>

                                                                                        <TextBlock x:Name="LblBtnAddCustomProperty" TextWrapping="WrapWholeWords"/>
                                                                                    </StackPanel>
                                                                                </Button.Content>
                                                                            </Button>
                                                                        </Grid>

                                                                        <StackPanel x:Name="ListCustomProperties" Orientation="Vertical" Spacing="6"/>

                                                                        <TextBlock x:Name="LblCustomPropertiesWarning" HorizontalAlignment="Center" Margin="0,-12,0,0" Foreground="Gray" TextWrapping="WrapWholeWords"/>

                                                                        <MenuFlyoutSeparator/>

                                                                        <TextBlock x:Name="LblFileProperties" Style="{ThemeResource NavigationViewItemHeaderTextStyle}"/>

                                                                        <wct:SettingsCard x:Name="CardFingerprint">
                                                                            <StackPanel Orientation="Horizontal" Spacing="6">
                                                                                <TextBlock x:Name="LblFingerprint" VerticalAlignment="Center" Width="300" MaxLines="1"/>

                                                                                <Button x:Name="BtnCopyFingerprint" VerticalAlignment="Center" Margin="6,0,0,0" Click="CopyFingerprintToClipboard">
                                                                                    <Button.Content>
                                                                                        <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE16F;"/>
                                                                                    </Button.Content>
                                                                                </Button>
                                                                            </StackPanel>
                                                                        </wct:SettingsCard>
                                                                    </StackPanel>
                                                                </ScrollView>

                                                                <AppBarSeparator x:Name="DetailsSeparator" Grid.Column="1"/>

                                                                <ScrollView x:Name="ExtrasPane" Grid.Column="2" Width="340">
                                                                    <StackPanel Orientation="Vertical" Spacing="6">
                                                                        <Border HorizontalAlignment="Center" Width="260" Height="260" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1" CornerRadius="8">
                                                                            <nickvision:ViewStack x:Name="ArtViewStack" >
                                                                                <nickvision:ViewStack.Pages>
                                                                                    <nickvision:ViewStackPage PageName="NoImage">
                                                                                        <FontIcon HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="62" Glyph="&#xE158;"/>
                                                                                    </nickvision:ViewStackPage>

                                                                                    <nickvision:ViewStackPage PageName="Image">
                                                                                        <Image x:Name="ImgAlbumArt"/>
                                                                                    </nickvision:ViewStackPage>

                                                                                    <nickvision:ViewStackPage PageName="KeepImage">
                                                                                        <FontIcon HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="62" Glyph="&#xE93C;"/>
                                                                                    </nickvision:ViewStackPage>
                                                                                </nickvision:ViewStack.Pages>
                                                                            </nickvision:ViewStack>
                                                                        </Border>

                                                                        <TextBlock x:Name="LblDurationFileSize" HorizontalAlignment="Center" Style="{ThemeResource NavigationViewItemHeaderTextStyle}" FontSize="16" Foreground="Gray"/>

                                                                        <Button x:Name="BtnAlbumArtSwitch" HorizontalAlignment="Stretch" Margin="0,12,0,0" Click="SwitchAlbumArt">
                                                                            <Button.Content>
                                                                                <StackPanel Orientation="Horizontal" Spacing="6">
                                                                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE13C;"/>

                                                                                    <TextBlock x:Name="LblBtnAlbumArtSwitch"/>
                                                                                </StackPanel>
                                                                            </Button.Content>
                                                                        </Button>

                                                                        <Button x:Name="BtnAlbumArtInsert" HorizontalAlignment="Stretch" Click="InsertAlbumArt">
                                                                            <Button.Content>
                                                                                <StackPanel Orientation="Horizontal" Spacing="6">
                                                                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE710;"/>

                                                                                    <TextBlock x:Name="LblBtnAlbumArtInsert"/>
                                                                                </StackPanel>
                                                                            </Button.Content>
                                                                        </Button>

                                                                        <Button x:Name="BtnAlbumArtRemove" HorizontalAlignment="Stretch" Click="RemoveAlbumArt">
                                                                            <Button.Content>
                                                                                <StackPanel Orientation="Horizontal" Spacing="6">
                                                                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE108;"/>

                                                                                    <TextBlock x:Name="LblBtnAlbumArtRemove"/>
                                                                                </StackPanel>
                                                                            </Button.Content>
                                                                        </Button>

                                                                        <Button x:Name="BtnAlbumArtExport" HorizontalAlignment="Stretch" Click="ExportAlbumArt">
                                                                            <Button.Content>
                                                                                <StackPanel Orientation="Horizontal" Spacing="6">
                                                                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE118;"/>

                                                                                    <TextBlock x:Name="LblBtnAlbumArtExport"/>
                                                                                </StackPanel>
                                                                            </Button.Content>
                                                                        </Button>

                                                                        <Button x:Name="BtnAlbumArtInfo" HorizontalAlignment="Stretch" Click="AlbumArtInfo">
                                                                            <Button.Content>
                                                                                <StackPanel Orientation="Horizontal" Spacing="6">
                                                                                    <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE946;"/>

                                                                                    <TextBlock x:Name="LblBtnAlbumArtInfo"/>
                                                                                </StackPanel>
                                                                            </Button.Content>
                                                                        </Button>
                                                                    </StackPanel>
                                                                </ScrollView>
                                                            </Grid>
                                                        </Grid>
                                                    </nickvision:ViewStackPage>
                                                </nickvision:ViewStack.Pages>
                                            </nickvision:ViewStack>
                                        </Border>
                                    </Grid>
                                </nickvision:ViewStackPage>
                            </nickvision:ViewStack.Pages>
                        </nickvision:ViewStack>
                    </nickvision:ViewStackPage>
                </nickvision:ViewStack.Pages>
            </nickvision:ViewStack>

            <InfoBar x:Name="InfoBar" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,6" CornerRadius="12">
                <InfoBar.ActionButton>
                    <Button x:Name="BtnInfoBar" HorizontalAlignment="Right"/>
                </InfoBar.ActionButton>
            </InfoBar>
        </Grid>

        <Border x:Name="StatusBar" Grid.Row="2" HorizontalAlignment="Stretch" Margin="0,6,0,0" Height="36" Visibility="Collapsed" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1">
            <wct:DockPanel LastChildFill="False">
                <FontIcon x:Name="StatusIcon" wct:DockPanel.Dock="Left" VerticalAlignment="Center" Margin="6,0,10,0" FontFamily="{StaticResource SymbolThemeFontFamily}" FontSize="16" Glyph="&#xE73E;"/>

                <TextBlock x:Name="StatusLabelLeft" wct:DockPanel.Dock="Left" VerticalAlignment="Center"/>

                <TextBlock x:Name="StatusLabelRight" wct:DockPanel.Dock="Right" VerticalAlignment="Center" Margin="0,0,6,0"/>
            </wct:DockPanel>
        </Border>
    </Grid>
</Window>
