Add full context menu to call columns
This commit is contained in:
parent
1bf86b05ec
commit
932472cb91
@ -84,13 +84,13 @@
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</controls:DataGridTemplateColumnExt>
|
||||
|
||||
<DataGridTemplateColumn CanUserSort="False" Width="80" Header="Cover" SortMemberPath="Cover" ClipboardContentBinding="{Binding LibraryBook.Book.PictureLarge}">
|
||||
<controls:DataGridTemplateColumnExt CanUserSort="False" Width="80" Header="Cover" SortMemberPath="Cover" ClipboardContentBinding="{Binding LibraryBook.Book.PictureLarge}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate x:DataType="uibase:IGridEntry">
|
||||
<Image Opacity="{CompiledBinding Liberate.Opacity}" Tapped="Cover_Click" Height="80" Source="{CompiledBinding Cover}" ToolTip.Tip="Click to see full size" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</controls:DataGridTemplateColumnExt>
|
||||
|
||||
<controls:DataGridTemplateColumnExt MinWidth="150" Width="2*" Header="Title" CanUserSort="True" SortMemberPath="Title" ClipboardContentBinding="{Binding Title}">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
|
||||
@ -78,9 +78,16 @@ namespace LibationAvalonia.Views
|
||||
|
||||
public void ProductsGrid_CellContextMenuStripNeeded(object sender, DataGridCellContextMenuStripNeededEventArgs args)
|
||||
{
|
||||
// stop light
|
||||
if (args.Column.SortMemberPath == "Liberate")
|
||||
if (args.Column.SortMemberPath is not "Liberate" and not "Cover")
|
||||
{
|
||||
var menuItem = new MenuItem { Header = "_Copy Cell Contents" };
|
||||
|
||||
menuItem.Click += async (s, e)
|
||||
=> await App.MainWindow.Clipboard.SetTextAsync(args.CellClipboardContents);
|
||||
|
||||
args.ContextMenuItems.Add(menuItem);
|
||||
args.ContextMenuItems.Add(new Separator());
|
||||
}
|
||||
var entry = args.GridEntry;
|
||||
|
||||
#region Liberate all Episodes
|
||||
@ -224,18 +231,6 @@ namespace LibationAvalonia.Views
|
||||
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
// any non-stop light column
|
||||
// (except for the Cover column which does not have a context menu)
|
||||
var menuItem = new MenuItem { Header = "_Copy Cell Contents" };
|
||||
|
||||
menuItem.Click += async (s, e)
|
||||
=> await App.MainWindow.Clipboard.SetTextAsync(args.CellClipboardContents);
|
||||
|
||||
args.ContextMenuItems.Add(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -56,15 +56,11 @@ namespace LibationWinForms.GridView
|
||||
if (e.RowIndex < 0)
|
||||
return;
|
||||
|
||||
// cover
|
||||
else if (e.ColumnIndex == coverGVColumn.Index)
|
||||
return;
|
||||
|
||||
e.ContextMenuStrip = new ContextMenuStrip();
|
||||
// any non-stop light
|
||||
if (e.ColumnIndex != liberateGVColumn.Index)
|
||||
// any column except cover & stop light
|
||||
if (e.ColumnIndex != liberateGVColumn.Index && e.ColumnIndex != coverGVColumn.Index)
|
||||
{
|
||||
e.ContextMenuStrip.Items.Add("Copy", null, (_, __) =>
|
||||
e.ContextMenuStrip.Items.Add("Copy Cell Contents", null, (_, __) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -74,14 +70,13 @@ namespace LibationWinForms.GridView
|
||||
}
|
||||
catch { }
|
||||
});
|
||||
e.ContextMenuStrip.Items.Add(new ToolStripSeparator());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var entry = getGridEntry(e.RowIndex);
|
||||
var name = gridEntryDataGridView.Columns[e.ColumnIndex].DataPropertyName;
|
||||
LiberateContextMenuStripNeeded?.Invoke(entry, e.ContextMenuStrip);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableDoubleBuffering()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user