#398 - new feature: right-click, copy

This commit is contained in:
Robert McRackan 2022-12-12 15:03:20 -05:00
parent 451af7bea9
commit ce711a36ba
12 changed files with 88 additions and 13 deletions

View File

@ -44,6 +44,7 @@
<DataTemplate>
<Button Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="LiberateButton_Click" ToolTip.Tip="{Binding Liberate.ToolTip}">
<Image Stretch="None" Source="{Binding Liberate.Image}" />
<!--
<Button.ContextMenu>
<ContextMenu IsVisible="{Binding !Liberate.IsSeries}">
<MenuItem Header="Item 1" Click="ContextMenuItem1_Click" />
@ -51,6 +52,7 @@
<MenuItem Header="Item 3" Click="ContextMenuItem3_Click" />
</ContextMenu>
</Button.ContextMenu>
-->
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>

View File

@ -6,5 +6,6 @@ namespace LibationFileManager
{
void SetFolderIcon(string image, string directory);
void DeleteFolderIcon(string directory);
void CopyTextToClipboard(string text);
}
}

View File

@ -19,10 +19,16 @@ namespace LibationFileManager
//public static IInteropFunctions Create(string str, int i) => _create(str, i);
//public static IInteropFunctions Create(params object[] values) => _create(values);
private static IInteropFunctions instance { get; set; }
private static IInteropFunctions _create(params object[] values)
=> InteropFunctionsType is null ? new NullInteropFunctions()
//: values is null || values.Length == 0 ? Activator.CreateInstance(InteropFunctionsType) as IInteropFunctions
: Activator.CreateInstance(InteropFunctionsType, values) as IInteropFunctions;
{
instance ??=
InteropFunctionsType is null
? new NullInteropFunctions()
//: values is null || values.Length == 0 ? Activator.CreateInstance(InteropFunctionsType) as IInteropFunctions
: Activator.CreateInstance(InteropFunctionsType, values) as IInteropFunctions;
return instance;
}
#region load types

View File

@ -9,5 +9,6 @@ namespace LibationFileManager
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
public void CopyTextToClipboard(string text) => throw new PlatformNotSupportedException();
}
}

View File

@ -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

View File

@ -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;

View File

@ -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
//

View File

@ -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

View File

@ -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;

View File

@ -9,5 +9,6 @@ namespace LinuxConfigApp
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
public void CopyTextToClipboard(string text) => throw new PlatformNotSupportedException();
}
}

View File

@ -9,5 +9,6 @@ namespace MacOSConfigApp
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
public void CopyTextToClipboard(string text) => throw new PlatformNotSupportedException();
}
}

View File

@ -35,5 +35,8 @@ namespace WindowsConfigApp
public void DeleteFolderIcon(string directory)
=> new DirectoryInfo(directory)?.DeleteIcon();
public void CopyTextToClipboard(string text)
=> Clipboard.SetText(text);
}
}