<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
			 xmlns:vm="clr-namespace:LibationUiBase.ProcessQueue;assembly=LibationUiBase"
			 xmlns:views="clr-namespace:LibationAvalonia.Views"
			 x:DataType="vm:ProcessBookViewModel"
             mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="87" MaxHeight="87" MinHeight="87" MinWidth="300"
			 x:Class="LibationAvalonia.Views.ProcessBookControl">

	<UserControl.Styles>
		<Style Selector="Border#QueuedItemBorder:not(:pointerover) Button">
			<Setter Property="IsVisible" Value="False" />
		</Style>
		<Style Selector="Border#QueuedItemBorder:pointerover Button">
			<Setter Property="IsVisible" Value="True" />
		</Style>
		<Style Selector="views|ProcessBookControl">
			<Setter Property="ProcessBookStatus" Value="{CompiledBinding Status}" />
			<Style Selector="^[ProcessBookStatus=Cancelled]">
				<Setter Property="Background" Value="{DynamicResource ProcessQueueBookCancelledBrush}" />
			</Style>
			<Style Selector="^[ProcessBookStatus=Failed]">
				<Setter Property="Background" Value="{DynamicResource ProcessQueueBookFailedBrush}" />
			</Style>
			<Style Selector="^[ProcessBookStatus=Completed]">
				<Setter Property="Background" Value="{DynamicResource ProcessQueueBookCompletedBrush}" />
			</Style>
		</Style>
	</UserControl.Styles>

	<Border Name="QueuedItemBorder" Background="Transparent" BorderBrush="{DynamicResource SystemControlForegroundBaseMediumBrush}" BorderThickness="0,0,0,1">

		<Grid ColumnDefinitions="Auto,*,Auto">

			<Panel Grid.Column="0" Margin="3" Width="80" Height="80" HorizontalAlignment="Left">
				<Image Width="80" Height="80" Source="{CompiledBinding Cover}" Stretch="Uniform" />
			</Panel>
			<Grid Margin="0,3,0,3" Grid.Column="1" ColumnDefinitions="*" RowDefinitions="*,16">
				<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Vertical">
					<TextBlock ClipToBounds="True" TextWrapping="Wrap" FontSize="11" Text="{CompiledBinding Title}" />
					<TextBlock FontSize="10" TextWrapping="NoWrap" Text="{CompiledBinding Author}" />
					<TextBlock FontSize="10" TextWrapping="NoWrap" Text="{CompiledBinding Narrator}" />
				</StackPanel>
				<Panel Grid.Column="0" Grid.Row="1">
					<Panel.Styles>
						<Style Selector="ProgressBar:horizontal">
							<Setter Property="MinWidth" Value="20" />
						</Style>
					</Panel.Styles>
					<ProgressBar IsVisible="{CompiledBinding IsDownloading}" Value="{CompiledBinding Progress}" ShowProgressText="True" FontSize="12" />
					<TextBlock IsVisible="{CompiledBinding !IsDownloading}" Text="{CompiledBinding StatusText}"/>
				</Panel>
			</Grid>
			<Grid Name="ButtonsGrid" Margin="3" Grid.Column="2" HorizontalAlignment="Right" ColumnDefinitions="Auto,Auto">
				<Grid.Styles>
					<Style Selector="Button">
						<Setter Property="Padding" Value="0,1" />
						<Setter Property="Height" Value="20" />
						<Setter Property="Width" Value="30" />
						<Style Selector="^ > Path">
							<Setter Property="Stretch" Value="Uniform" />
							<Setter Property="Fill" Value="{DynamicResource IconFill}" />
						</Style>
					</Style>
				</Grid.Styles>
				<StackPanel IsVisible="{CompiledBinding Queued}" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Vertical">

					<Button ToolTip.Tip="Move book to top of queue" Click="MoveFirst_Click">
						<Path VerticalAlignment="Top" Data="{StaticResource	FirstButtonIcon}" />
					</Button>
					<Button ToolTip.Tip="Move book up in queue" Click="MoveUp_Click">
						<Path VerticalAlignment="Top" Data="{StaticResource	UpButtonIcon}" />
					</Button>
					<Button ToolTip.Tip="Move book down in queue" Click="MoveDown_Click">
						<Path VerticalAlignment="Bottom" Data="{StaticResource	DownButtonIcon}" />
					</Button>
					<Button ToolTip.Tip="Move book to bottom of queue" Click="MoveLast_Click">
						<Path VerticalAlignment="Bottom" Data="{StaticResource	LastButtonIcon}" />
					</Button>
				</StackPanel>
				<Panel Margin="3,0,0,0" Grid.Column="1" VerticalAlignment="Top" IsVisible="{CompiledBinding !IsFinished}">
					<Button Height="32" Background="{DynamicResource CancelRed}" Width="22" CornerRadius="11" Click="Cancel_Click">
						<Path Fill="{DynamicResource SystemAltHighColor}" VerticalAlignment="Center" Data="{StaticResource CancelButtonIcon}" RenderTransform="{StaticResource Rotate45Transform}" />
					</Button>
				</Panel>
			</Grid>
			<Panel Margin="3" Width="50" Grid.Column="2">
				<TextPresenter FontSize="9" VerticalAlignment="Bottom" HorizontalAlignment="Right" IsVisible="{CompiledBinding IsDownloading}" Text="{CompiledBinding ETA}" />
			</Panel>

		</Grid>
	</Border>
</UserControl>
