private void OnContextMenuStripOpening(object sender, CancelEventArgs e) { if (_tileController == null || _tileController.ContextMenuProvider == null) { e.Cancel = true; return; } if (_tileController.ContextMenuEnabled) { ActionModelNode menuModel = _tileController.ContextMenuProvider.GetContextMenuModel(_tileController); if (menuModel != null && menuModel.ChildNodes.Count > 0) { ToolStripBuilder.Clear(_contextMenuStrip.Items); ToolStripBuilder.BuildMenu(_contextMenuStrip.Items, menuModel.ChildNodes); // filter unavailable items out of list since they wreck the display of the overflow and scroll portions of the menu dropdown // (ClearCanvas Ticket #4775, Microsoft Connect Issue #136061) FilterUnavailableItems(_contextMenuStrip.Items); // cancel list if, after filtering, no items are left to display. e.Cancel = (_contextMenuStrip.Items.Count == 0); } else { e.Cancel = true; } } else { e.Cancel = true; } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { ToolStripBuilder.Clear(_contextMenuStrip.Items); _tilesToRepaint.Remove(this); DisposeSurface(); if (components != null) { components.Dispose(); } if (_tile != null) { _tile.Drawing -= new EventHandler(OnTileDrawing); _tile.RendererChanged -= new EventHandler(OnRendererChanged); _tile.EditBoxChanged -= new EventHandler(OnEditBoxChanged); _tile.InformationBoxChanged -= new EventHandler <InformationBoxChangedEventArgs>(OnInformationBoxChanged); _tile.SelectionChanged -= new EventHandler <ItemEventArgs <ITile> >(OnTileSelectionChanged); _tileController.CursorTokenChanged -= new EventHandler(OnCursorTokenChanged); _tileController.ContextMenuRequested -= new EventHandler <ItemEventArgs <Point> >(OnContextMenuRequested); _tileController.CaptureChanging -= new EventHandler <ItemEventArgs <IMouseButtonHandler> >(OnCaptureChanging); _tileController.Dispose(); _tile = null; } _tileController = null; } base.Dispose(disposing); }
private void InitializeToolStrip() { ToolStripBuilder.Clear(_toolStrip.Items); if (_component.ToolbarModel != null) { ToolStripBuilder.BuildToolbar(_toolStrip.Items, _component.ToolbarModel.ChildNodes); } }
private void InitializeMenu() { ToolStripBuilder.Clear(_contextMenu.Items); if (_menuModel != null) { ToolStripBuilder.BuildMenu(_contextMenu.Items, _menuModel.ChildNodes); } }
private static void ShowContextMenu(ContextMenuStrip contextMenuStrip, ActionModelNode actionModel, Point screenPoint, int minWidth, bool alignRight) { ToolStripBuilder.Clear(contextMenuStrip.Items); if (actionModel != null) { ToolStripBuilder.BuildMenu(contextMenuStrip.Items, actionModel.ChildNodes); if (alignRight) { screenPoint.Offset(-contextMenuStrip.Width, 0); } contextMenuStrip.Show(screenPoint); } }