Merge pull request #240 from Mbucari/master

Lots of new UI stuff!
This commit is contained in:
rmcrackan 2022-05-10 14:37:39 -04:00 committed by GitHub
commit de9b3fd6ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 1114 additions and 247 deletions

View File

@ -140,11 +140,6 @@ namespace AaxDecrypter
else else
FileUtility.SaferDelete(TempFilePath); FileUtility.SaferDelete(TempFilePath);
} }
else
{
FileUtility.SaferDelete(OutputFileName);
}
return success; return success;
} }

View File

@ -125,6 +125,15 @@ namespace AppScaffolding
if (!config.Exists(nameof(config.AutoScan))) if (!config.Exists(nameof(config.AutoScan)))
config.AutoScan = true; config.AutoScan = true;
if (!config.Exists(nameof(config.GridColumnsVisibilities)))
config.GridColumnsVisibilities = new Dictionary<string, bool>();
if (!config.Exists(nameof(config.GridColumnsDisplayIndices)))
config.GridColumnsDisplayIndices = new Dictionary<string, int>();
if (!config.Exists(nameof(config.GridColumnsWidths)))
config.GridColumnsWidths = new Dictionary<string, int>();
} }
/// <summary>Initialize logging. Run after migration</summary> /// <summary>Initialize logging. Run after migration</summary>

View File

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AudibleApi" Version="2.7.6.1" /> <PackageReference Include="AudibleApi" Version="2.8.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -34,6 +34,7 @@ namespace DataLayer
// mutable // mutable
public string PictureId { get; set; } public string PictureId { get; set; }
public string PictureLarge { get; set; }
// book details // book details
public bool IsAbridged { get; private set; } public bool IsAbridged { get; private set; }

Binary file not shown.

View File

@ -0,0 +1,394 @@
// <auto-generated />
using System;
using DataLayer;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DataLayer.Migrations
{
[DbContext(typeof(LibationContext))]
[Migration("20220510175257_AddPictureIDLargeMigration")]
partial class AddPictureIDLargeMigration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.4");
modelBuilder.Entity("DataLayer.Book", b =>
{
b.Property<int>("BookId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AudibleProductId")
.HasColumnType("TEXT");
b.Property<int>("CategoryId")
.HasColumnType("INTEGER");
b.Property<int>("ContentType")
.HasColumnType("INTEGER");
b.Property<DateTime?>("DatePublished")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<bool>("IsAbridged")
.HasColumnType("INTEGER");
b.Property<int>("LengthInMinutes")
.HasColumnType("INTEGER");
b.Property<string>("Locale")
.HasColumnType("TEXT");
b.Property<string>("PictureId")
.HasColumnType("TEXT");
b.Property<string>("PictureLarge")
.HasColumnType("TEXT");
b.Property<string>("Title")
.HasColumnType("TEXT");
b.HasKey("BookId");
b.HasIndex("AudibleProductId");
b.HasIndex("CategoryId");
b.ToTable("Books");
});
modelBuilder.Entity("DataLayer.BookContributor", b =>
{
b.Property<int>("BookId")
.HasColumnType("INTEGER");
b.Property<int>("ContributorId")
.HasColumnType("INTEGER");
b.Property<int>("Role")
.HasColumnType("INTEGER");
b.Property<byte>("Order")
.HasColumnType("INTEGER");
b.HasKey("BookId", "ContributorId", "Role");
b.HasIndex("BookId");
b.HasIndex("ContributorId");
b.ToTable("BookContributor");
});
modelBuilder.Entity("DataLayer.Category", b =>
{
b.Property<int>("CategoryId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AudibleCategoryId")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<int?>("ParentCategoryCategoryId")
.HasColumnType("INTEGER");
b.HasKey("CategoryId");
b.HasIndex("AudibleCategoryId");
b.HasIndex("ParentCategoryCategoryId");
b.ToTable("Categories");
b.HasData(
new
{
CategoryId = -1,
AudibleCategoryId = "",
Name = ""
});
});
modelBuilder.Entity("DataLayer.Contributor", b =>
{
b.Property<int>("ContributorId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AudibleContributorId")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("ContributorId");
b.HasIndex("Name");
b.ToTable("Contributors");
b.HasData(
new
{
ContributorId = -1,
Name = ""
});
});
modelBuilder.Entity("DataLayer.LibraryBook", b =>
{
b.Property<int>("BookId")
.HasColumnType("INTEGER");
b.Property<string>("Account")
.HasColumnType("TEXT");
b.Property<DateTime>("DateAdded")
.HasColumnType("TEXT");
b.HasKey("BookId");
b.ToTable("LibraryBooks");
});
modelBuilder.Entity("DataLayer.Series", b =>
{
b.Property<int>("SeriesId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("AudibleSeriesId")
.HasColumnType("TEXT");
b.Property<string>("Name")
.HasColumnType("TEXT");
b.HasKey("SeriesId");
b.HasIndex("AudibleSeriesId");
b.ToTable("Series");
});
modelBuilder.Entity("DataLayer.SeriesBook", b =>
{
b.Property<int>("SeriesId")
.HasColumnType("INTEGER");
b.Property<int>("BookId")
.HasColumnType("INTEGER");
b.Property<string>("Order")
.HasColumnType("TEXT");
b.HasKey("SeriesId", "BookId");
b.HasIndex("BookId");
b.HasIndex("SeriesId");
b.ToTable("SeriesBook");
});
modelBuilder.Entity("DataLayer.Book", b =>
{
b.HasOne("DataLayer.Category", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("DataLayer.Rating", "Rating", b1 =>
{
b1.Property<int>("BookId")
.HasColumnType("INTEGER");
b1.Property<float>("OverallRating")
.HasColumnType("REAL");
b1.Property<float>("PerformanceRating")
.HasColumnType("REAL");
b1.Property<float>("StoryRating")
.HasColumnType("REAL");
b1.HasKey("BookId");
b1.ToTable("Books");
b1.WithOwner()
.HasForeignKey("BookId");
});
b.OwnsMany("DataLayer.Supplement", "Supplements", b1 =>
{
b1.Property<int>("SupplementId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b1.Property<int>("BookId")
.HasColumnType("INTEGER");
b1.Property<string>("Url")
.HasColumnType("TEXT");
b1.HasKey("SupplementId");
b1.HasIndex("BookId");
b1.ToTable("Supplement");
b1.WithOwner("Book")
.HasForeignKey("BookId");
b1.Navigation("Book");
});
b.OwnsOne("DataLayer.UserDefinedItem", "UserDefinedItem", b1 =>
{
b1.Property<int>("BookId")
.HasColumnType("INTEGER");
b1.Property<int>("BookStatus")
.HasColumnType("INTEGER");
b1.Property<int?>("PdfStatus")
.HasColumnType("INTEGER");
b1.Property<string>("Tags")
.HasColumnType("TEXT");
b1.HasKey("BookId");
b1.ToTable("UserDefinedItem", (string)null);
b1.WithOwner("Book")
.HasForeignKey("BookId");
b1.OwnsOne("DataLayer.Rating", "Rating", b2 =>
{
b2.Property<int>("UserDefinedItemBookId")
.HasColumnType("INTEGER");
b2.Property<float>("OverallRating")
.HasColumnType("REAL");
b2.Property<float>("PerformanceRating")
.HasColumnType("REAL");
b2.Property<float>("StoryRating")
.HasColumnType("REAL");
b2.HasKey("UserDefinedItemBookId");
b2.ToTable("UserDefinedItem");
b2.WithOwner()
.HasForeignKey("UserDefinedItemBookId");
});
b1.Navigation("Book");
b1.Navigation("Rating");
});
b.Navigation("Category");
b.Navigation("Rating");
b.Navigation("Supplements");
b.Navigation("UserDefinedItem");
});
modelBuilder.Entity("DataLayer.BookContributor", b =>
{
b.HasOne("DataLayer.Book", "Book")
.WithMany("ContributorsLink")
.HasForeignKey("BookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DataLayer.Contributor", "Contributor")
.WithMany("BooksLink")
.HasForeignKey("ContributorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Book");
b.Navigation("Contributor");
});
modelBuilder.Entity("DataLayer.Category", b =>
{
b.HasOne("DataLayer.Category", "ParentCategory")
.WithMany()
.HasForeignKey("ParentCategoryCategoryId");
b.Navigation("ParentCategory");
});
modelBuilder.Entity("DataLayer.LibraryBook", b =>
{
b.HasOne("DataLayer.Book", "Book")
.WithOne()
.HasForeignKey("DataLayer.LibraryBook", "BookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Book");
});
modelBuilder.Entity("DataLayer.SeriesBook", b =>
{
b.HasOne("DataLayer.Book", "Book")
.WithMany("SeriesLink")
.HasForeignKey("BookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DataLayer.Series", "Series")
.WithMany("BooksLink")
.HasForeignKey("SeriesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Book");
b.Navigation("Series");
});
modelBuilder.Entity("DataLayer.Book", b =>
{
b.Navigation("ContributorsLink");
b.Navigation("SeriesLink");
});
modelBuilder.Entity("DataLayer.Contributor", b =>
{
b.Navigation("BooksLink");
});
modelBuilder.Entity("DataLayer.Series", b =>
{
b.Navigation("BooksLink");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DataLayer.Migrations
{
public partial class AddPictureIDLargeMigration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "PictureLarge",
table: "Books",
type: "TEXT",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PictureLarge",
table: "Books");
}
}
}

View File

@ -5,6 +5,8 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DataLayer.Migrations namespace DataLayer.Migrations
{ {
[DbContext(typeof(LibationContext))] [DbContext(typeof(LibationContext))]
@ -13,8 +15,7 @@ namespace DataLayer.Migrations
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder.HasAnnotation("ProductVersion", "6.0.4");
.HasAnnotation("ProductVersion", "5.0.10");
modelBuilder.Entity("DataLayer.Book", b => modelBuilder.Entity("DataLayer.Book", b =>
{ {
@ -49,6 +50,9 @@ namespace DataLayer.Migrations
b.Property<string>("PictureId") b.Property<string>("PictureId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("PictureLarge")
.HasColumnType("TEXT");
b.Property<string>("Title") b.Property<string>("Title")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@ -267,7 +271,7 @@ namespace DataLayer.Migrations
b1.HasKey("BookId"); b1.HasKey("BookId");
b1.ToTable("UserDefinedItem"); b1.ToTable("UserDefinedItem", (string)null);
b1.WithOwner("Book") b1.WithOwner("Book")
.HasForeignKey("BookId"); .HasForeignKey("BookId");

View File

@ -165,6 +165,9 @@ namespace DtoImporterService
if (item.PictureId is not null) if (item.PictureId is not null)
book.PictureId = item.PictureId; book.PictureId = item.PictureId;
if (item.PictureLarge is not null)
book.PictureLarge = item.PictureLarge;
book.UpdateProductRating(item.Product_OverallStars, item.Product_PerformanceStars, item.Product_StoryStars); book.UpdateProductRating(item.Product_OverallStars, item.Product_PerformanceStars, item.Product_StoryStars);
// important to update user-specific info. this will have changed if user has rated/reviewed the book since last library import // important to update user-specific info. this will have changed if user has rated/reviewed the book since last library import

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using DataLayer; using DataLayer;
using Dinah.Core; using Dinah.Core;
using Dinah.Core.ErrorHandling; using Dinah.Core.ErrorHandling;
using LibationFileManager;
namespace FileLiberator namespace FileLiberator
{ {
@ -47,9 +48,38 @@ namespace FileLiberator
= (await ProcessAsync(libraryBook)) = (await ProcessAsync(libraryBook))
?? new StatusHandler { "Processable should never return a null status" }; ?? new StatusHandler { "Processable should never return a null status" };
if (status.IsSuccess)
DownloadCoverArt(libraryBook);
return status; return status;
} }
private void DownloadCoverArt(LibraryBook libraryBook)
{
var destinationDir = AudibleFileStorage.Audio.GetDestinationDirectory(libraryBook);
var coverPath = FileManager.FileUtility.GetValidFilename(System.IO.Path.Combine(destinationDir, "Cover.jpg"), "", true);
if (System.IO.File.Exists(coverPath)) return;
try
{
(string picId, PictureSize size) = libraryBook.Book.PictureLarge is null ?
(libraryBook.Book.PictureId, PictureSize.Native) :
(libraryBook.Book.PictureLarge, PictureSize.Native);
var picBytes = PictureStorage.GetPictureSynchronously(new PictureDefinition(picId, size));
if (picBytes.Length > 0)
System.IO.File.WriteAllBytes(coverPath, picBytes);
}
catch (Exception ex)
{
//Failure to download cover art should not be
//considered a failure to download the book
Serilog.Log.Logger.Error(ex.Message);
}
}
public async Task<StatusHandler> TryProcessAsync(LibraryBook libraryBook) public async Task<StatusHandler> TryProcessAsync(LibraryBook libraryBook)
=> Validate(libraryBook) => Validate(libraryBook)
? await ProcessAsync(libraryBook) ? await ProcessAsync(libraryBook)

View File

@ -180,6 +180,27 @@ namespace LibationFileManager
set => persistentDictionary.SetNonString(nameof(LameVBRQuality), value); set => persistentDictionary.SetNonString(nameof(LameVBRQuality), value);
} }
[Description("A Dictionary of GridView data property names and bool indicating its column's visibility in ProductsGrid")]
public Dictionary<string, bool> GridColumnsVisibilities
{
get => persistentDictionary.GetNonString<Dictionary<string, bool>>(nameof(GridColumnsVisibilities));
set => persistentDictionary.SetNonString(nameof(GridColumnsVisibilities), value);
}
[Description("A Dictionary of GridView data property names and int indicating its column's display index in ProductsGrid")]
public Dictionary<string, int> GridColumnsDisplayIndices
{
get => persistentDictionary.GetNonString<Dictionary<string,int>>(nameof(GridColumnsDisplayIndices));
set => persistentDictionary.SetNonString(nameof(GridColumnsDisplayIndices), value);
}
[Description("A Dictionary of GridView data property names and int indicating its column's width in ProductsGrid")]
public Dictionary<string, int> GridColumnsWidths
{
get => persistentDictionary.GetNonString<Dictionary<string,int>>(nameof(GridColumnsWidths));
set => persistentDictionary.SetNonString(nameof(GridColumnsWidths), value);
}
public enum BadBookAction public enum BadBookAction
{ {
[Description("Ask each time what action to take.")] [Description("Ask each time what action to take.")]

View File

@ -8,13 +8,13 @@ using System.Threading.Tasks;
namespace LibationFileManager namespace LibationFileManager
{ {
public enum PictureSize { _80x80 = 80, _300x300 = 300, _500x500 = 500 } public enum PictureSize { Native, _80x80 = 80, _300x300 = 300, _500x500 = 500 }
public class PictureCachedEventArgs : EventArgs public class PictureCachedEventArgs : EventArgs
{ {
public PictureDefinition Definition { get; internal set; } public PictureDefinition Definition { get; internal set; }
public byte[] Picture { get; internal set; } public byte[] Picture { get; internal set; }
} }
public struct PictureDefinition public struct PictureDefinition : IEquatable<PictureDefinition>
{ {
public string PictureId { get; } public string PictureId { get; }
public PictureSize Size { get; } public PictureSize Size { get; }
@ -24,6 +24,11 @@ namespace LibationFileManager
PictureId = pictureId; PictureId = pictureId;
Size = pictureSize; Size = pictureSize;
} }
public bool Equals(PictureDefinition other)
{
return PictureId == other.PictureId && Size == other.Size;
}
} }
public static class PictureStorage public static class PictureStorage
{ {
@ -113,8 +118,8 @@ namespace LibationFileManager
try try
{ {
var sz = (int)def.Size; var sizeStr = def.Size == PictureSize.Native ? "" : $"._SL{(int)def.Size}_";
var bytes = imageDownloadClient.GetByteArrayAsync("ht" + $"tps://images-na.ssl-images-amazon.com/images/I/{def.PictureId}._SL{sz}_.jpg").Result; var bytes = imageDownloadClient.GetByteArrayAsync("ht" + $"tps://images-na.ssl-images-amazon.com/images/I/{def.PictureId}{sizeStr}.jpg").Result;
// save image file. make sure to not save default image // save image file. make sure to not save default image
var path = getPath(def); var path = getPath(def);

View File

@ -19,6 +19,7 @@ namespace LibationWinForms.BookLiberation.BaseForms
//If this is the first form created, it will not exist until after execution //If this is the first form created, it will not exist until after execution
//reaches inside the constructor (after base class has been initialized). //reaches inside the constructor (after base class has been initialized).
Invoker = new SynchronizeInvoker(); Invoker = new SynchronizeInvoker();
this.SetLibationIcon();
} }
public void RegisterFileLiberator(Streamable streamable, LogMe logMe = null) public void RegisterFileLiberator(Streamable streamable, LogMe logMe = null)

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using DataLayer; using DataLayer;

View File

@ -28,6 +28,7 @@ namespace LibationWinForms.Dialogs
populateDropDown(); populateDropDown();
populateGridValues(); populateGridValues();
this.SetLibationIcon();
} }
private void populateDropDown() private void populateDropDown()

View File

@ -205,7 +205,6 @@
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "BookDetailsDialog"; this.Name = "BookDetailsDialog";
this.ShowIcon = false;
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";

View File

@ -27,6 +27,7 @@ namespace LibationWinForms.Dialogs
public BookDetailsDialog() public BookDetailsDialog()
{ {
InitializeComponent(); InitializeComponent();
this.SetLibationIcon();
} }
public BookDetailsDialog(LibraryBook libraryBook) : this() public BookDetailsDialog(LibraryBook libraryBook) : this()
{ {

View File

@ -26,6 +26,7 @@ namespace LibationWinForms.Dialogs
dataGridView1.Columns[COL_Filter].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView1.Columns[COL_Filter].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
populateGridValues(); populateGridValues();
this.SetLibationIcon();
} }
private void populateGridValues() private void populateGridValues()

View File

@ -170,8 +170,10 @@
this.Controls.Add(this.templateTb); this.Controls.Add(this.templateTb);
this.Controls.Add(this.cancelBtn); this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.saveBtn); this.Controls.Add(this.saveBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 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.MinimizeBox = false;
this.Name = "EditTemplateDialog"; this.Name = "EditTemplateDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Edit Template"; this.Text = "Edit Template";

View File

@ -28,7 +28,11 @@ namespace LibationWinForms.Dialogs
private Templates template { get; } private Templates template { get; }
private string inputTemplateText { get; } private string inputTemplateText { get; }
public EditTemplateDialog() => InitializeComponent(); public EditTemplateDialog()
{
InitializeComponent();
this.SetLibationIcon();
}
public EditTemplateDialog(Templates template, string inputTemplateText) : this() public EditTemplateDialog(Templates template, string inputTemplateText) : this()
{ {
this.template = ArgumentValidator.EnsureNotNull(template, nameof(template)); this.template = ArgumentValidator.EnsureNotNull(template, nameof(template));

View File

@ -164,7 +164,7 @@ namespace LibationWinForms.Dialogs
this.Controls.Add(this.btnRemoveBooks); this.Controls.Add(this.btnRemoveBooks);
this.Controls.Add(this._dataGridView); this.Controls.Add(this._dataGridView);
this.Name = "RemoveBooksDialog"; this.Name = "RemoveBooksDialog";
this.Text = "RemoveBooksDialog"; this.Text = "Remove Books from Libation's Database";
this.Shown += new System.EventHandler(this.RemoveBooksDialog_Shown); this.Shown += new System.EventHandler(this.RemoveBooksDialog_Shown);
((System.ComponentModel.ISupportInitialize)(this._dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this._dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridEntryBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.gridEntryBindingSource)).EndInit();

View File

@ -48,6 +48,7 @@ namespace LibationWinForms.Dialogs
gridEntryBindingSource.DataSource = _removableGridEntries; gridEntryBindingSource.DataSource = _removableGridEntries;
_dataGridView.Enabled = false; _dataGridView.Enabled = false;
this.SetLibationIcon();
} }
private void _dataGridView_BindingContextChanged(object sender, EventArgs e) private void _dataGridView_BindingContextChanged(object sender, EventArgs e)

View File

@ -17,6 +17,7 @@ namespace LibationWinForms.Dialogs
_parent = parent; _parent = parent;
InitializeComponent(); InitializeComponent();
this.SetLibationIcon();
} }
private class listItem private class listItem

View File

@ -113,7 +113,6 @@
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "SearchSyntaxDialog"; this.Name = "SearchSyntaxDialog";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Filter options"; this.Text = "Filter options";
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -14,6 +14,7 @@ namespace LibationWinForms.Dialogs
label3.Text += "\r\n\r\n" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchNumberFields()); label3.Text += "\r\n\r\n" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchNumberFields());
label4.Text += "\r\n\r\n" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchBoolFields()); label4.Text += "\r\n\r\n" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchBoolFields());
label5.Text += "\r\n\r\n" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchIdFields()); label5.Text += "\r\n\r\n" + string.Join("\r\n", LibationSearchEngine.SearchEngine.GetSearchIdFields());
this.SetLibationIcon();
} }
private void CloseBtn_Click(object sender, EventArgs e) => this.Close(); private void CloseBtn_Click(object sender, EventArgs e) => this.Close();

View File

@ -17,7 +17,6 @@ namespace LibationWinForms.Dialogs
private void LameMatchSourceBRCbox_CheckedChanged(object sender, EventArgs e) private void LameMatchSourceBRCbox_CheckedChanged(object sender, EventArgs e)
{ {
lameBitrateTb.Enabled = !LameMatchSourceBRCbox.Checked; lameBitrateTb.Enabled = !LameMatchSourceBRCbox.Checked;
lameConstantBitrateCbox.Enabled = !LameMatchSourceBRCbox.Checked;
} }
private void convertFormatRb_CheckedChanged(object sender, EventArgs e) private void convertFormatRb_CheckedChanged(object sender, EventArgs e)

View File

@ -944,8 +944,10 @@
this.Controls.Add(this.tabControl); this.Controls.Add(this.tabControl);
this.Controls.Add(this.cancelBtn); this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.saveBtn); this.Controls.Add(this.saveBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 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.MinimizeBox = false;
this.Name = "SettingsDialog"; this.Name = "SettingsDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Edit Settings"; this.Text = "Edit Settings";

View File

@ -13,7 +13,11 @@ namespace LibationWinForms.Dialogs
private Configuration config { get; } = Configuration.Instance; private Configuration config { get; } = Configuration.Instance;
private Func<string, string> desc { get; } = Configuration.GetDescription; private Func<string, string> desc { get; } = Configuration.GetDescription;
public SettingsDialog() => InitializeComponent(); public SettingsDialog()
{
InitializeComponent();
this.SetLibationIcon();
}
private void SettingsDialog_Load(object sender, EventArgs e) private void SettingsDialog_Load(object sender, EventArgs e)
{ {

View File

@ -262,8 +262,8 @@ namespace LibationWinForms
.Where(a => a.LibraryScan) .Where(a => a.LibraryScan)
.ToArray(); .ToArray();
// in autoScan, new books SHALL NOT show dialog // in autoScan, new books SHALL NOT show dialog
await LibraryCommands.ImportAccountAsync(Login.WinformLoginChoiceEager.ApiExtendedFunc, accounts); await Invoke(async () => await LibraryCommands.ImportAccountAsync(Login.WinformLoginChoiceEager.ApiExtendedFunc, accounts));
}; };
// load init state to menu checkbox // load init state to menu checkbox

View File

@ -7,6 +7,18 @@ namespace LibationWinForms
{ {
public static class FormSaveExtension public static class FormSaveExtension
{ {
static readonly Icon libationIcon;
static FormSaveExtension()
{
var resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
libationIcon = (Icon)resources.GetObject("$this.Icon");
}
public static void SetLibationIcon(this Form form)
{
form.Icon = libationIcon;
}
public static void RestoreSizeAndLocation(this Form form, Configuration config) public static void RestoreSizeAndLocation(this Form form, Configuration config)
{ {
FormSizeAndPosition savedState = config.GetNonString<FormSizeAndPosition>(form.Name); FormSizeAndPosition savedState = config.GetNonString<FormSizeAndPosition>(form.Name);
@ -77,6 +89,7 @@ namespace LibationWinForms
config.SetObject(form.Name, saveState); config.SetObject(form.Name, saveState);
} }
} }
class FormSizeAndPosition class FormSizeAndPosition
{ {

View File

@ -0,0 +1,69 @@
namespace LibationWinForms
{
partial class DescriptionDisplay
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.textBox1.Location = new System.Drawing.Point(5, 5);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(540, 140);
this.textBox1.TabIndex = 0;
//
// DescriptionDisplay
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Highlight;
this.ClientSize = new System.Drawing.Size(550, 150);
this.Controls.Add(this.textBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "DescriptionDisplay";
this.ShowInTaskbar = false;
this.Text = "DescriptionDisplay";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace LibationWinForms
{
public partial class DescriptionDisplay : Form
{
private int borderThickness = 5;
public int BorderThickness
{
get => borderThickness;
set
{
borderThickness = value;
textBox1.Location = new Point(borderThickness, borderThickness);
textBox1.Size = new Size(Width - 2 * borderThickness, Height - 2 * borderThickness);
}
}
public string DescriptionText { get => textBox1.Text; set => textBox1.Text = value; }
public Point SpawnLocation { get; set; }
public DescriptionDisplay()
{
InitializeComponent();
textBox1.LostFocus += (_, _) => Close();
Shown += DescriptionDisplay_Shown;
}
private void DescriptionDisplay_Shown(object sender, EventArgs e)
{
textBox1.DeselectAll();
HideCaret(textBox1.Handle);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
int lineCount = textBox1.GetLineFromCharIndex(int.MaxValue) + 2;
Height = Height - textBox1.Height + lineCount * TextRenderer.MeasureText("X", textBox1.Font).Height;
Location = new Point(SpawnLocation.X, Math.Min(SpawnLocation.Y, Screen.PrimaryScreen.WorkingArea.Height - Height));
}
[DllImport("user32.dll")]
static extern bool HideCaret(IntPtr hWnd);
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -26,10 +26,16 @@ namespace LibationWinForms
public string AudibleProductId => Book.AudibleProductId; public string AudibleProductId => Book.AudibleProductId;
[Browsable(false)] [Browsable(false)]
public LibraryBook LibraryBook { get; private set; } public LibraryBook LibraryBook { get; private set; }
[Browsable(false)]
public string LongDescription { get; private set; }
#endregion #endregion
#region Model properties exposed to the view #region Model properties exposed to the view
private Image _cover; private Image _cover;
private DateTime lastStatusUpdate = default;
private LiberatedStatus _bookStatus;
private LiberatedStatus? _pdfStatus;
public Image Cover public Image Cover
{ {
get => _cover; get => _cover;
@ -61,10 +67,21 @@ namespace LibationWinForms
// these 2 values being in 1 field is the trick behind getting the liberated+pdf 'stoplight' icon to draw. See: LiberateDataGridViewImageButtonCell.Paint // these 2 values being in 1 field is the trick behind getting the liberated+pdf 'stoplight' icon to draw. See: LiberateDataGridViewImageButtonCell.Paint
public (LiberatedStatus BookStatus, LiberatedStatus? PdfStatus) Liberate public (LiberatedStatus BookStatus, LiberatedStatus? PdfStatus) Liberate
{ {
get => (LibraryCommands.Liberated_Status(LibraryBook.Book), LibraryCommands.Pdf_Status(LibraryBook.Book)); get
{
//Cache these statuses for faster sorting.
if ((DateTime.Now - lastStatusUpdate).TotalSeconds > 2)
{
UpdateLiberatedStatus(notify: false);
lastStatusUpdate = DateTime.Now;
}
return (_bookStatus, _pdfStatus);
}
set set
{ {
_bookStatus = value.BookStatus;
_pdfStatus = value.PdfStatus;
LibraryBook.Book.UserDefinedItem.BookStatus = value.BookStatus; LibraryBook.Book.UserDefinedItem.BookStatus = value.BookStatus;
LibraryBook.Book.UserDefinedItem.PdfStatus = value.PdfStatus; LibraryBook.Book.UserDefinedItem.PdfStatus = value.PdfStatus;
} }
@ -87,6 +104,7 @@ namespace LibationWinForms
{ {
DownloadInProgress = true; DownloadInProgress = true;
await BookLiberation.ProcessorAutomationController.BackupSingleBookAsync(LibraryBook); await BookLiberation.ProcessorAutomationController.BackupSingleBookAsync(LibraryBook);
UpdateLiberatedStatus();
} }
finally finally
{ {
@ -131,7 +149,8 @@ namespace LibationWinForms
Narrators = Book.NarratorNames; Narrators = Book.NarratorNames;
Category = string.Join(" > ", Book.CategoriesNames); Category = string.Join(" > ", Book.CategoriesNames);
Misc = GetMiscDisplay(libraryBook); Misc = GetMiscDisplay(libraryBook);
Description = GetDescriptionDisplay(Book); LongDescription = GetDescriptionDisplay(Book);
Description = TrimTextToWord(LongDescription, 62);
} }
UserDefinedItem.ItemChanged += UserDefinedItem_ItemChanged; UserDefinedItem.ItemChanged += UserDefinedItem_ItemChanged;
@ -212,6 +231,14 @@ namespace LibationWinForms
Committed?.Invoke(this, null); Committed?.Invoke(this, null);
} }
private void UpdateLiberatedStatus(bool notify = true)
{
_bookStatus = LibraryCommands.Liberated_Status(LibraryBook.Book);
_pdfStatus = LibraryCommands.Pdf_Status(LibraryBook.Book);
if (notify)
NotifyPropertyChanged(nameof(Liberate));
}
#endregion #endregion
#region Data Sorting #region Data Sorting
@ -262,12 +289,16 @@ namespace LibationWinForms
private static string GetDescriptionDisplay(Book book) private static string GetDescriptionDisplay(Book book)
{ {
var doc = new HtmlAgilityPack.HtmlDocument(); var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(book?.Description ?? ""); doc.LoadHtml(book?.Description?.Replace("</p> ", "\r\n\r\n</p>") ?? "");
var noHtml = doc.DocumentNode.InnerText; return doc.DocumentNode.InnerText.Trim();
}
private static string TrimTextToWord(string text, int maxLength)
{
return return
noHtml.Length < 63 ? text.Length <= maxLength ?
noHtml : text :
noHtml.Substring(0, 60) + "..."; text.Substring(0, maxLength - 3) + "...";
} }
/// <summary> /// <summary>

View File

@ -28,195 +28,207 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
this.gridEntryBindingSource = new LibationWinForms.SyncBindingSource(this.components); this.gridEntryBindingSource = new LibationWinForms.SyncBindingSource(this.components);
this.gridEntryDataGridView = new System.Windows.Forms.DataGridView(); this.gridEntryDataGridView = new System.Windows.Forms.DataGridView();
this.dataGridViewImageButtonBoxColumn1 = new LibationWinForms.LiberateDataGridViewImageButtonColumn(); this.liberateGVColumn = new LibationWinForms.LiberateDataGridViewImageButtonColumn();
this.dataGridViewImageColumn1 = new System.Windows.Forms.DataGridViewImageColumn(); this.coverGVColumn = new System.Windows.Forms.DataGridViewImageColumn();
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.titleGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.authorsGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.narratorsGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.lengthGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.seriesGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.descriptionGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.categoryGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.productRatingGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.purchaseDateGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.myRatingGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn11 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.miscGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewImageButtonBoxColumn2 = new LibationWinForms.EditTagsDataGridViewImageButtonColumn(); this.tagAndDetailsGVColumn = new LibationWinForms.EditTagsDataGridViewImageButtonColumn();
((System.ComponentModel.ISupportInitialize)(this.gridEntryBindingSource)).BeginInit(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.gridEntryBindingSource)).BeginInit();
this.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).BeginInit();
// this.SuspendLayout();
// gridEntryBindingSource //
// // gridEntryBindingSource
this.gridEntryBindingSource.DataSource = typeof(LibationWinForms.GridEntry); //
// this.gridEntryBindingSource.DataSource = typeof(LibationWinForms.GridEntry);
// gridEntryDataGridView //
// // gridEntryDataGridView
this.gridEntryDataGridView.AllowUserToAddRows = false; //
this.gridEntryDataGridView.AllowUserToDeleteRows = false; this.gridEntryDataGridView.AllowUserToAddRows = false;
this.gridEntryDataGridView.AllowUserToResizeRows = false; this.gridEntryDataGridView.AllowUserToDeleteRows = false;
this.gridEntryDataGridView.AutoGenerateColumns = false; this.gridEntryDataGridView.AllowUserToOrderColumns = true;
this.gridEntryDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.gridEntryDataGridView.AllowUserToResizeRows = false;
this.gridEntryDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.gridEntryDataGridView.AutoGenerateColumns = false;
this.dataGridViewImageButtonBoxColumn1, this.gridEntryDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridViewImageColumn1, this.gridEntryDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dataGridViewTextBoxColumn1, this.liberateGVColumn,
this.dataGridViewTextBoxColumn2, this.coverGVColumn,
this.dataGridViewTextBoxColumn3, this.titleGVColumn,
this.dataGridViewTextBoxColumn4, this.authorsGVColumn,
this.dataGridViewTextBoxColumn5, this.narratorsGVColumn,
this.dataGridViewTextBoxColumn6, this.lengthGVColumn,
this.dataGridViewTextBoxColumn7, this.seriesGVColumn,
this.dataGridViewTextBoxColumn8, this.descriptionGVColumn,
this.dataGridViewTextBoxColumn9, this.categoryGVColumn,
this.dataGridViewTextBoxColumn10, this.productRatingGVColumn,
this.dataGridViewTextBoxColumn11, this.purchaseDateGVColumn,
this.dataGridViewImageButtonBoxColumn2}); this.myRatingGVColumn,
this.gridEntryDataGridView.DataSource = this.gridEntryBindingSource; this.miscGVColumn,
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.tagAndDetailsGVColumn});
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window; this.gridEntryDataGridView.ContextMenuStrip = this.contextMenuStrip1;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.gridEntryDataGridView.DataSource = this.gridEntryBindingSource;
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText; dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
this.gridEntryDataGridView.DefaultCellStyle = dataGridViewCellStyle1; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
this.gridEntryDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
this.gridEntryDataGridView.Location = new System.Drawing.Point(0, 0); dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.gridEntryDataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.gridEntryDataGridView.DefaultCellStyle = dataGridViewCellStyle1;
this.gridEntryDataGridView.Name = "gridEntryDataGridView"; this.gridEntryDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.gridEntryDataGridView.ReadOnly = true; this.gridEntryDataGridView.Location = new System.Drawing.Point(0, 0);
this.gridEntryDataGridView.RowHeadersVisible = false; this.gridEntryDataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.gridEntryDataGridView.RowTemplate.Height = 82; this.gridEntryDataGridView.Name = "gridEntryDataGridView";
this.gridEntryDataGridView.Size = new System.Drawing.Size(1510, 380); this.gridEntryDataGridView.ReadOnly = true;
this.gridEntryDataGridView.TabIndex = 0; this.gridEntryDataGridView.RowHeadersVisible = false;
// this.gridEntryDataGridView.RowTemplate.Height = 82;
// dataGridViewImageButtonBoxColumn1 this.gridEntryDataGridView.Size = new System.Drawing.Size(1510, 380);
// this.gridEntryDataGridView.TabIndex = 0;
this.dataGridViewImageButtonBoxColumn1.DataPropertyName = "Liberate"; this.gridEntryDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.gridEntryDataGridView_CellToolTipTextNeeded);
this.dataGridViewImageButtonBoxColumn1.HeaderText = "Liberate"; this.gridEntryDataGridView.ColumnDisplayIndexChanged += new System.Windows.Forms.DataGridViewColumnEventHandler(this.gridEntryDataGridView_ColumnDisplayIndexChanged);
this.dataGridViewImageButtonBoxColumn1.Name = "dataGridViewImageButtonBoxColumn1"; this.gridEntryDataGridView.ColumnWidthChanged += new System.Windows.Forms.DataGridViewColumnEventHandler(this.gridEntryDataGridView_ColumnWidthChanged);
this.dataGridViewImageButtonBoxColumn1.ReadOnly = true; //
this.dataGridViewImageButtonBoxColumn1.Resizable = System.Windows.Forms.DataGridViewTriState.False; // liberateGVColumn
this.dataGridViewImageButtonBoxColumn1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; //
this.dataGridViewImageButtonBoxColumn1.Width = 75; this.liberateGVColumn.DataPropertyName = "Liberate";
// this.liberateGVColumn.HeaderText = "Liberate";
// dataGridViewImageColumn1 this.liberateGVColumn.Name = "liberateGVColumn";
// this.liberateGVColumn.ReadOnly = true;
this.dataGridViewImageColumn1.DataPropertyName = "Cover"; this.liberateGVColumn.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridViewImageColumn1.HeaderText = "Cover"; this.liberateGVColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.dataGridViewImageColumn1.Name = "dataGridViewImageColumn1"; this.liberateGVColumn.Width = 75;
this.dataGridViewImageColumn1.ReadOnly = true; //
this.dataGridViewImageColumn1.Resizable = System.Windows.Forms.DataGridViewTriState.False; // coverGVColumn
this.dataGridViewImageColumn1.ToolTipText = "Cover Art"; //
this.dataGridViewImageColumn1.Width = 80; this.coverGVColumn.DataPropertyName = "Cover";
// this.coverGVColumn.HeaderText = "Cover";
// dataGridViewTextBoxColumn1 this.coverGVColumn.Name = "coverGVColumn";
// this.coverGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn1.DataPropertyName = "Title"; this.coverGVColumn.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.dataGridViewTextBoxColumn1.HeaderText = "Title"; this.coverGVColumn.ToolTipText = "Cover Art";
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; this.coverGVColumn.Width = 80;
this.dataGridViewTextBoxColumn1.ReadOnly = true; //
this.dataGridViewTextBoxColumn1.Width = 200; // titleGVColumn
// //
// dataGridViewTextBoxColumn2 this.titleGVColumn.DataPropertyName = "Title";
// this.titleGVColumn.HeaderText = "Title";
this.dataGridViewTextBoxColumn2.DataPropertyName = "Authors"; this.titleGVColumn.Name = "titleGVColumn";
this.dataGridViewTextBoxColumn2.HeaderText = "Authors"; this.titleGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; this.titleGVColumn.Width = 200;
this.dataGridViewTextBoxColumn2.ReadOnly = true; //
// // authorsGVColumn
// dataGridViewTextBoxColumn3 //
// this.authorsGVColumn.DataPropertyName = "Authors";
this.dataGridViewTextBoxColumn3.DataPropertyName = "Narrators"; this.authorsGVColumn.HeaderText = "Authors";
this.dataGridViewTextBoxColumn3.HeaderText = "Narrators"; this.authorsGVColumn.Name = "authorsGVColumn";
this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3"; this.authorsGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn3.ReadOnly = true; //
// // narratorsGVColumn
// dataGridViewTextBoxColumn4 //
// this.narratorsGVColumn.DataPropertyName = "Narrators";
this.dataGridViewTextBoxColumn4.DataPropertyName = "Length"; this.narratorsGVColumn.HeaderText = "Narrators";
this.dataGridViewTextBoxColumn4.HeaderText = "Length"; this.narratorsGVColumn.Name = "narratorsGVColumn";
this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4"; this.narratorsGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn4.ReadOnly = true; //
this.dataGridViewTextBoxColumn4.ToolTipText = "Recording Length"; // lengthGVColumn
// //
// dataGridViewTextBoxColumn5 this.lengthGVColumn.DataPropertyName = "Length";
// this.lengthGVColumn.HeaderText = "Length";
this.dataGridViewTextBoxColumn5.DataPropertyName = "Series"; this.lengthGVColumn.Name = "lengthGVColumn";
this.dataGridViewTextBoxColumn5.HeaderText = "Series"; this.lengthGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5"; this.lengthGVColumn.ToolTipText = "Recording Length";
this.dataGridViewTextBoxColumn5.ReadOnly = true; //
// // seriesGVColumn
// dataGridViewTextBoxColumn6 //
// this.seriesGVColumn.DataPropertyName = "Series";
this.dataGridViewTextBoxColumn6.DataPropertyName = "Description"; this.seriesGVColumn.HeaderText = "Series";
this.dataGridViewTextBoxColumn6.HeaderText = "Description"; this.seriesGVColumn.Name = "seriesGVColumn";
this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6"; this.seriesGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn6.ReadOnly = true; //
// // descriptionGVColumn
// dataGridViewTextBoxColumn7 //
// this.descriptionGVColumn.DataPropertyName = "Description";
this.dataGridViewTextBoxColumn7.DataPropertyName = "Category"; this.descriptionGVColumn.HeaderText = "Description";
this.dataGridViewTextBoxColumn7.HeaderText = "Category"; this.descriptionGVColumn.Name = "descriptionGVColumn";
this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7"; this.descriptionGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn7.ReadOnly = true; this.descriptionGVColumn.Resizable = System.Windows.Forms.DataGridViewTriState.False;
// //
// ProductRating // categoryGVColumn
// //
this.dataGridViewTextBoxColumn8.DataPropertyName = "ProductRating"; this.categoryGVColumn.DataPropertyName = "Category";
this.dataGridViewTextBoxColumn8.HeaderText = "Product Rating"; this.categoryGVColumn.HeaderText = "Category";
this.dataGridViewTextBoxColumn8.Name = "ProductRating"; this.categoryGVColumn.Name = "categoryGVColumn";
this.dataGridViewTextBoxColumn8.ReadOnly = true; this.categoryGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn8.Width = 108; //
// // productRatingGVColumn
// PurchaseDate //
// this.productRatingGVColumn.DataPropertyName = "ProductRating";
this.dataGridViewTextBoxColumn9.DataPropertyName = "PurchaseDate"; this.productRatingGVColumn.HeaderText = "Product Rating";
this.dataGridViewTextBoxColumn9.HeaderText = "Purchase Date"; this.productRatingGVColumn.Name = "productRatingGVColumn";
this.dataGridViewTextBoxColumn9.Name = "PurchaseDate"; this.productRatingGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn9.ReadOnly = true; this.productRatingGVColumn.Width = 108;
// //
// MyRating // purchaseDateGVColumn
// //
this.dataGridViewTextBoxColumn10.DataPropertyName = "MyRating"; this.purchaseDateGVColumn.DataPropertyName = "PurchaseDate";
this.dataGridViewTextBoxColumn10.HeaderText = "My Rating"; this.purchaseDateGVColumn.HeaderText = "Purchase Date";
this.dataGridViewTextBoxColumn10.Name = "MyRating"; this.purchaseDateGVColumn.Name = "purchaseDateGVColumn";
this.dataGridViewTextBoxColumn10.ReadOnly = true; this.purchaseDateGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn10.Width = 108; //
// // myRatingGVColumn
// dataGridViewTextBoxColumn11 //
// this.myRatingGVColumn.DataPropertyName = "MyRating";
this.dataGridViewTextBoxColumn11.DataPropertyName = "Misc"; this.myRatingGVColumn.HeaderText = "My Rating";
this.dataGridViewTextBoxColumn11.HeaderText = "Misc"; this.myRatingGVColumn.Name = "myRatingGVColumn";
this.dataGridViewTextBoxColumn11.Name = "dataGridViewTextBoxColumn11"; this.myRatingGVColumn.ReadOnly = true;
this.dataGridViewTextBoxColumn11.ReadOnly = true; this.myRatingGVColumn.Width = 108;
this.dataGridViewTextBoxColumn11.Width = 135; //
// // miscGVColumn
// dataGridViewImageButtonBoxColumn2 //
// this.miscGVColumn.DataPropertyName = "Misc";
this.dataGridViewImageButtonBoxColumn2.DataPropertyName = "DisplayTags"; this.miscGVColumn.HeaderText = "Misc";
this.dataGridViewImageButtonBoxColumn2.HeaderText = "Tags and Details"; this.miscGVColumn.Name = "miscGVColumn";
this.dataGridViewImageButtonBoxColumn2.Name = "dataGridViewImageButtonBoxColumn2"; this.miscGVColumn.ReadOnly = true;
this.dataGridViewImageButtonBoxColumn2.ReadOnly = true; this.miscGVColumn.Width = 135;
this.dataGridViewImageButtonBoxColumn2.Resizable = System.Windows.Forms.DataGridViewTriState.False; //
this.dataGridViewImageButtonBoxColumn2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; // tagAndDetailsGVColumn
// //
// ProductsGrid this.tagAndDetailsGVColumn.DataPropertyName = "DisplayTags";
// this.tagAndDetailsGVColumn.HeaderText = "Tags and Details";
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.tagAndDetailsGVColumn.Name = "tagAndDetailsGVColumn";
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.tagAndDetailsGVColumn.ReadOnly = true;
this.Controls.Add(this.gridEntryDataGridView); this.tagAndDetailsGVColumn.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.tagAndDetailsGVColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.Name = "ProductsGrid"; //
this.Size = new System.Drawing.Size(1510, 380); // contextMenuStrip1
((System.ComponentModel.ISupportInitialize)(this.gridEntryBindingSource)).EndInit(); //
((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).EndInit(); this.contextMenuStrip1.Name = "contextMenuStrip1";
this.ResumeLayout(false); this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
//
// ProductsGrid
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.gridEntryDataGridView);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "ProductsGrid";
this.Size = new System.Drawing.Size(1510, 380);
((System.ComponentModel.ISupportInitialize)(this.gridEntryBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.gridEntryDataGridView)).EndInit();
this.ResumeLayout(false);
} }
@ -224,19 +236,20 @@
private LibationWinForms.SyncBindingSource gridEntryBindingSource; private LibationWinForms.SyncBindingSource gridEntryBindingSource;
private System.Windows.Forms.DataGridView gridEntryDataGridView; private System.Windows.Forms.DataGridView gridEntryDataGridView;
private LiberateDataGridViewImageButtonColumn dataGridViewImageButtonBoxColumn1; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.DataGridViewImageColumn dataGridViewImageColumn1; private LiberateDataGridViewImageButtonColumn liberateGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; private System.Windows.Forms.DataGridViewImageColumn coverGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; private System.Windows.Forms.DataGridViewTextBoxColumn titleGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; private System.Windows.Forms.DataGridViewTextBoxColumn authorsGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; private System.Windows.Forms.DataGridViewTextBoxColumn narratorsGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn5; private System.Windows.Forms.DataGridViewTextBoxColumn lengthGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn6; private System.Windows.Forms.DataGridViewTextBoxColumn seriesGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7; private System.Windows.Forms.DataGridViewTextBoxColumn descriptionGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn8; private System.Windows.Forms.DataGridViewTextBoxColumn categoryGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn9; private System.Windows.Forms.DataGridViewTextBoxColumn productRatingGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn10; private System.Windows.Forms.DataGridViewTextBoxColumn purchaseDateGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn11; private System.Windows.Forms.DataGridViewTextBoxColumn myRatingGVColumn;
private EditTagsDataGridViewImageButtonColumn dataGridViewImageButtonBoxColumn2; private System.Windows.Forms.DataGridViewTextBoxColumn miscGVColumn;
} private EditTagsDataGridViewImageButtonColumn tagAndDetailsGVColumn;
}
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@ -8,6 +9,7 @@ using Dinah.Core;
using Dinah.Core.DataBinding; using Dinah.Core.DataBinding;
using Dinah.Core.Threading; using Dinah.Core.Threading;
using Dinah.Core.Windows.Forms; using Dinah.Core.Windows.Forms;
using LibationFileManager;
using LibationWinForms.Dialogs; using LibationWinForms.Dialogs;
namespace LibationWinForms namespace LibationWinForms
@ -44,6 +46,7 @@ namespace LibationWinForms
EnableDoubleBuffering(); EnableDoubleBuffering();
} }
private void EnableDoubleBuffering() private void EnableDoubleBuffering()
{ {
var propertyInfo = _dataGridView.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); var propertyInfo = _dataGridView.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
@ -56,20 +59,36 @@ namespace LibationWinForms
private async void DataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) private async void DataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{ {
// handle grid button click: https://stackoverflow.com/a/13687844 // handle grid button click: https://stackoverflow.com/a/13687844
if (e.RowIndex < 0 || _dataGridView.Columns[e.ColumnIndex] is not DataGridViewButtonColumn) if (e.RowIndex < 0)
return; return;
var liveGridEntry = getGridEntry(e.RowIndex); var clickedColumn = _dataGridView.Columns[e.ColumnIndex];
switch (_dataGridView.Columns[e.ColumnIndex].DataPropertyName) if (clickedColumn == liberateGVColumn)
await Liberate_Click(getGridEntry(e.RowIndex));
else if (clickedColumn == tagAndDetailsGVColumn)
Details_Click(getGridEntry(e.RowIndex));
else if (clickedColumn == descriptionGVColumn)
Description_Click(getGridEntry(e.RowIndex), _dataGridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false));
}
private void Description_Click(GridEntry liveGridEntry, Rectangle cellDisplay)
{
var displayWindow = new DescriptionDisplay
{ {
case nameof(liveGridEntry.Liberate): SpawnLocation = PointToScreen(cellDisplay.Location + new Size(cellDisplay.Width, 0)),
await Liberate_Click(liveGridEntry); DescriptionText = liveGridEntry.LongDescription,
break; BorderThickness = 2,
case nameof(liveGridEntry.DisplayTags): };
Details_Click(liveGridEntry);
break; void CloseWindow (object o, EventArgs e)
{
displayWindow.Close();
} }
_dataGridView.Scroll += CloseWindow;
displayWindow.FormClosed += (_,_) => _dataGridView.Scroll -= CloseWindow;
displayWindow.Show(this);
} }
private static async Task Liberate_Click(GridEntry liveGridEntry) private static async Task Liberate_Click(GridEntry liveGridEntry)
@ -79,7 +98,7 @@ namespace LibationWinForms
// liberated: open explorer to file // liberated: open explorer to file
if (libraryBook.Book.Audio_Exists) if (libraryBook.Book.Audio_Exists)
{ {
var filePath = LibationFileManager.AudibleFileStorage.Audio.GetPath(libraryBook.Book.AudibleProductId); var filePath = AudibleFileStorage.Audio.GetPath(libraryBook.Book.AudibleProductId);
if (!Go.To.File(filePath)) if (!Go.To.File(filePath))
{ {
var suffix = string.IsNullOrWhiteSpace(filePath) ? "" : $":\r\n{filePath}"; var suffix = string.IsNullOrWhiteSpace(filePath) ? "" : $":\r\n{filePath}";
@ -225,5 +244,108 @@ namespace LibationWinForms
#region DataGridView Macro #region DataGridView Macro
private GridEntry getGridEntry(int rowIndex) => _dataGridView.GetBoundItem<GridEntry>(rowIndex); private GridEntry getGridEntry(int rowIndex) => _dataGridView.GetBoundItem<GridEntry>(rowIndex);
#endregion #endregion
#region Column Customizations
protected override void OnVisibleChanged(EventArgs e)
{
contextMenuStrip1.Items.Add(new ToolStripLabel("Show / Hide Columns"));
contextMenuStrip1.Items.Add(new ToolStripSeparator());
//Restore Grid Display Settings
var config = Configuration.Instance;
var gridColumnsVisibilities = config.GridColumnsVisibilities;
var gridColumnsWidths = config.GridColumnsWidths;
var displayIndices = config.GridColumnsDisplayIndices;
var cmsKiller = new ContextMenuStrip();
foreach (DataGridViewColumn column in _dataGridView.Columns)
{
var itemName = column.DataPropertyName;
var visible = gridColumnsVisibilities.GetValueOrDefault(itemName, true);
var menuItem = new ToolStripMenuItem()
{
Text = column.HeaderText,
Checked = visible,
Tag = itemName
};
menuItem.Click += HideMenuItem_Click;
contextMenuStrip1.Items.Add(menuItem);
column.Width = gridColumnsWidths.GetValueOrDefault(itemName, column.Width);
column.MinimumWidth = 10;
column.HeaderCell.ContextMenuStrip = contextMenuStrip1;
column.Visible = visible;
//Setting a default ContextMenuStrip will allow the columns to handle the
//Show() event so it is not passed up to the _dataGridView.ContextMenuStrip.
//This allows the ContextMenuStrip to be shown if right-clicking in the gray
//background of _dataGridView but not shown if right-clicking inside cells.
column.ContextMenuStrip = cmsKiller;
}
//We must set DisplayIndex properties in ascending order
foreach (var itemName in displayIndices.OrderBy(i => i.Value).Select(i => i.Key))
{
var column = _dataGridView.Columns
.Cast<DataGridViewColumn>()
.Single(c => c.DataPropertyName == itemName);
column.DisplayIndex = displayIndices.GetValueOrDefault(itemName, column.Index);
}
base.OnVisibleChanged(e);
}
private void gridEntryDataGridView_ColumnDisplayIndexChanged(object sender, DataGridViewColumnEventArgs e)
{
var config = Configuration.Instance;
var dictionary = config.GridColumnsDisplayIndices;
dictionary[e.Column.DataPropertyName] = e.Column.DisplayIndex;
config.GridColumnsDisplayIndices = dictionary;
}
private void gridEntryDataGridView_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
{
var config = Configuration.Instance;
var dictionary = config.GridColumnsWidths;
dictionary[e.Column.DataPropertyName] = e.Column.Width;
config.GridColumnsWidths = dictionary;
}
private void HideMenuItem_Click(object sender, EventArgs e)
{
var menuItem = sender as ToolStripMenuItem;
var propertyName = menuItem.Tag as string;
var column = _dataGridView.Columns
.Cast<DataGridViewColumn>()
.FirstOrDefault(c => c.DataPropertyName == propertyName);
if (column != null)
{
var visible = menuItem.Checked;
menuItem.Checked = !visible;
column.Visible = !visible;
var config = Configuration.Instance;
var dictionary = config.GridColumnsVisibilities;
dictionary[propertyName] = column.Visible;
config.GridColumnsVisibilities = dictionary;
}
}
private void gridEntryDataGridView_CellToolTipTextNeeded(object sender, DataGridViewCellToolTipTextNeededEventArgs e)
{
if (e.ColumnIndex == descriptionGVColumn.Index)
e.ToolTipText = "Click to see full description";
}
#endregion
} }
} }

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
@ -61,4 +60,10 @@
<metadata name="gridEntryBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="gridEntryBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>197, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>81</value>
</metadata>
</root> </root>