Improve GridView

- Remove LongDescription
- Description has the full description
- Better MyRating updating
This commit is contained in:
Mbucari 2023-07-18 16:18:01 -06:00
parent b94f9bbc15
commit 914e574bf8
5 changed files with 7 additions and 12 deletions

View File

@ -148,7 +148,7 @@
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</controls:DataGridTemplateColumnExt> </controls:DataGridTemplateColumnExt>
<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 Description}">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="uibase:IGridEntry"> <DataTemplate x:DataType="uibase:IGridEntry">
<Panel Opacity="{CompiledBinding Liberate.Opacity}" Background="{CompiledBinding Liberate.BackgroundBrush}" Tapped="Description_Click" ToolTip.Tip="Click to see full description" > <Panel Opacity="{CompiledBinding Liberate.Opacity}" Background="{CompiledBinding Liberate.BackgroundBrush}" Tapped="Description_Click" ToolTip.Tip="Click to see full description" >

View File

@ -536,7 +536,7 @@ namespace LibationAvalonia.Views
var displayWindow = new DescriptionDisplayDialog var displayWindow = new DescriptionDisplayDialog
{ {
SpawnLocation = new Point(pt.X, pt.Y), SpawnLocation = new Point(pt.X, pt.Y),
DescriptionText = gEntry.LongDescription, DescriptionText = gEntry.Description,
}; };
void CloseWindow(object o, DataGridRowEventArgs e) void CloseWindow(object o, DataGridRowEventArgs e)

View File

@ -27,7 +27,6 @@ namespace LibationUiBase.GridView
[Browsable(false)] public string AudibleProductId => Book.AudibleProductId; [Browsable(false)] public string AudibleProductId => Book.AudibleProductId;
[Browsable(false)] public LibraryBook LibraryBook { get; protected set; } [Browsable(false)] public LibraryBook LibraryBook { get; protected set; }
[Browsable(false)] public float SeriesIndex { get; protected set; } [Browsable(false)] public float SeriesIndex { get; protected set; }
[Browsable(false)] public string LongDescription { get; protected set; }
[Browsable(false)] public abstract DateTime DateAdded { get; } [Browsable(false)] public abstract DateTime DateAdded { get; }
[Browsable(false)] public Book Book => LibraryBook.Book; [Browsable(false)] public Book Book => LibraryBook.Book;
@ -109,9 +108,7 @@ namespace LibationUiBase.GridView
Series = Book.SeriesNames(includeIndex: true); Series = Book.SeriesNames(includeIndex: true);
SeriesOrder = new SeriesOrder(Book.SeriesLink); SeriesOrder = new SeriesOrder(Book.SeriesLink);
Length = GetBookLengthString(); Length = GetBookLengthString();
//Ratings are changed using Update(), which is a problem for Avalonia data bindings because RaiseAndSetIfChanged(ref _myRating, Book.UserDefinedItem.Rating, nameof(MyRating));
//the reference doesn't change. Clone the rating so that it updates within Avalonia properly.
_myRating = new Rating(Book.UserDefinedItem.Rating.OverallRating, Book.UserDefinedItem.Rating.PerformanceRating, Book.UserDefinedItem.Rating.StoryRating);
PurchaseDate = GetPurchaseDateString(); PurchaseDate = GetPurchaseDateString();
ProductRating = Book.Rating ?? new Rating(0, 0, 0); ProductRating = Book.Rating ?? new Rating(0, 0, 0);
Authors = Book.AuthorNames(); Authors = Book.AuthorNames();
@ -119,13 +116,10 @@ namespace LibationUiBase.GridView
Category = string.Join(", ", Book.LowestCategoryNames()); Category = string.Join(", ", Book.LowestCategoryNames());
Misc = GetMiscDisplay(libraryBook); Misc = GetMiscDisplay(libraryBook);
LastDownload = new(Book.UserDefinedItem); LastDownload = new(Book.UserDefinedItem);
LongDescription = GetDescriptionDisplay(Book); Description = GetDescriptionDisplay(Book);
Description = LongDescription;// TrimTextToWord(LongDescription, 62);
SeriesIndex = Book.SeriesLink.FirstOrDefault()?.Index ?? 0; SeriesIndex = Book.SeriesLink.FirstOrDefault()?.Index ?? 0;
BookTags = GetBookTags(); BookTags = GetBookTags();
RaisePropertyChanged(nameof(MyRating));
UserDefinedItem.ItemChanged += UserDefinedItem_ItemChanged; UserDefinedItem.ItemChanged += UserDefinedItem_ItemChanged;
} }
@ -182,6 +176,8 @@ namespace LibationUiBase.GridView
break; break;
case nameof(udi.Rating): case nameof(udi.Rating):
_myRating = udi.Rating; _myRating = udi.Rating;
//Ratings are changed using Update(), which is a problem for Avalonia data bindings because
//the reference doesn't change. Must call RaisePropertyChanged instead of RaiseAndSetIfChanged
RaisePropertyChanged(nameof(MyRating)); RaisePropertyChanged(nameof(MyRating));
break; break;
} }

View File

@ -10,7 +10,6 @@ namespace LibationUiBase.GridView
EntryStatus Liberate { get; } EntryStatus Liberate { get; }
float SeriesIndex { get; } float SeriesIndex { get; }
string AudibleProductId { get; } string AudibleProductId { get; }
string LongDescription { get; }
LibraryBook LibraryBook { get; } LibraryBook LibraryBook { get; }
Book Book { get; } Book Book { get; }
DateTime DateAdded { get; } DateTime DateAdded { get; }

View File

@ -75,7 +75,7 @@ namespace LibationWinForms.GridView
var displayWindow = new DescriptionDisplay var displayWindow = new DescriptionDisplay
{ {
SpawnLocation = PointToScreen(cellRectangle.Location + new Size(cellRectangle.Width, 0)), SpawnLocation = PointToScreen(cellRectangle.Location + new Size(cellRectangle.Width, 0)),
DescriptionText = liveGridEntry.LongDescription, DescriptionText = liveGridEntry.Description,
BorderThickness = 2, BorderThickness = 2,
}; };