Fix hidden tag

This commit is contained in:
Michael Bucari-Tovo 2022-12-13 02:42:53 -07:00
parent f39d272e6a
commit 6fbd90a6b3
7 changed files with 59 additions and 66 deletions

View File

@ -1,8 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Styles.Resources> <Styles.Resources>
<Color x:Key="SeriesEntryGridBackgroundColor">#FFE6FFE6</Color> <Color x:Key="SeriesEntryGridBackgroundColor">#cdffcd</Color>
<SolidColorBrush x:Key="SeriesEntryGridBackgroundBrush" Color="{StaticResource SeriesEntryGridBackgroundColor}" /> <SolidColorBrush x:Key="SeriesEntryGridBackgroundBrush" Opacity="0.5" Color="{StaticResource SeriesEntryGridBackgroundColor}" />
<SolidColorBrush x:Key="ProcessQueueBookFailedBrush" Color="LightCoral" /> <SolidColorBrush x:Key="ProcessQueueBookFailedBrush" Color="LightCoral" />
<SolidColorBrush x:Key="ProcessQueueBookCompletedBrush" Color="PaleGreen" /> <SolidColorBrush x:Key="ProcessQueueBookCompletedBrush" Color="PaleGreen" />
<SolidColorBrush x:Key="ProcessQueueBookCancelledBrush" Color="Khaki" /> <SolidColorBrush x:Key="ProcessQueueBookCancelledBrush" Color="Khaki" />

View File

@ -7,10 +7,10 @@ using System.Reflection;
namespace LibationAvalonia.Controls namespace LibationAvalonia.Controls
{ {
public class DataGridViewCellContextMenuStripNeededEventArgs public class DataGridCellContextMenuStripNeededEventArgs
{ {
private static readonly MethodInfo GetCellValueMethod; private static readonly MethodInfo GetCellValueMethod;
static DataGridViewCellContextMenuStripNeededEventArgs() static DataGridCellContextMenuStripNeededEventArgs()
{ {
GetCellValueMethod = typeof(DataGridColumn).GetMethod("GetCellValue", BindingFlags.NonPublic | BindingFlags.Instance); GetCellValueMethod = typeof(DataGridColumn).GetMethod("GetCellValue", BindingFlags.NonPublic | BindingFlags.Instance);
} }
@ -28,7 +28,7 @@ namespace LibationAvalonia.Controls
public partial class DataGridTemplateColumnExt : DataGridTemplateColumn public partial class DataGridTemplateColumnExt : DataGridTemplateColumn
{ {
public event EventHandler<DataGridViewCellContextMenuStripNeededEventArgs> CellContextMenuStripNeeded; public event EventHandler<DataGridCellContextMenuStripNeededEventArgs> CellContextMenuStripNeeded;
private static readonly ContextMenu ContextMenu = new(); private static readonly ContextMenu ContextMenu = new();
private static readonly AvaloniaList<MenuItem> MenuItems = new(); private static readonly AvaloniaList<MenuItem> MenuItems = new();
@ -43,7 +43,7 @@ namespace LibationAvalonia.Controls
{ {
if (sender is DataGridCell cell && cell.DataContext is GridEntry entry) if (sender is DataGridCell cell && cell.DataContext is GridEntry entry)
{ {
var args = new DataGridViewCellContextMenuStripNeededEventArgs var args = new DataGridCellContextMenuStripNeededEventArgs
{ {
Column = this, Column = this,
GridEntry = entry, GridEntry = entry,

View File

@ -51,7 +51,8 @@ namespace LibationAvalonia.ViewModels
public abstract bool IsSeries { get; } public abstract bool IsSeries { get; }
public abstract bool IsEpisode { get; } public abstract bool IsEpisode { get; }
public abstract bool IsBook { get; } public abstract bool IsBook { get; }
public IBrush BackgroundBrush => IsEpisode ? App.SeriesEntryGridBackgroundBrush : null; public abstract double Opacity { get; }
public IBrush BackgroundBrush => IsEpisode ? App.SeriesEntryGridBackgroundBrush : Brushes.Transparent;
#endregion #endregion

View File

@ -53,6 +53,7 @@ namespace LibationAvalonia.ViewModels
public override bool IsSeries => false; public override bool IsSeries => false;
public override bool IsEpisode => Parent is not null; public override bool IsEpisode => Parent is not null;
public override bool IsBook => Parent is null; public override bool IsBook => Parent is null;
public override double Opacity => Book.UserDefinedItem.Tags.ToLower().Contains("hidden") ? 0.4 : 1;
#endregion #endregion
@ -99,6 +100,7 @@ namespace LibationAvalonia.ViewModels
case nameof(udi.Tags): case nameof(udi.Tags):
Book.UserDefinedItem.Tags = udi.Tags; Book.UserDefinedItem.Tags = udi.Tags;
this.RaisePropertyChanged(nameof(BookTags)); this.RaisePropertyChanged(nameof(BookTags));
this.RaisePropertyChanged(nameof(Opacity));
break; break;
case nameof(udi.BookStatus): case nameof(udi.BookStatus):
Book.UserDefinedItem.BookStatus = udi.BookStatus; Book.UserDefinedItem.BookStatus = udi.BookStatus;

View File

@ -50,6 +50,7 @@ namespace LibationAvalonia.ViewModels
public override bool IsSeries => true; public override bool IsSeries => true;
public override bool IsEpisode => false; public override bool IsEpisode => false;
public override bool IsBook => false; public override bool IsBook => false;
public override double Opacity => 1;
#endregion #endregion

View File

@ -15,9 +15,22 @@
GridLinesVisibility="All" GridLinesVisibility="All"
AutoGenerateColumns="False" AutoGenerateColumns="False"
Items="{Binding GridEntries}" Items="{Binding GridEntries}"
CanUserSortColumns="True" CanUserSortColumns="True" BorderThickness="3"
CanUserReorderColumns="True"> CanUserReorderColumns="True">
<DataGrid.Styles>
<Style Selector="DataGridCell > Panel">
<Setter Property="Margin" Value="0,1,0,1"/>
<Setter Property="Height" Value="80"/>
</Style>
<Style Selector="DataGridCell > Panel > TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="Padding" Value="4"/>
</Style>
</DataGrid.Styles>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTemplateColumn <DataGridTemplateColumn
@ -42,8 +55,8 @@
<controls:DataGridTemplateColumnExt CanUserSort="True" Width="75" Header="Liberate" SortMemberPath="Liberate" ClipboardContentBinding="{Binding Liberate.ToolTip}"> <controls:DataGridTemplateColumnExt CanUserSort="True" Width="75" Header="Liberate" SortMemberPath="Liberate" ClipboardContentBinding="{Binding Liberate.ToolTip}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Button Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="LiberateButton_Click" ToolTip.Tip="{Binding Liberate.ToolTip}"> <Button Opacity="{Binding Opacity}" Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="LiberateButton_Click" ToolTip.Tip="{Binding Liberate.ToolTip}">
<Image Stretch="None" Source="{Binding Liberate.Image}" /> <Image Source="{Binding Liberate.Image}" Stretch="None" />
</Button> </Button>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -52,7 +65,7 @@
<DataGridTemplateColumn CanUserSort="False" Width="80" Header="Cover" SortMemberPath="Cover" ClipboardContentBinding="{Binding LibraryBook.Book.PictureLarge}"> <DataGridTemplateColumn CanUserSort="False" Width="80" Header="Cover" SortMemberPath="Cover" ClipboardContentBinding="{Binding LibraryBook.Book.PictureLarge}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Image Tapped="Cover_Click" Height="80" Source="{Binding Cover}" ToolTip.Tip="Click to see full size" /> <Image Opacity="{Binding Opacity}" Tapped="Cover_Click" Height="80" Source="{Binding Cover}" ToolTip.Tip="Click to see full size" />
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
@ -60,10 +73,8 @@
<controls:DataGridTemplateColumnExt MinWidth="150" Width="2*" Header="Title" CanUserSort="True" SortMemberPath="Title" ClipboardContentBinding="{Binding Title}"> <controls:DataGridTemplateColumnExt MinWidth="150" Width="2*" Header="Title" CanUserSort="True" SortMemberPath="Title" ClipboardContentBinding="{Binding Title}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border Background="{Binding BackgroundBrush}" BorderThickness="3" Height="80"> <TextBlock Text="{Binding Title}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Title}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -72,10 +83,8 @@
<controls:DataGridTemplateColumnExt MinWidth="80" Width="1*" Header="Authors" CanUserSort="True" SortMemberPath="Authors" ClipboardContentBinding="{Binding Authors}"> <controls:DataGridTemplateColumnExt MinWidth="80" Width="1*" Header="Authors" CanUserSort="True" SortMemberPath="Authors" ClipboardContentBinding="{Binding Authors}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding Authors}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Authors}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -84,10 +93,8 @@
<controls:DataGridTemplateColumnExt MinWidth="80" Width="1*" Header="Narrators" CanUserSort="True" SortMemberPath="Narrators" ClipboardContentBinding="{Binding Narrators}"> <controls:DataGridTemplateColumnExt MinWidth="80" Width="1*" Header="Narrators" CanUserSort="True" SortMemberPath="Narrators" ClipboardContentBinding="{Binding Narrators}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding Narrators}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Narrators}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -96,10 +103,8 @@
<controls:DataGridTemplateColumnExt Width="90" Header="Length" CanUserSort="True" SortMemberPath="Length" ClipboardContentBinding="{Binding Length}"> <controls:DataGridTemplateColumnExt Width="90" Header="Length" CanUserSort="True" SortMemberPath="Length" ClipboardContentBinding="{Binding Length}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding Length}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Length}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -108,10 +113,8 @@
<controls:DataGridTemplateColumnExt MinWidth="80" Width="1*" Header="Series" CanUserSort="True" SortMemberPath="Series" ClipboardContentBinding="{Binding Series}"> <controls:DataGridTemplateColumnExt MinWidth="80" Width="1*" Header="Series" CanUserSort="True" SortMemberPath="Series" ClipboardContentBinding="{Binding Series}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding Series}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Series}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -120,10 +123,8 @@
<controls:DataGridTemplateColumnExt MinWidth="100" Width="1*" Header="Description" CanUserSort="True" SortMemberPath="Description" ClipboardContentBinding="{Binding LongDescription}"> <controls:DataGridTemplateColumnExt MinWidth="100" Width="1*" Header="Description" CanUserSort="True" SortMemberPath="Description" ClipboardContentBinding="{Binding LongDescription}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}" Tapped="Description_Click" ToolTip.Tip="Click to see full description" >
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding Description}" />
<TextBlock Tapped="Description_Click" VerticalAlignment="Center" TextWrapping="Wrap" ToolTip.Tip="Click to see full description" Text="{Binding Description}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -132,10 +133,8 @@
<controls:DataGridTemplateColumnExt Width="100" Header="Category" CanUserSort="True" SortMemberPath="Category" ClipboardContentBinding="{Binding Category}"> <controls:DataGridTemplateColumnExt Width="100" Header="Category" CanUserSort="True" SortMemberPath="Category" ClipboardContentBinding="{Binding Category}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding Category}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Category}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -144,10 +143,8 @@
<controls:DataGridTemplateColumnExt Width="120" Header="Product&#xA;Rating" CanUserSort="True" SortMemberPath="ProductRating" ClipboardContentBinding="{Binding ProductRating}"> <controls:DataGridTemplateColumnExt Width="120" Header="Product&#xA;Rating" CanUserSort="True" SortMemberPath="ProductRating" ClipboardContentBinding="{Binding ProductRating}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding ProductRating}" TextWrapping="NoWrap" FontSize="11" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" Text="{Binding ProductRating}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -156,10 +153,8 @@
<controls:DataGridTemplateColumnExt Width="90" Header="Purchase&#xA;Date" CanUserSort="True" SortMemberPath="PurchaseDate" ClipboardContentBinding="{Binding PurchaseDate}"> <controls:DataGridTemplateColumnExt Width="90" Header="Purchase&#xA;Date" CanUserSort="True" SortMemberPath="PurchaseDate" ClipboardContentBinding="{Binding PurchaseDate}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding PurchaseDate}" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding PurchaseDate}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -168,10 +163,8 @@
<controls:DataGridTemplateColumnExt Width="120" Header="My Rating" CanUserSort="True" SortMemberPath="MyRating" ClipboardContentBinding="{Binding MyRating}"> <controls:DataGridTemplateColumnExt Width="120" Header="My Rating" CanUserSort="True" SortMemberPath="MyRating" ClipboardContentBinding="{Binding MyRating}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding MyRating}" TextWrapping="NoWrap" FontSize="11" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" Text="{Binding MyRating}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -180,10 +173,8 @@
<controls:DataGridTemplateColumnExt Width="135" Header="Misc" CanUserSort="True" SortMemberPath="Misc" ClipboardContentBinding="{Binding Misc}"> <controls:DataGridTemplateColumnExt Width="135" Header="Misc" CanUserSort="True" SortMemberPath="Misc" ClipboardContentBinding="{Binding Misc}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Panel Background="{Binding BackgroundBrush}"> <Panel Background="{Binding BackgroundBrush}" Opacity="{Binding Opacity}">
<Border BorderThickness="3" Height="80"> <TextBlock Text="{Binding Misc}" TextWrapping="WrapWithOverflow" FontSize="10" />
<TextBlock VerticalAlignment="Center" TextWrapping="WrapWithOverflow" FontSize="10" Text="{Binding Misc}" />
</Border>
</Panel> </Panel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -192,14 +183,12 @@
<controls:DataGridTemplateColumnExt CanUserSort="True" Width="100" Header="Tags" SortMemberPath="BookTags" ClipboardContentBinding="{Binding BookTags.Tags}"> <controls:DataGridTemplateColumnExt CanUserSort="True" Width="100" Header="Tags" SortMemberPath="BookTags" ClipboardContentBinding="{Binding BookTags.Tags}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<StackPanel Orientation="Horizontal"> <Button IsVisible="{Binding !IsSeries}" Width="100" Height="80" Click="OnTagsButtonClick" ToolTip.Tip="Click to edit tags" >
<Button IsVisible="{Binding !IsSeries}" Width="100" Height="80" Click="OnTagsButtonClick" ToolTip.Tip="Click to edit tags" > <Panel>
<Panel> <Image IsVisible="{Binding !BookTags.HasTags}" Stretch="None" Source="/Assets/edit_25x25.png" />
<Image IsVisible="{Binding !BookTags.HasTags}" Stretch="None" Source="/Assets/edit_25x25.png" /> <TextBlock IsVisible="{Binding BookTags.HasTags}" FontSize="12" TextWrapping="WrapWithOverflow" Text="{Binding BookTags.Tags}"/>
<TextBlock IsVisible="{Binding BookTags.HasTags}" FontSize="12" TextWrapping="WrapWithOverflow" Text="{Binding BookTags.Tags}"/> </Panel>
</Panel> </Button>
</Button>
</StackPanel>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</controls:DataGridTemplateColumnExt> </controls:DataGridTemplateColumnExt>

View File

@ -73,7 +73,7 @@ namespace LibationAvalonia.Views
#region Cell Context Menu #region Cell Context Menu
public void ProductsGrid_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs args) public void ProductsGrid_CellContextMenuStripNeeded(object sender, DataGridCellContextMenuStripNeededEventArgs args)
{ {
if (args.Column.SortMemberPath == "Liberate") if (args.Column.SortMemberPath == "Liberate")
{ {
@ -277,9 +277,9 @@ namespace LibationAvalonia.Views
public void Description_Click(object sender, Avalonia.Input.TappedEventArgs args) public void Description_Click(object sender, Avalonia.Input.TappedEventArgs args)
{ {
if (sender is TextBlock tblock && tblock.DataContext is GridEntry gEntry) if (sender is Control tblock && tblock.DataContext is GridEntry gEntry)
{ {
var pt = tblock.Parent.PointToScreen(tblock.Parent.Bounds.TopRight); var pt = tblock.PointToScreen(tblock.Bounds.TopRight);
var displayWindow = new DescriptionDisplayDialog var displayWindow = new DescriptionDisplayDialog
{ {
SpawnLocation = new Point(pt.X, pt.Y), SpawnLocation = new Point(pt.X, pt.Y),