Book details form: quick and dirty 1st draft
This commit is contained in:
parent
6dfef09ea3
commit
c9f988acf8
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>5.5.0.20</Version>
|
<Version>5.5.1.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
|||||||
105
LibationWinForms/Dialogs/BookDetailsDialog.Designer.cs
generated
105
LibationWinForms/Dialogs/BookDetailsDialog.Designer.cs
generated
@ -28,51 +28,107 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.SaveBtn = new System.Windows.Forms.Button();
|
this.saveBtn = new System.Windows.Forms.Button();
|
||||||
this.newTagsTb = new System.Windows.Forms.TextBox();
|
this.newTagsTb = new System.Windows.Forms.TextBox();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.coverPb = new System.Windows.Forms.PictureBox();
|
||||||
|
this.detailsTb = new System.Windows.Forms.TextBox();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.cancelBtn = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.coverPb)).BeginInit();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// SaveBtn
|
// saveBtn
|
||||||
//
|
//
|
||||||
this.SaveBtn.Location = new System.Drawing.Point(462, 29);
|
this.saveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.SaveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.saveBtn.Location = new System.Drawing.Point(481, 247);
|
||||||
this.SaveBtn.Name = "SaveBtn";
|
this.saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.SaveBtn.Size = new System.Drawing.Size(88, 27);
|
this.saveBtn.Name = "saveBtn";
|
||||||
this.SaveBtn.TabIndex = 1;
|
this.saveBtn.Size = new System.Drawing.Size(88, 27);
|
||||||
this.SaveBtn.Text = "Save";
|
this.saveBtn.TabIndex = 3;
|
||||||
this.SaveBtn.UseVisualStyleBackColor = true;
|
this.saveBtn.Text = "Save";
|
||||||
this.SaveBtn.Click += new System.EventHandler(this.SaveBtn_Click);
|
this.saveBtn.UseVisualStyleBackColor = true;
|
||||||
|
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
|
||||||
//
|
//
|
||||||
// newTagsTb
|
// newTagsTb
|
||||||
//
|
//
|
||||||
this.newTagsTb.Location = new System.Drawing.Point(14, 31);
|
this.newTagsTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.newTagsTb.Location = new System.Drawing.Point(7, 40);
|
||||||
this.newTagsTb.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.newTagsTb.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.newTagsTb.Name = "newTagsTb";
|
this.newTagsTb.Name = "newTagsTb";
|
||||||
this.newTagsTb.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
this.newTagsTb.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||||
this.newTagsTb.Size = new System.Drawing.Size(437, 23);
|
this.newTagsTb.Size = new System.Drawing.Size(661, 23);
|
||||||
this.newTagsTb.TabIndex = 0;
|
this.newTagsTb.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(14, 10);
|
this.label1.Location = new System.Drawing.Point(7, 19);
|
||||||
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(458, 15);
|
this.label1.Size = new System.Drawing.Size(458, 15);
|
||||||
this.label1.TabIndex = 2;
|
this.label1.TabIndex = 0;
|
||||||
this.label1.Text = "Tags are separated by a space. Each tag can contain letters, numbers, and undersc" +
|
this.label1.Text = "Tags are separated by a space. Each tag can contain letters, numbers, and undersc" +
|
||||||
"ores";
|
"ores";
|
||||||
|
//
|
||||||
|
// coverPb
|
||||||
|
//
|
||||||
|
this.coverPb.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.coverPb.Name = "coverPb";
|
||||||
|
this.coverPb.Size = new System.Drawing.Size(80, 80);
|
||||||
|
this.coverPb.TabIndex = 3;
|
||||||
|
this.coverPb.TabStop = false;
|
||||||
|
//
|
||||||
|
// detailsTb
|
||||||
|
//
|
||||||
|
this.detailsTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.detailsTb.Location = new System.Drawing.Point(98, 12);
|
||||||
|
this.detailsTb.Multiline = true;
|
||||||
|
this.detailsTb.Name = "detailsTb";
|
||||||
|
this.detailsTb.ReadOnly = true;
|
||||||
|
this.detailsTb.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||||
|
this.detailsTb.Size = new System.Drawing.Size(589, 151);
|
||||||
|
this.detailsTb.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.groupBox1.Controls.Add(this.label1);
|
||||||
|
this.groupBox1.Controls.Add(this.newTagsTb);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(12, 169);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(675, 73);
|
||||||
|
this.groupBox1.TabIndex = 1;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Edit Tags";
|
||||||
|
//
|
||||||
|
// cancelBtn
|
||||||
|
//
|
||||||
|
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.cancelBtn.Location = new System.Drawing.Point(599, 247);
|
||||||
|
this.cancelBtn.Name = "cancelBtn";
|
||||||
|
this.cancelBtn.Size = new System.Drawing.Size(88, 27);
|
||||||
|
this.cancelBtn.TabIndex = 4;
|
||||||
|
this.cancelBtn.Text = "Cancel";
|
||||||
|
this.cancelBtn.UseVisualStyleBackColor = true;
|
||||||
|
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
|
||||||
//
|
//
|
||||||
// BookDetailsDialog
|
// BookDetailsDialog
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.SaveBtn;
|
this.AcceptButton = this.saveBtn;
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(564, 69);
|
this.CancelButton = this.cancelBtn;
|
||||||
this.Controls.Add(this.label1);
|
this.ClientSize = new System.Drawing.Size(699, 286);
|
||||||
this.Controls.Add(this.newTagsTb);
|
this.Controls.Add(this.cancelBtn);
|
||||||
this.Controls.Add(this.SaveBtn);
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Controls.Add(this.detailsTb);
|
||||||
|
this.Controls.Add(this.coverPb);
|
||||||
|
this.Controls.Add(this.saveBtn);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
@ -82,14 +138,21 @@
|
|||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Book Details";
|
this.Text = "Book Details";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.coverPb)).EndInit();
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
this.groupBox1.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
private System.Windows.Forms.Button SaveBtn;
|
private System.Windows.Forms.Button saveBtn;
|
||||||
private System.Windows.Forms.TextBox newTagsTb;
|
private System.Windows.Forms.TextBox newTagsTb;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.PictureBox coverPb;
|
||||||
|
private System.Windows.Forms.TextBox detailsTb;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
|
private System.Windows.Forms.Button cancelBtn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,6 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using DataLayer;
|
||||||
|
using Dinah.Core;
|
||||||
|
|
||||||
namespace LibationWinForms.Dialogs
|
namespace LibationWinForms.Dialogs
|
||||||
{
|
{
|
||||||
@ -8,21 +11,62 @@ namespace LibationWinForms.Dialogs
|
|||||||
{
|
{
|
||||||
public string NewTags { get; private set; }
|
public string NewTags { get; private set; }
|
||||||
|
|
||||||
|
private LibraryBook _libraryBook { get; }
|
||||||
|
private Book Book => _libraryBook.Book;
|
||||||
|
|
||||||
public BookDetailsDialog()
|
public BookDetailsDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
public BookDetailsDialog(string title, string rawTags) : this()
|
public BookDetailsDialog(LibraryBook libraryBook) : this()
|
||||||
{
|
{
|
||||||
this.Text = title;
|
_libraryBook = ArgumentValidator.EnsureNotNull(libraryBook, nameof(libraryBook));
|
||||||
|
initDetails();
|
||||||
this.newTagsTb.Text = rawTags;
|
initTags();
|
||||||
|
//initLiberated();
|
||||||
}
|
}
|
||||||
|
// 1st draft: lazily cribbed from GridEntry.ctor()
|
||||||
|
private void initDetails()
|
||||||
|
{
|
||||||
|
this.Text = Book.Title;
|
||||||
|
|
||||||
private void SaveBtn_Click(object sender, EventArgs e)
|
(var isDefault, var picture) = FileManager.PictureStorage.GetPicture(new FileManager.PictureDefinition(Book.PictureId, FileManager.PictureSize._80x80));
|
||||||
|
this.coverPb.Image = Dinah.Core.Drawing.ImageReader.ToImage(picture);
|
||||||
|
|
||||||
|
var t = @$"
|
||||||
|
Title: {Book.Title}
|
||||||
|
Author(s): {Book.AuthorNames}
|
||||||
|
Narrator(s): {Book.NarratorNames}
|
||||||
|
Length: {(Book.LengthInMinutes == 0 ? "" : $"{Book.LengthInMinutes / 60} hr {Book.LengthInMinutes % 60} min")}
|
||||||
|
Category: {string.Join(" > ", Book.CategoriesNames)}
|
||||||
|
Purchase Date: {_libraryBook.DateAdded.ToString("d")}
|
||||||
|
".Trim();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(Book.SeriesNames))
|
||||||
|
t += $"\r\nSeries: {Book.SeriesNames}";
|
||||||
|
|
||||||
|
var bookRating = Book.Rating?.ToStarString();
|
||||||
|
if (!string.IsNullOrWhiteSpace(bookRating))
|
||||||
|
t += $"\r\nBook Rating:\r\n{bookRating}";
|
||||||
|
|
||||||
|
var myRating = Book.UserDefinedItem.Rating?.ToStarString();
|
||||||
|
if (!string.IsNullOrWhiteSpace(myRating))
|
||||||
|
t += $"\r\nMy Rating:\r\n{myRating}";
|
||||||
|
|
||||||
|
this.detailsTb.Text = t;
|
||||||
|
}
|
||||||
|
private void initTags() => this.newTagsTb.Text = Book.UserDefinedItem.Tags;
|
||||||
|
|
||||||
|
private void saveBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
NewTags = this.newTagsTb.Text;
|
NewTags = this.newTagsTb.Text;
|
||||||
DialogResult = DialogResult.OK;
|
this.DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.DialogResult = DialogResult.Cancel;
|
||||||
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,7 @@ namespace LibationWinForms
|
|||||||
await Liberate_Click(liveGridEntry);
|
await Liberate_Click(liveGridEntry);
|
||||||
break;
|
break;
|
||||||
case nameof(liveGridEntry.DisplayTags):
|
case nameof(liveGridEntry.DisplayTags):
|
||||||
EditTags_Click(liveGridEntry);
|
Details_Click(liveGridEntry.LibraryBook);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,13 +89,13 @@ namespace LibationWinForms
|
|||||||
await BookLiberation.ProcessorAutomationController.BackupSingleBookAsync(libraryBook, (_, __) => RefreshRow(libraryBook.Book.AudibleProductId));
|
await BookLiberation.ProcessorAutomationController.BackupSingleBookAsync(libraryBook, (_, __) => RefreshRow(libraryBook.Book.AudibleProductId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EditTags_Click(GridEntry liveGridEntry)
|
private void Details_Click(LibraryBook libraryBook)
|
||||||
{
|
{
|
||||||
var bookDetailsForm = new BookDetailsDialog(liveGridEntry.Title, liveGridEntry.LibraryBook.Book.UserDefinedItem.Tags);
|
var bookDetailsForm = new BookDetailsDialog(libraryBook);
|
||||||
if (bookDetailsForm.ShowDialog() != DialogResult.OK)
|
if (bookDetailsForm.ShowDialog() != DialogResult.OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var qtyChanges = LibraryCommands.UpdateTags(liveGridEntry.LibraryBook.Book, bookDetailsForm.NewTags);
|
var qtyChanges = LibraryCommands.UpdateTags(libraryBook.Book, bookDetailsForm.NewTags);
|
||||||
if (qtyChanges == 0)
|
if (qtyChanges == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user