private void FillContextMenuItems() { contextMenu.Items.Clear(); if (this.CanAddFilters && GetCellColumnHeader(contextMenu) != null) { contextMenu.Items.Add(new MenuItem { Header = SearchMessage.AddFilter.NiceToString() }.Handle(MenuItem.ClickEvent, filterCell_Click)); } if (GetContextMenuItems != null) { foreach (var fun in GetContextMenuItems.GetInvocationListTyped()) { var items = fun(this)?.ToList(); if (items.IsNullOrEmpty()) { continue; } if (contextMenu.Items.Count > 0) { contextMenu.Items.Add(new Separator()); } foreach (var item in items) { contextMenu.Items.Add(item); } } if (contextMenu.Items.Count == 0) { contextMenu.Items.Add(new MenuItem { Header = new TextBlock(new Italic(new Run(SearchMessage.NoActionsFound.NiceToString()))), IsEnabled = false }); } } ContextMenuOpened?.Invoke(contextMenu); }
/// <summary> /// A mouse button has been released, check if something has been clicked. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PopupNotifierForm_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (RectClose.Contains(e.X, e.Y)) { CloseClick?.Invoke(this, EventArgs.Empty); } if (RectContentText.Contains(e.X, e.Y)) { LinkClick?.Invoke(this, EventArgs.Empty); } if (RectOptions.Contains(e.X, e.Y) && (Parent.OptionsMenu != null)) { ContextMenuOpened?.Invoke(this, EventArgs.Empty); Parent.OptionsMenu.Show(this, new Point(RectOptions.Right - Parent.OptionsMenu.Width, RectOptions.Bottom)); Parent.OptionsMenu.Closed += OptionsMenu_Closed; } } }