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