#398 - new feature: right-click, copy
This commit is contained in:
parent
451af7bea9
commit
ce711a36ba
12 changed files with 88 additions and 13 deletions
|
|
@ -28,9 +28,13 @@ namespace LibationWinForms.GridView
|
|||
[Browsable(false)] public abstract DateTime DateAdded { get; }
|
||||
[Browsable(false)] protected Book Book => LibraryBook.Book;
|
||||
|
||||
#region Model properties exposed to the view
|
||||
[Browsable(false)] public abstract bool IsSeries { get; }
|
||||
[Browsable(false)] public abstract bool IsEpisode { get; }
|
||||
[Browsable(false)] public abstract bool IsBook { get; }
|
||||
|
||||
protected RemoveStatus _remove = RemoveStatus.NotRemoved;
|
||||
#region Model properties exposed to the view
|
||||
|
||||
protected RemoveStatus _remove = RemoveStatus.NotRemoved;
|
||||
public abstract RemoveStatus Remove { get; set; }
|
||||
|
||||
public abstract LiberateButtonStatus Liberate { get; }
|
||||
|
|
@ -56,11 +60,11 @@ namespace LibationWinForms.GridView
|
|||
public string MyRating { get; protected set; }
|
||||
public abstract string DisplayTags { get; }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Sorting
|
||||
#region Sorting
|
||||
|
||||
public GridEntry() => _memberValues = CreateMemberValueDictionary();
|
||||
public GridEntry() => _memberValues = CreateMemberValueDictionary();
|
||||
|
||||
// These methods are implementation of Dinah.Core.DataBinding.IMemberComparable
|
||||
// Used by GridEntryBindingList for all sorting
|
||||
|
|
|
|||
|
|
@ -14,9 +14,13 @@ namespace LibationWinForms.GridView
|
|||
[Browsable(false)] public override DateTime DateAdded => LibraryBook.DateAdded;
|
||||
[Browsable(false)] public SeriesEntry Parent { get; init; }
|
||||
|
||||
#region Model properties exposed to the view
|
||||
[Browsable(false)] public override bool IsSeries => false;
|
||||
[Browsable(false)] public override bool IsEpisode => Parent is not null;
|
||||
[Browsable(false)] public override bool IsBook => Parent is null;
|
||||
|
||||
private DateTime lastStatusUpdate = default;
|
||||
#region Model properties exposed to the view
|
||||
|
||||
private DateTime lastStatusUpdate = default;
|
||||
private LiberatedStatus _bookStatus;
|
||||
private LiberatedStatus? _pdfStatus;
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@
|
|||
this.gridEntryDataGridView.Size = new System.Drawing.Size(1570, 380);
|
||||
this.gridEntryDataGridView.TabIndex = 0;
|
||||
this.gridEntryDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellContentClick);
|
||||
this.gridEntryDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.gridEntryDataGridView_CellToolTipTextNeeded);
|
||||
this.gridEntryDataGridView.CellContextMenuStripNeeded += new System.Windows.Forms.DataGridViewCellContextMenuStripNeededEventHandler(this.gridEntryDataGridView_CellContextMenuStripNeeded);
|
||||
this.gridEntryDataGridView.CellToolTipTextNeeded += new System.Windows.Forms.DataGridViewCellToolTipTextNeededEventHandler(this.gridEntryDataGridView_CellToolTipTextNeeded);
|
||||
//
|
||||
// removeGVColumn
|
||||
//
|
||||
|
|
|
|||
|
|
@ -100,7 +100,54 @@ namespace LibationWinForms.GridView
|
|||
}
|
||||
}
|
||||
|
||||
private GridEntry getGridEntry(int rowIndex) => gridEntryDataGridView.GetBoundItem<GridEntry>(rowIndex);
|
||||
private void gridEntryDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
|
||||
{
|
||||
var dgv = (DataGridView)sender;
|
||||
|
||||
// cover
|
||||
if (e.ColumnIndex == coverGVColumn.Index)
|
||||
return;
|
||||
|
||||
// any non-stop light
|
||||
if (e.ColumnIndex != liberateGVColumn.Index)
|
||||
{
|
||||
var copyContextMenu = new ContextMenuStrip();
|
||||
copyContextMenu.Items.Add("Copy", null, (_, __) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var text = dgv[e.ColumnIndex, e.RowIndex].Value.ToString();
|
||||
InteropFactory.Create().CopyTextToClipboard(text);
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
|
||||
e.ContextMenuStrip = copyContextMenu;
|
||||
return;
|
||||
}
|
||||
|
||||
// else: stop light
|
||||
|
||||
var entry = getGridEntry(e.RowIndex);
|
||||
if (entry.IsSeries)
|
||||
return;
|
||||
|
||||
// \Visual Studio 2022\Libation\Source\LibationAvalonia\Views\ProductsDisplay.axaml
|
||||
/*
|
||||
<ContextMenu IsVisible="{Binding !Liberate.IsSeries}">
|
||||
<MenuItem Header="Item 1" Click="ContextMenuItem1_Click" />
|
||||
<MenuItem Header="Item 2" Click="ContextMenuItem2_Click" />
|
||||
<MenuItem Header="Item 3" Click="ContextMenuItem3_Click" />
|
||||
</ContextMenu>
|
||||
*/
|
||||
//var contextMenu = new ContextMenuStrip();
|
||||
//contextMenu.Items.Add("Item 1");
|
||||
//contextMenu.Items.Add("Item 2");
|
||||
//contextMenu.Items.Add("Item 3");
|
||||
//e.ContextMenuStrip = contextMenu;
|
||||
}
|
||||
|
||||
private GridEntry getGridEntry(int rowIndex) => gridEntryDataGridView.GetBoundItem<GridEntry>(rowIndex);
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,11 @@ namespace LibationWinForms.GridView
|
|||
[Browsable(false)] public List<LibraryBookEntry> Children { get; }
|
||||
[Browsable(false)] public override DateTime DateAdded => Children.Max(c => c.DateAdded);
|
||||
|
||||
private bool suspendCounting = false;
|
||||
[Browsable(false)] public override bool IsSeries => true;
|
||||
[Browsable(false)] public override bool IsEpisode => false;
|
||||
[Browsable(false)] public override bool IsBook => false;
|
||||
|
||||
private bool suspendCounting = false;
|
||||
public void ChildRemoveUpdate()
|
||||
{
|
||||
if (suspendCounting) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue