Add user rating editing to grid

This commit is contained in:
Michael Bucari-Tovo 2022-12-30 17:00:16 -07:00
parent 3a44bef0d9
commit c900fe8461
24 changed files with 942 additions and 62 deletions

View file

@ -1,7 +1,9 @@
using DataLayer;
using ApplicationServices;
using DataLayer;
using Dinah.Core;
using Dinah.Core.DataBinding;
using Dinah.Core.WindowsDesktop.Drawing;
using FileLiberator;
using LibationFileManager;
using System;
using System.Collections;
@ -9,6 +11,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
namespace LibationWinForms.GridView
{
@ -57,14 +60,44 @@ namespace LibationWinForms.GridView
public string Misc { get; protected set; }
public string Description { get; protected set; }
public string ProductRating { get; protected set; }
public string MyRating { get; protected set; }
protected Rating _myRating;
public Rating MyRating
{
get => _myRating;
set
{
if (_myRating != value
&& (value.OverallRating + value.PerformanceRating + value.StoryRating) > 0
&& updateReviewTask?.IsCompleted is not false)
{
updateReviewTask = UpdateRating(value);
}
}
}
public abstract string DisplayTags { get; }
#endregion
#endregion
#region Sorting
#region User rating
public GridEntry() => _memberValues = CreateMemberValueDictionary();
private Task updateReviewTask;
private async Task UpdateRating(Rating rating)
{
var api = await LibraryBook.GetApiAsync();
if (await api.ReviewAsync(Book.AudibleProductId, (int)rating.OverallRating, (int)rating.PerformanceRating, (int)rating.StoryRating))
{
_myRating = rating;
LibraryBook.Book.UpdateUserDefinedItem(null, null, null, rating);
}
this.NotifyPropertyChanged(nameof(MyRating));
}
#endregion
#region Sorting
public GridEntry() => _memberValues = CreateMemberValueDictionary();
// These methods are implementation of Dinah.Core.DataBinding.IMemberComparable
// Used by GridEntryBindingList for all sorting

View file

@ -80,7 +80,7 @@ namespace LibationWinForms.GridView
Title = Book.Title;
Series = Book.SeriesNames();
Length = Book.LengthInMinutes == 0 ? "" : $"{Book.LengthInMinutes / 60} hr {Book.LengthInMinutes % 60} min";
MyRating = Book.UserDefinedItem.Rating?.ToStarString()?.DefaultIfNullOrWhiteSpace("");
MyRating = Book.UserDefinedItem.Rating;
PurchaseDate = libraryBook.DateAdded.ToString("d");
ProductRating = Book.Rating?.ToStarString()?.DefaultIfNullOrWhiteSpace("");
Authors = Book.AuthorNames();

View file

@ -0,0 +1,73 @@
using DataLayer;
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
namespace LibationWinForms.GridView
{
public class MyRatingGridViewColumn : DataGridViewColumn
{
public MyRatingGridViewColumn() : base(new MyRatingGridViewCell()) { }
public override DataGridViewCell CellTemplate
{
get => base.CellTemplate;
set
{
if (value is not MyRatingGridViewCell)
throw new InvalidCastException("Must be a MyRatingGridViewCell");
base.CellTemplate = value;
}
}
}
internal class MyRatingGridViewCell : DataGridViewTextBoxCell
{
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
{
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
var ctl = DataGridView.EditingControl as RatingPicker;
ctl.Rating =
Value is Rating rating
? rating
: (Rating)DefaultNewRowValue;
}
public override object ParseFormattedValue(object formattedValue, DataGridViewCellStyle cellStyle, TypeConverter formattedValueTypeConverter, TypeConverter valueTypeConverter)
{
const char SOLID_STAR = '★';
if (formattedValue is string s)
{
int overall = 0, performance = 0, story = 0;
foreach (var line in s.Split('\n'))
{
if (line.Contains("Overall"))
overall = line.Count(c => c == SOLID_STAR);
else if (line.Contains("Perform"))
performance = line.Count(c => c == SOLID_STAR);
else if (line.Contains("Story"))
story = line.Count(c => c == SOLID_STAR);
}
return new Rating(overall, performance, story);
}
else
return DefaultNewRowValue;
}
protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
=> value is Rating rating
? rating.ToStarString()
: base.GetFormattedValue(value, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context);
public override Type EditType => typeof(RatingPicker);
public override object DefaultNewRowValue => new Rating(0, 0, 0);
public override Type ValueType => typeof(Rating);
}
}

View file

@ -43,7 +43,7 @@
this.categoryGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.productRatingGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.purchaseDateGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.myRatingGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.myRatingGVColumn = new MyRatingGridViewColumn();
this.miscGVColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.tagAndDetailsGVColumn = new LibationWinForms.GridView.EditTagsDataGridViewImageButtonColumn();
this.showHideColumnsContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
@ -204,7 +204,7 @@
this.myRatingGVColumn.DataPropertyName = "MyRating";
this.myRatingGVColumn.HeaderText = "My Rating";
this.myRatingGVColumn.Name = "myRatingGVColumn";
this.myRatingGVColumn.ReadOnly = true;
this.myRatingGVColumn.ReadOnly = false;
this.myRatingGVColumn.Width = 108;
//
// miscGVColumn
@ -265,7 +265,7 @@
private System.Windows.Forms.DataGridViewTextBoxColumn categoryGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn productRatingGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn purchaseDateGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn myRatingGVColumn;
private MyRatingGridViewColumn myRatingGVColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn miscGVColumn;
private EditTagsDataGridViewImageButtonColumn tagAndDetailsGVColumn;
}

View file

@ -40,6 +40,8 @@ namespace LibationWinForms.GridView
EnableDoubleBuffering();
gridEntryDataGridView.Scroll += (_, s) => Scroll?.Invoke(this, s);
removeGVColumn.Frozen = false;
gridEntryDataGridView.EditMode = DataGridViewEditMode.EditOnEnter;
}
private void EnableDoubleBuffering()
@ -49,6 +51,8 @@ namespace LibationWinForms.GridView
propertyInfo.SetValue(gridEntryDataGridView, true, null);
}
#region Button controls
private void DataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{

View file

@ -0,0 +1,348 @@
namespace LibationWinForms.GridView
{
partial class RatingPicker
{
/// <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 Component 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.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.label14 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel3.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Margin = new System.Windows.Forms.Padding(0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(12, 15);
this.label1.TabIndex = 0;
this.label1.Text = "☆";
this.label1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label1.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label1.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label2
//
this.label2.Location = new System.Drawing.Point(12, 0);
this.label2.Margin = new System.Windows.Forms.Padding(0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(12, 15);
this.label2.TabIndex = 1;
this.label2.Text = "☆";
this.label2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label2.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label2.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label3
//
this.label3.Location = new System.Drawing.Point(24, 0);
this.label3.Margin = new System.Windows.Forms.Padding(0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(12, 15);
this.label3.TabIndex = 3;
this.label3.Text = "☆";
this.label3.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label3.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label3.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label4
//
this.label4.Location = new System.Drawing.Point(36, 0);
this.label4.Margin = new System.Windows.Forms.Padding(0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(12, 15);
this.label4.TabIndex = 2;
this.label4.Text = "☆";
this.label4.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label4.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label4.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label5
//
this.label5.Location = new System.Drawing.Point(48, 0);
this.label5.Margin = new System.Windows.Forms.Padding(0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(12, 15);
this.label5.TabIndex = 4;
this.label5.Text = "☆";
this.label5.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label5.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label5.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// panel1
//
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.label4);
this.panel1.Controls.Add(this.label5);
this.panel1.Location = new System.Drawing.Point(45, 13);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(60, 15);
this.panel1.TabIndex = 5;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(0, 13);
this.label6.Margin = new System.Windows.Forms.Padding(0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(47, 15);
this.label6.TabIndex = 6;
this.label6.Text = "Overall:";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label7.Location = new System.Drawing.Point(0, 32);
this.label7.Margin = new System.Windows.Forms.Padding(0);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(46, 15);
this.label7.TabIndex = 8;
this.label7.Text = "Perfrm:";
//
// panel2
//
this.panel2.Controls.Add(this.label8);
this.panel2.Controls.Add(this.label9);
this.panel2.Controls.Add(this.label10);
this.panel2.Controls.Add(this.label11);
this.panel2.Controls.Add(this.label12);
this.panel2.Location = new System.Drawing.Point(45, 32);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(60, 15);
this.panel2.TabIndex = 7;
//
// label8
//
this.label8.Location = new System.Drawing.Point(0, 0);
this.label8.Margin = new System.Windows.Forms.Padding(0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(12, 15);
this.label8.TabIndex = 0;
this.label8.Text = "☆";
this.label8.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label8.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label8.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label9
//
this.label9.Location = new System.Drawing.Point(12, 0);
this.label9.Margin = new System.Windows.Forms.Padding(0);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(12, 15);
this.label9.TabIndex = 1;
this.label9.Text = "☆";
this.label9.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label9.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label9.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label10
//
this.label10.Location = new System.Drawing.Point(24, 0);
this.label10.Margin = new System.Windows.Forms.Padding(0);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(12, 15);
this.label10.TabIndex = 3;
this.label10.Text = "☆";
this.label10.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label10.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label10.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label11
//
this.label11.Location = new System.Drawing.Point(36, 0);
this.label11.Margin = new System.Windows.Forms.Padding(0);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(12, 15);
this.label11.TabIndex = 2;
this.label11.Text = "☆";
this.label11.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label11.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label11.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label12
//
this.label12.Location = new System.Drawing.Point(48, 0);
this.label12.Margin = new System.Windows.Forms.Padding(0);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(12, 15);
this.label12.TabIndex = 4;
this.label12.Text = "☆";
this.label12.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label12.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label12.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(0, 51);
this.label13.Margin = new System.Windows.Forms.Padding(0);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(37, 15);
this.label13.TabIndex = 10;
this.label13.Text = "Story:";
//
// panel3
//
this.panel3.Controls.Add(this.label14);
this.panel3.Controls.Add(this.label15);
this.panel3.Controls.Add(this.label16);
this.panel3.Controls.Add(this.label17);
this.panel3.Controls.Add(this.label18);
this.panel3.Location = new System.Drawing.Point(45, 51);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(60, 15);
this.panel3.TabIndex = 9;
//
// label14
//
this.label14.Location = new System.Drawing.Point(0, 0);
this.label14.Margin = new System.Windows.Forms.Padding(0);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(12, 15);
this.label14.TabIndex = 0;
this.label14.Text = "☆";
this.label14.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label14.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label14.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label15
//
this.label15.Location = new System.Drawing.Point(12, 0);
this.label15.Margin = new System.Windows.Forms.Padding(0);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(12, 15);
this.label15.TabIndex = 1;
this.label15.Text = "☆";
this.label15.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label15.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label15.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label16
//
this.label16.Location = new System.Drawing.Point(24, 0);
this.label16.Margin = new System.Windows.Forms.Padding(0);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(12, 15);
this.label16.TabIndex = 3;
this.label16.Text = "☆";
this.label16.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label16.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label16.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label17
//
this.label17.Location = new System.Drawing.Point(36, 0);
this.label17.Margin = new System.Windows.Forms.Padding(0);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(12, 15);
this.label17.TabIndex = 2;
this.label17.Text = "☆";
this.label17.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label17.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label17.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// label18
//
this.label18.Location = new System.Drawing.Point(48, 0);
this.label18.Margin = new System.Windows.Forms.Padding(0);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(12, 15);
this.label18.TabIndex = 4;
this.label18.Text = "☆";
this.label18.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Star_MouseClick);
this.label18.MouseEnter += new System.EventHandler(this.Star_MouseEnter);
this.label18.MouseLeave += new System.EventHandler(this.Star_MouseLeave);
//
// RatingPicker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label13);
this.Controls.Add(this.panel3);
this.Controls.Add(this.label7);
this.Controls.Add(this.panel2);
this.Controls.Add(this.label6);
this.Controls.Add(this.panel1);
this.Name = "RatingPicker";
this.Size = new System.Drawing.Size(108, 80);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label18;
}
}

View file

@ -0,0 +1,142 @@
using DataLayer;
using Mpeg4Lib.Boxes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LibationWinForms.GridView
{
public partial class RatingPicker : UserControl, IDataGridViewEditingControl
{
private const string SOLID_STAR = "★";
private const string HOLLOW_STAR = "☆";
private Rating _rating;
public Rating Rating {
get => _rating;
set
{
_rating = value;
int rating = 0;
foreach (Label star in panel1.Controls)
star.Tag = star.Text = _rating.OverallRating > rating++ ? SOLID_STAR : HOLLOW_STAR;
rating = 0;
foreach (Label star in panel2.Controls)
star.Tag = star.Text = _rating.PerformanceRating > rating++ ? SOLID_STAR : HOLLOW_STAR;
rating = 0;
foreach (Label star in panel3.Controls)
star.Tag = star.Text = _rating.StoryRating > rating++ ? SOLID_STAR : HOLLOW_STAR;
}
}
public RatingPicker()
{
InitializeComponent();
}
private void Star_MouseEnter(object sender, EventArgs e)
{
var thisTbox = sender as Label;
var stackPanel = thisTbox.Parent as Panel;
var star = SOLID_STAR;
foreach (Label child in stackPanel.Controls)
{
child.Text = star;
if (child == thisTbox) star = HOLLOW_STAR;
}
}
private void Star_MouseLeave(object sender, EventArgs e)
{
var thisTbox = sender as Label;
var panel = thisTbox.Parent as Panel;
//Artifically shrink rectangle to guarantee mouse is outside when exiting from the left (negative X)
var clientPt = panel.PointToClient(MousePosition);
var rect = new Rectangle(0, 0, panel.ClientRectangle.Width - 2, panel.ClientRectangle.Height);
if (!rect.Contains(clientPt.X - 2, clientPt.Y))
{
//Restore defaults
foreach (Label child in panel.Controls)
child.Text = (string)child.Tag;
}
}
private void Star_MouseClick(object sender, MouseEventArgs e)
{
var overall = Rating.OverallRating;
var perform = Rating.PerformanceRating;
var story = Rating.StoryRating;
var thisTbox = sender as Label;
var panel = thisTbox.Parent as Panel;
int newRating = 0;
foreach (var child in panel.Controls)
{
newRating++;
if (child == thisTbox) break;
}
if (panel == panel1)
overall = newRating;
else if (panel == panel2)
perform = newRating;
else if (panel == panel3)
story = newRating;
if (overall + perform + story == 0f) return;
Rating = new Rating(overall, perform, story);
EditingControlValueChanged = true;
EditingControlDataGridView.NotifyCurrentCellDirty(true);
}
DataGridView dataGridView;
private bool valueChanged = false;
int rowIndex;
#region IDataGridViewEditingControl
public DataGridView EditingControlDataGridView { get => dataGridView; set => dataGridView = value; }
public object EditingControlFormattedValue { get => Rating.ToStarString(); set { } }
public int EditingControlRowIndex { get => rowIndex; set => rowIndex = value; }
public bool EditingControlValueChanged { get => valueChanged; set => valueChanged = value; }
public Cursor EditingPanelCursor => base.Cursor;
public bool RepositionEditingControlOnValueChange => false;
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
{
this.Font = dataGridViewCellStyle.Font;
this.ForeColor = dataGridViewCellStyle.ForeColor;
this.BackColor = dataGridViewCellStyle.BackColor;
}
public bool EditingControlWantsInputKey(Keys keyData, bool dataGridViewWantsInputKey)
{
switch (keyData & Keys.KeyCode)
{
case Keys.Enter:
case Keys.Escape:
return true;
default:
return !dataGridViewWantsInputKey;
}
}
public object GetEditingControlFormattedValue(DataGridViewDataErrorContexts context) => EditingControlFormattedValue;
public void PrepareEditingControlForEdit(bool selectAll) { }
#endregion
}
}

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

@ -89,7 +89,7 @@ namespace LibationWinForms.GridView
Title = Book.Title;
Series = Book.SeriesNames();
MyRating = Book.UserDefinedItem.Rating?.ToStarString()?.DefaultIfNullOrWhiteSpace("");
MyRating = Book.UserDefinedItem.Rating;
PurchaseDate = Children.Min(c => c.LibraryBook.DateAdded).ToString("d");
ProductRating = Book.Rating?.ToStarString()?.DefaultIfNullOrWhiteSpace("");
Authors = Book.AuthorNames();