#398 - new feature: right-click, copy
This commit is contained in:
parent
451af7bea9
commit
ce711a36ba
@ -44,6 +44,7 @@
|
|||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Button Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="LiberateButton_Click" ToolTip.Tip="{Binding Liberate.ToolTip}">
|
<Button Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="LiberateButton_Click" ToolTip.Tip="{Binding Liberate.ToolTip}">
|
||||||
<Image Stretch="None" Source="{Binding Liberate.Image}" />
|
<Image Stretch="None" Source="{Binding Liberate.Image}" />
|
||||||
|
<!--
|
||||||
<Button.ContextMenu>
|
<Button.ContextMenu>
|
||||||
<ContextMenu IsVisible="{Binding !Liberate.IsSeries}">
|
<ContextMenu IsVisible="{Binding !Liberate.IsSeries}">
|
||||||
<MenuItem Header="Item 1" Click="ContextMenuItem1_Click" />
|
<MenuItem Header="Item 1" Click="ContextMenuItem1_Click" />
|
||||||
@ -51,6 +52,7 @@
|
|||||||
<MenuItem Header="Item 3" Click="ContextMenuItem3_Click" />
|
<MenuItem Header="Item 3" Click="ContextMenuItem3_Click" />
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Button.ContextMenu>
|
</Button.ContextMenu>
|
||||||
|
-->
|
||||||
</Button>
|
</Button>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
|||||||
@ -6,5 +6,6 @@ namespace LibationFileManager
|
|||||||
{
|
{
|
||||||
void SetFolderIcon(string image, string directory);
|
void SetFolderIcon(string image, string directory);
|
||||||
void DeleteFolderIcon(string directory);
|
void DeleteFolderIcon(string directory);
|
||||||
|
void CopyTextToClipboard(string text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,10 +19,16 @@ namespace LibationFileManager
|
|||||||
//public static IInteropFunctions Create(string str, int i) => _create(str, i);
|
//public static IInteropFunctions Create(string str, int i) => _create(str, i);
|
||||||
//public static IInteropFunctions Create(params object[] values) => _create(values);
|
//public static IInteropFunctions Create(params object[] values) => _create(values);
|
||||||
|
|
||||||
|
private static IInteropFunctions instance { get; set; }
|
||||||
private static IInteropFunctions _create(params object[] values)
|
private static IInteropFunctions _create(params object[] values)
|
||||||
=> InteropFunctionsType is null ? new NullInteropFunctions()
|
{
|
||||||
//: values is null || values.Length == 0 ? Activator.CreateInstance(InteropFunctionsType) as IInteropFunctions
|
instance ??=
|
||||||
: Activator.CreateInstance(InteropFunctionsType, values) as IInteropFunctions;
|
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
|
#region load types
|
||||||
|
|
||||||
|
|||||||
@ -9,5 +9,6 @@ namespace LibationFileManager
|
|||||||
|
|
||||||
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
|
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
|
||||||
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
|
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
|
||||||
|
public void CopyTextToClipboard(string text) => throw new PlatformNotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,9 +28,13 @@ namespace LibationWinForms.GridView
|
|||||||
[Browsable(false)] public abstract DateTime DateAdded { get; }
|
[Browsable(false)] public abstract DateTime DateAdded { get; }
|
||||||
[Browsable(false)] protected Book Book => LibraryBook.Book;
|
[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 RemoveStatus Remove { get; set; }
|
||||||
|
|
||||||
public abstract LiberateButtonStatus Liberate { get; }
|
public abstract LiberateButtonStatus Liberate { get; }
|
||||||
@ -56,11 +60,11 @@ namespace LibationWinForms.GridView
|
|||||||
public string MyRating { get; protected set; }
|
public string MyRating { get; protected set; }
|
||||||
public abstract string DisplayTags { get; }
|
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
|
// These methods are implementation of Dinah.Core.DataBinding.IMemberComparable
|
||||||
// Used by GridEntryBindingList for all sorting
|
// Used by GridEntryBindingList for all sorting
|
||||||
|
|||||||
@ -14,9 +14,13 @@ namespace LibationWinForms.GridView
|
|||||||
[Browsable(false)] public override DateTime DateAdded => LibraryBook.DateAdded;
|
[Browsable(false)] public override DateTime DateAdded => LibraryBook.DateAdded;
|
||||||
[Browsable(false)] public SeriesEntry Parent { get; init; }
|
[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 _bookStatus;
|
||||||
private LiberatedStatus? _pdfStatus;
|
private LiberatedStatus? _pdfStatus;
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,8 @@
|
|||||||
this.gridEntryDataGridView.Size = new System.Drawing.Size(1570, 380);
|
this.gridEntryDataGridView.Size = new System.Drawing.Size(1570, 380);
|
||||||
this.gridEntryDataGridView.TabIndex = 0;
|
this.gridEntryDataGridView.TabIndex = 0;
|
||||||
this.gridEntryDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellContentClick);
|
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
|
// 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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,11 @@ namespace LibationWinForms.GridView
|
|||||||
[Browsable(false)] public List<LibraryBookEntry> Children { get; }
|
[Browsable(false)] public List<LibraryBookEntry> Children { get; }
|
||||||
[Browsable(false)] public override DateTime DateAdded => Children.Max(c => c.DateAdded);
|
[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()
|
public void ChildRemoveUpdate()
|
||||||
{
|
{
|
||||||
if (suspendCounting) return;
|
if (suspendCounting) return;
|
||||||
|
|||||||
@ -9,5 +9,6 @@ namespace LinuxConfigApp
|
|||||||
|
|
||||||
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
|
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
|
||||||
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
|
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
|
||||||
|
public void CopyTextToClipboard(string text) => throw new PlatformNotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,5 +9,6 @@ namespace MacOSConfigApp
|
|||||||
|
|
||||||
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
|
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
|
||||||
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
|
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
|
||||||
|
public void CopyTextToClipboard(string text) => throw new PlatformNotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,5 +35,8 @@ namespace WindowsConfigApp
|
|||||||
|
|
||||||
public void DeleteFolderIcon(string directory)
|
public void DeleteFolderIcon(string directory)
|
||||||
=> new DirectoryInfo(directory)?.DeleteIcon();
|
=> new DirectoryInfo(directory)?.DeleteIcon();
|
||||||
|
|
||||||
|
public void CopyTextToClipboard(string text)
|
||||||
|
=> Clipboard.SetText(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user