From 952173d450069a41d49e56645868c8ad09141251 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Sat, 16 Jul 2022 15:06:37 -0600 Subject: [PATCH] Added book details dialog --- .../AvaloniaUI/Controls/GroupBox.axaml | 55 ++++++ .../AvaloniaUI/Controls/GroupBox.axaml.cs | 38 +++++ .../AvaloniaUI/FormSaveExtension2.cs | 4 +- .../LibationWinForms/AvaloniaUI/MessageBox.cs | 4 +- .../ViewModels/ProcessQueueViewModel.cs | 54 ------ .../ViewModels/ProductsDisplayViewModel.cs | 21 +-- .../Views/Dialogs/BookDetailsDialog2.axaml | 130 +++++++++++++++ .../Views/Dialogs/BookDetailsDialog2.axaml.cs | 157 ++++++++++++++++++ .../MainWindow.VisibleBooks.axaml.cs | 3 +- .../Views/MainWindow/MainWindow.axaml.cs | 7 + .../Views/ProcessBookControl2.axaml.cs | 12 ++ .../Views/ProcessQueueControl2.axaml.cs | 66 +++++++- .../Views/ProductsDisplay2.axaml.cs | 37 ++++- .../LibationWinForms/LibationWinForms.csproj | 7 + Source/LibationWinForms/Program.cs | 6 +- .../PublishProfiles/FolderProfile.pubxml | 3 +- 16 files changed, 516 insertions(+), 88 deletions(-) create mode 100644 Source/LibationWinForms/AvaloniaUI/Controls/GroupBox.axaml create mode 100644 Source/LibationWinForms/AvaloniaUI/Controls/GroupBox.axaml.cs create mode 100644 Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog2.axaml create mode 100644 Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog2.axaml.cs diff --git a/Source/LibationWinForms/AvaloniaUI/Controls/GroupBox.axaml b/Source/LibationWinForms/AvaloniaUI/Controls/GroupBox.axaml new file mode 100644 index 00000000..f6395f35 --- /dev/null +++ b/Source/LibationWinForms/AvaloniaUI/Controls/GroupBox.axaml @@ -0,0 +1,55 @@ + + + + + + + + + + diff --git a/Source/LibationWinForms/AvaloniaUI/Controls/GroupBox.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Controls/GroupBox.axaml.cs new file mode 100644 index 00000000..094e8a3e --- /dev/null +++ b/Source/LibationWinForms/AvaloniaUI/Controls/GroupBox.axaml.cs @@ -0,0 +1,38 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace LibationWinForms.AvaloniaUI.Controls +{ + public partial class GroupBox : ContentControl + { + + public static readonly StyledProperty BorderWidthProperty = + AvaloniaProperty.Register(nameof(BorderWidth)); + + public static readonly StyledProperty LabelProperty = + AvaloniaProperty.Register(nameof(Label)); + public GroupBox() + { + InitializeComponent(); + BorderWidth = new Thickness(3); + Label = "This is a groupbox label"; + } + public Thickness BorderWidth + { + get { return GetValue(BorderWidthProperty); } + set { SetValue(BorderWidthProperty, value); } + } + + public string Label + { + get { return GetValue(LabelProperty); } + set { SetValue(LabelProperty, value); } + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/Source/LibationWinForms/AvaloniaUI/FormSaveExtension2.cs b/Source/LibationWinForms/AvaloniaUI/FormSaveExtension2.cs index 0f3bfd8d..d595f2b3 100644 --- a/Source/LibationWinForms/AvaloniaUI/FormSaveExtension2.cs +++ b/Source/LibationWinForms/AvaloniaUI/FormSaveExtension2.cs @@ -24,7 +24,7 @@ namespace LibationWinForms.AvaloniaUI public static void RestoreSizeAndLocation(this Window form, Configuration config) { - FormSizeAndPosition savedState = config.GetNonString(form.Name); + FormSizeAndPosition savedState = config.GetNonString(form.GetType().Name); if (savedState is null) return; @@ -79,7 +79,7 @@ namespace LibationWinForms.AvaloniaUI saveState.Width = (int)form.Bounds.Size.Width; saveState.Height = (int)form.Bounds.Size.Height; - config.SetObject(form.Name, saveState); + config.SetObject(form.GetType().Name, saveState); } class FormSizeAndPosition diff --git a/Source/LibationWinForms/AvaloniaUI/MessageBox.cs b/Source/LibationWinForms/AvaloniaUI/MessageBox.cs index 52b50202..9583bcee 100644 --- a/Source/LibationWinForms/AvaloniaUI/MessageBox.cs +++ b/Source/LibationWinForms/AvaloniaUI/MessageBox.cs @@ -201,7 +201,7 @@ namespace LibationWinForms.AvaloniaUI return await ShowCore(owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); } - public static async Task ShowConfirmationDialog(Window owner, IEnumerable libraryBooks, string format, string title) + public static async Task ShowConfirmationDialog(Window owner, IEnumerable libraryBooks, string format, string title, MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1) { if (libraryBooks is null || !libraryBooks.Any()) return DialogResult.Cancel; @@ -221,7 +221,7 @@ namespace LibationWinForms.AvaloniaUI title, MessageBoxButtons.YesNo, MessageBoxIcon.Question, - MessageBoxDefaultButton.Button1); + defaultButton); } private static async Task ShowCore(Window owner, string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs index 80b0eee7..6351c46c 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessQueueViewModel.cs @@ -28,60 +28,6 @@ namespace LibationWinForms.AvaloniaUI.ViewModels Queue.QueuededCountChanged += Queue_QueuededCountChanged; Queue.CompletedCountChanged += Queue_CompletedCountChanged; Logger = ProcessQueue.LogMe.RegisterForm(this); - - #region Design Mode Testing - if (Design.IsDesignMode) - { - using var context = DbContexts.GetContext(); - var book = context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"); - List testList = new() - { - new ProcessBook2(book, Logger) - { - Result = ProcessBookResult.FailedAbort, - Status = ProcessBookStatus.Failed, - }, - new ProcessBook2(book, Logger) - { - Result = ProcessBookResult.FailedSkip, - Status = ProcessBookStatus.Failed, - }, - new ProcessBook2(book, Logger) - { - Result = ProcessBookResult.FailedRetry, - Status = ProcessBookStatus.Failed, - }, - new ProcessBook2(book, Logger) - { - Result = ProcessBookResult.ValidationFail, - Status = ProcessBookStatus.Failed, - }, - new ProcessBook2(book, Logger) - { - Result = ProcessBookResult.Cancelled, - Status = ProcessBookStatus.Cancelled, - }, - new ProcessBook2(book, Logger) - { - Result = ProcessBookResult.Success, - Status = ProcessBookStatus.Completed, - }, - new ProcessBook2(book, Logger) - { - Result = ProcessBookResult.None, - Status = ProcessBookStatus.Working, - }, - new ProcessBook2(book, Logger) - { - Result = ProcessBookResult.None, - Status = ProcessBookStatus.Queued, - }, - }; - - Items.Enqueue(testList); - return; - } - #endregion } private int _completedCount; diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs index 9698c3d1..3604bd1c 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs @@ -39,25 +39,10 @@ namespace LibationWinForms.AvaloniaUI.ViewModels => GridEntries .AllItems() .BookEntries(); - - public ProductsDisplayViewModel() + public ProductsDisplayViewModel() { } + public ProductsDisplayViewModel(List items) { - if (Design.IsDesignMode) - { - using var context = DbContexts.GetContext(); - List sampleEntries = new() - { - context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"), - context.GetLibraryBook_Flat_NoTracking("B017V4IWVG"), - context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q"), - context.GetLibraryBook_Flat_NoTracking("B017V4NUPO"), - context.GetLibraryBook_Flat_NoTracking("B017V4NMX4"), - context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0"), - context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6"), - }; - GridEntries = new GridEntryBindingList2(CreateGridEntries(sampleEntries)); - return; - } + GridEntries = new GridEntryBindingList2(items); } #region Display Functions diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog2.axaml b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog2.axaml new file mode 100644 index 00000000..5ecdd665 --- /dev/null +++ b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/BookDetailsDialog2.axaml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + Tags are separated by a space. Each tag can contain letters, numbers, and underscores + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +