mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-16 02:13:39 +12:00
Switch context menu location as it is done by Windows Explorer
This commit is contained in:
parent
4f1ee5385c
commit
bfd50ae141
|
@ -281,17 +281,10 @@ namespace SystemTrayMenu.DataClasses
|
|||
{
|
||||
if (Owner != null)
|
||||
{
|
||||
#if CONTEXT_MENU_EXPLORER_BEHAVIOR
|
||||
// Snap context menu left aligned to the ListViewItem with a small padding, but keep it vertically centered
|
||||
Rect rectChild = Owner.GetDataGridViewChildRect(this);
|
||||
position = Owner.GetRelativeChildPositionTo(Owner.GetDataGridView());
|
||||
position.Offset(Owner.Left + rectChild.Left + 10D, Owner.Top + rectChild.Top + (rectChild.Height / 2D));
|
||||
#else
|
||||
// Snap context menu left and top aligned to the ListViewItem
|
||||
Rect rectChild = Owner.GetDataGridViewChildRect(this);
|
||||
position = Owner.GetRelativeChildPositionTo(Owner.GetDataGridView());
|
||||
position.Offset(Owner.Left + rectChild.Left, Owner.Top + rectChild.Top);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1174,21 +1174,12 @@ namespace SystemTrayMenu.UserInterface
|
|||
|
||||
private void ListViewItem_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ListViewItem lvi = (ListViewItem)sender;
|
||||
RowData itemData = (RowData)lvi.Content;
|
||||
|
||||
#if CONTEXT_MENU_EXPLORER_BEHAVIOR
|
||||
// At mouse location
|
||||
Point position = Mouse.GetPosition(this);
|
||||
position.Offset(Left, Top);
|
||||
#else
|
||||
// Snap context menu above the ListViewItem, but horizontally follow the mouse
|
||||
Point position = this.GetRelativeChildPositionTo(lvi);
|
||||
position.Offset(Left + Mouse.GetPosition(lvi).X, Top);
|
||||
#endif
|
||||
|
||||
isShellContextMenuOpen = true;
|
||||
itemData.OpenShellContextMenu(position);
|
||||
((RowData)((ListViewItem)sender).Content).OpenShellContextMenu(position);
|
||||
isShellContextMenuOpen = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue