<?xml version="1.0" encoding="UTF-8"?>
<Window xmlns="https://github.com/avaloniaui"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:vm="clr-namespace:LibationAvalonia.ViewModels"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:views="clr-namespace:LibationAvalonia.Views"
		xmlns:controls="clr-namespace:LibationAvalonia.Controls"
		mc:Ignorable="d" d:DesignWidth="1850" d:DesignHeight="700"
		x:Class="LibationAvalonia.Views.MainWindow"
		Title="Libation"
		Name="Form1"
		Icon="/Assets/libation.ico">

	<Border BorderBrush="{DynamicResource DataGridGridLinesBrush}" BorderThickness="2" Padding="10,0,10,10">
		<Grid RowDefinitions="Auto,Auto,*,Auto">
			<Grid Grid.Row="0" ColumnDefinitions="1*,Auto">

				<!-- Menu Strip -->
				<Menu Grid.Column="0" VerticalAlignment="Top">
					<!-- Decrease height of menu strop -->
					<Menu.Styles>
						<Style Selector="ItemsPresenter#PART_ItemsPresenter">
							<Setter Property="Height" Value="25"/>
						</Style>
					</Menu.Styles>

					<!-- Import Menu -->
					
					<MenuItem Header="_Import">
						<!-- Remove height style property for menu item -->
						<MenuItem.Styles>
							<Style Selector="ItemsPresenter#PART_ItemsPresenter">
								<Setter Property="Height" Value="NaN"/>
							</Style>
						</MenuItem.Styles>
						<MenuItem IsVisible="{Binding AnyAccounts}" Click="autoScanLibraryToolStripMenuItem_Click" Header="A_uto Scan Library">
							<MenuItem.Icon>
								<CheckBox BorderThickness="0" IsChecked="{Binding AutoScanChecked, Mode=TwoWay}" IsHitTestVisible="False" />
							</MenuItem.Icon>
						</MenuItem>
						<MenuItem IsVisible="{Binding !AnyAccounts}" Click="noAccountsYetAddAccountToolStripMenuItem_Click" Header="No accounts yet. A_dd Account..." />
						
						<!-- Scan Library -->
						<MenuItem IsVisible="{Binding OneAccount}" IsEnabled="{Binding !ActivelyScanning}" Click="scanLibraryToolStripMenuItem_Click" Header="Scan _Library" />
						<MenuItem IsVisible="{Binding MultipleAccounts}" IsEnabled="{Binding !ActivelyScanning}" Click="scanLibraryOfAllAccountsToolStripMenuItem_Click" Header="Scan Library of _All Accounts" />
						<MenuItem IsVisible="{Binding MultipleAccounts}" IsEnabled="{Binding !ActivelyScanning}" Click="scanLibraryOfSomeAccountsToolStripMenuItem_Click" Header="Scan Library of _Some Accounts" />
						<Separator />
						
						<!-- Remove Books -->
						<MenuItem IsVisible="{Binding OneAccount}" IsEnabled="{Binding RemoveMenuItemsEnabled}" Click="removeLibraryBooksToolStripMenuItem_Click" Header="_Remove Library Books" />
						<MenuItem IsVisible="{Binding MultipleAccounts}" IsEnabled="{Binding RemoveMenuItemsEnabled}" Click="removeAllAccountsToolStripMenuItem_Click" Header="_Remove Books from All Accounts" />
						<MenuItem IsVisible="{Binding MultipleAccounts}" IsEnabled="{Binding RemoveMenuItemsEnabled}" Click="removeSomeAccountsToolStripMenuItem_Click" Header="_Remove Books from Some Accounts" />
						
						<Separator />
						<MenuItem Click="locateAudiobooksToolStripMenuItem_Click" Header="L_ocate Audiobooks" />

					</MenuItem>
					
					<!-- Liberate Menu -->

					<MenuItem Header="_Liberate">
						<!-- Remove height style property for menu item -->
						<MenuItem.Styles>
							<Style Selector="ItemsPresenter#PART_ItemsPresenter">
								<Setter Property="Height" Value="NaN"/>
							</Style>
						</MenuItem.Styles>
						<MenuItem Click="beginBookBackupsToolStripMenuItem_Click" Header="{Binding BookBackupsToolStripText}" />
						<MenuItem Click="beginPdfBackupsToolStripMenuItem_Click" Header="{Binding PdfBackupsToolStripText}" />
						<MenuItem Click="convertAllM4bToMp3ToolStripMenuItem_Click" Header="Convert all _M4b to Mp3 [Long-running]..." IsVisible="{Binding IsMp3Supported}" />
						<MenuItem Click="liberateVisible" Header="{Binding LiberateVisibleToolStripText}" IsEnabled="{Binding AnyVisibleNotLiberated}" />
					</MenuItem>

					<!-- Export Menu -->

					<MenuItem Header="E_xport">
						<!-- Remove height style property for menu item -->
						<MenuItem.Styles>
							<Style Selector="ItemsPresenter#PART_ItemsPresenter">
								<Setter Property="Height" Value="NaN"/>
							</Style>
						</MenuItem.Styles>
						<MenuItem IsEnabled="{Binding LibraryStats.HasBookResults}" Click="exportLibraryToolStripMenuItem_Click" Header="E_xport Library" />
					</MenuItem>

					<!-- Quick Filters Menu -->

					<MenuItem Name="quickFiltersToolStripMenuItem" Header="Quick _Filters">
						<!-- Remove height style property for menu item -->
						<MenuItem.Styles>
							<Style Selector="ItemsPresenter#PART_ItemsPresenter">
								<Setter Property="Height" Value="NaN"/>
							</Style>
						</MenuItem.Styles>
						<MenuItem Click="firstFilterIsDefaultToolStripMenuItem_Click" Header="Start Libation with 1st filter _Default">
							<MenuItem.Icon>
								<CheckBox  BorderThickness="0" IsChecked="{Binding FirstFilterIsDefault, Mode=TwoWay}" IsHitTestVisible="False"  />
							</MenuItem.Icon>
						</MenuItem>
						<MenuItem Click="editQuickFiltersToolStripMenuItem_Click" Header="_Edit quick filters..." />
						<Separator />
					</MenuItem>

					<!-- Visible Books Menu -->

					<MenuItem Header="{Binding VisibleCountMenuItemText}" >
						<!-- Remove height style property for menu item -->
						<MenuItem.Styles>
							<Style Selector="ItemsPresenter#PART_ItemsPresenter">
								<Setter Property="Height" Value="NaN"/>
							</Style>
						</MenuItem.Styles>
						<MenuItem Click="liberateVisible" Header="{Binding LiberateVisibleToolStripText_2}" IsEnabled="{Binding AnyVisibleNotLiberated}" />
						<MenuItem Click="replaceTagsToolStripMenuItem_Click" Header="Replace _Tags..." />
						<MenuItem Click="setBookDownloadedManualToolStripMenuItem_Click" Header="Set book '_Downloaded' status manually..." />
						<MenuItem Click="setPdfDownloadedManualToolStripMenuItem_Click" Header="Set _PDF 'Downloaded' status manually..." />
						<MenuItem Click="setDownloadedAutoToolStripMenuItem_Click" Header="Set '_Downloaded' status automatically..." />
						<MenuItem Click="removeToolStripMenuItem_Click" Header="_Remove from library..." />
					</MenuItem>

					<!-- Settings Menu -->

					<MenuItem Header="_Settings">
						<!-- Remove height style property for menu item -->
						<MenuItem.Styles>
							<Style Selector="ItemsPresenter#PART_ItemsPresenter">
								<Setter Property="Height" Value="NaN"/>
							</Style>
						</MenuItem.Styles>
						<MenuItem Click="accountsToolStripMenuItem_Click" Header="_Accounts..." />
						<MenuItem Click="basicSettingsToolStripMenuItem_Click" Header="_Settings..." />
						<Separator />
						<MenuItem Click="openTrashBinToolStripMenuItem_Click" Header="Trash Bin" />
						<MenuItem Click="launchHangoverToolStripMenuItem_Click" Header="Launch _Hangover" />
						<Separator />
						<MenuItem Click="aboutToolStripMenuItem_Click" Header="A_bout..." />
					</MenuItem>
				</Menu>
				<StackPanel IsVisible="{Binding ActivelyScanning}" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
					<Image Width="16" Height="16" Source="/Assets/import_16x16.png" />
					<TextBlock Margin="5,0,5,0" VerticalAlignment="Center" Text="{Binding ScanningText}"/>
				</StackPanel>
			</Grid>

			<!-- Buttons and Search Box -->
			<Grid Grid.Row="1" Margin="0,10,0,10" Height="30" ColumnDefinitions="Auto,*,Auto">

				<Grid.Styles>
					<Style Selector="TextBox">
						<Setter Property="MinHeight" Value="10" />
					</Style>
					<Style Selector="Button">
						<Setter Property="Padding" Value="15,0,15,0" />
						<Setter Property="Margin" Value="10,0,0,0" />
						<Setter Property="Height" Value="30" />
						<Setter Property="HorizontalContentAlignment" Value="Center" />
						<Setter Property="VerticalContentAlignment" Value="Center" />
					</Style>
				</Grid.Styles>
				
				<StackPanel Grid.Column="0" Orientation="Horizontal">
					<Button Margin="0" Click="filterHelpBtn_Click" Content="?"/>
					<Button Click="addQuickFilterBtn_Click" Content="Add To Quick Filters"/>
				</StackPanel>

				<StackPanel Grid.Column="1" Orientation="Horizontal">
					<Button IsVisible="{Binding RemoveButtonsVisible}" IsEnabled="{Binding RemoveBooksButtonEnabled}" Click="removeBooksBtn_Click" Content="{Binding RemoveBooksButtonText}"/>
					<Button IsVisible="{Binding RemoveButtonsVisible}" Click="doneRemovingBtn_Click" Content="Done Removing Books"/>
				</StackPanel>
				
				<TextBox Grid.Column="1" Margin="10,0,0,0" IsVisible="{Binding !RemoveButtonsVisible}" Text="{Binding FilterString, Mode=TwoWay}" KeyDown="filterSearchTb_KeyPress" />

				<StackPanel Grid.Column="2" Height="30" Orientation="Horizontal">
					<Button Click="filterBtn_Click" Height="30" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="Filter"/>
					<Button Padding="5,0,5,0" Click="ToggleQueueHideBtn_Click">
						<Panel>
							<Image Stretch="None" IsVisible="{Binding !QueueOpen}" Source="/Assets/Arrows_left.png" />
							<Image Stretch="None" IsVisible="{Binding QueueOpen}" Source="/Assets/Arrows_right.png" />
						</Panel>
					</Button>
				</StackPanel>

			</Grid>
			<Border Grid.Row="2" BorderThickness="1" BorderBrush="{DynamicResource DataGridGridLinesBrush}">
				<SplitView IsPaneOpen="{Binding QueueOpen}" DisplayMode="Inline" OpenPaneLength="400" MinWidth="400" PanePlacement="Right">

					<!-- Process Queue -->
					<SplitView.Pane>
						<views:ProcessQueueControl DataContext="{Binding ProcessQueue}"/>
					</SplitView.Pane>

					<!-- Product Display Grid -->
					<views:ProductsDisplay
						Name="productsDisplay"
						DataContext="{Binding ProductsDisplay}"						
						LiberateClicked="ProductsDisplay_LiberateClicked"
						LiberateSeriesClicked="ProductsDisplay_LiberateSeriesClicked"
						ConvertToMp3Clicked="ProductsDisplay_ConvertToMp3Clicked" />				
				</SplitView>
			</Border>

			<!-- Bottom Status Strip -->
			<Grid Grid.Row="3" Margin="0,10,0,0" VerticalAlignment="Bottom" ColumnDefinitions="Auto,Auto,*,Auto">
				<Grid.Styles>
					<Style Selector="ProgressBar:horizontal">
						<Setter Property="MinWidth" Value="100" />
					</Style>
				</Grid.Styles>
				<TextBlock FontSize="14" Grid.Column="0" Text="Upgrading:" VerticalAlignment="Center" IsVisible="{Binding DownloadProgress, Converter={x:Static ObjectConverters.IsNotNull}}" />
				<ProgressBar Grid.Column="1" Margin="5,0,10,0" VerticalAlignment="Stretch" Width="100" Value="{Binding DownloadProgress}" IsVisible="{Binding DownloadProgress, Converter={x:Static ObjectConverters.IsNotNull}}"/>
				<TextBlock FontSize="14" Grid.Column="2" Text="{Binding VisibleCountText}" VerticalAlignment="Center" />
				<TextBlock FontSize="14" Grid.Column="3" Text="{Binding LibraryStats.StatusString}" VerticalAlignment="Center" />		
			</Grid>
		</Grid>
	</Border>
</Window>
