public static ContextualMenuPopulateEvent GetPooled(EventBase triggerEvent, ContextualMenu menu, IEventHandler target) { ContextualMenuPopulateEvent e = GetPooled(); if (triggerEvent != null) { IMouseEvent mouseEvent = triggerEvent as IMouseEvent; if (mouseEvent != null) { e.modifiers = mouseEvent.modifiers; e.mousePosition = mouseEvent.mousePosition; e.localMousePosition = mouseEvent.mousePosition; e.mouseDelta = mouseEvent.mouseDelta; e.button = mouseEvent.button; e.clickCount = mouseEvent.clickCount; } IMouseEventInternal mouseEventInternal = triggerEvent as IMouseEventInternal; if (mouseEventInternal != null) { ((IMouseEventInternal)e).hasUnderlyingPhysicalEvent = mouseEventInternal.hasUnderlyingPhysicalEvent; } e.target = target; e.menu = menu; } return(e); }
/// <summary> /// Manage the views contextual menus (those that are defined in the templates) /// </summary> private IEnumerable <IContextualMenu> ManageViewsContextualMenu(ExcelInterop.Worksheet sheet, ExcelInterop.Range range) { List <IContextualMenu> menus = new List <IContextualMenu>(); if (sheet != null && range != null) { ExcelInterop.Range targetRange = range.Cells[1, 1]; lock (syncRoot) { List <ExcelTemplateView> views; if (viewsBySheet.TryGetValue(sheet, out views)) { if (views != null) { foreach (ExcelTemplateView view in views.Where(v => v.IsRendered).Select(v => v)) { ExcelInterop.Range intersect = ExcelApplication.Application.Intersect(view.RenderedRange, targetRange); if (intersect != null) { IBindingContextItem currentContextItem = view.GetConcernedContextItem(targetRange); if (currentContextItem != null) { // User contextual menu IBindingContextElement catchingContextElement = currentContextItem.ParentElement; do { ExcelTemplateDefinitionPart currentTemplateDefinition = catchingContextElement.ParentPart.TemplateDefinitionPart as ExcelTemplateDefinitionPart; if ((currentTemplateDefinition.Parent as ExcelTemplateDefinition).ContextualMenu != null) { ContextualMenu contextualMenu = (currentTemplateDefinition.Parent as ExcelTemplateDefinition).ContextualMenu as ContextualMenu; contextualMenu.SetAction(targetRange, catchingContextElement, currentContextItem.ParentElement); menus.Insert(0, contextualMenu); } catchingContextElement = catchingContextElement.ParentPart.ParentContext == null ? null : catchingContextElement.ParentPart.ParentContext.Parent; }while (catchingContextElement != null); // Etk sort, search and filter IContextualMenu searchSortAndFilterMenu = sortSearchAndFilterMenuManager.GetMenus(view, targetRange, currentContextItem); if (searchSortAndFilterMenu != null) { menus.Insert(0, searchSortAndFilterMenu); } } } } } } } //ExcelApplication.ReleaseComObject(targetRange); targetRange = null; } return(menus); }
public void DisplayMenu(EventBase triggerEvent, IEventHandler target) { bool doDisplay; ContextualMenu menu = new ContextualMenu(); using (ContextualMenuPopulateEvent cme = ContextualMenuPopulateEvent.GetPooled(triggerEvent, menu, target)) { UIElementsUtility.eventDispatcher.DispatchEvent(cme, null); doDisplay = cme.isDefaultPrevented == false; } if (doDisplay) { menu.PrepareForDisplay(triggerEvent); DoDisplayMenu(menu, triggerEvent); } }
public virtual void BuildContextualMenu(ContextualMenuPopulateEvent evt) { bool anchored; if (base.dependsOnPresenter) { MiniMapPresenter presenter = base.GetPresenter <MiniMapPresenter>(); anchored = presenter.anchored; } else { anchored = this.anchored; } ContextualMenu arg_6E_0 = evt.menu; string arg_6E_1 = (!anchored) ? "Anchor" : "Make floating"; Action <EventBase> arg_6E_2 = new Action <EventBase>(this.ToggleAnchorState); if (MiniMap.< > f__mg$cache0 == null) { MiniMap.< > f__mg$cache0 = new Func <EventBase, ContextualMenu.MenuAction.StatusFlags>(ContextualMenu.MenuAction.AlwaysEnabled); } arg_6E_0.AppendAction(arg_6E_1, arg_6E_2, MiniMap.< > f__mg$cache0); }
public static void AppendAction(this ContextualMenu contextualMenu, string actionName, Action action, ContextualMenu.MenuAction.StatusFlags statusFlags) { Debug.Assert(action != null); contextualMenu.AppendAction(actionName, e => action(), e => statusFlags); }
public static void AppendAction(this ContextualMenu contextualMenu, string actionName, Action action, Func <ContextualMenu.MenuAction.StatusFlags> actionStatusCallback) { Debug.Assert(action != null); Debug.Assert(actionStatusCallback != null); contextualMenu.AppendAction(actionName, e => action(), e => actionStatusCallback()); }
protected override void Init() { base.Init(); menu = null; }
void Awake() { rend = GetComponentInChildren <Renderer>(); contextualMenu = ContextualMenu.Instance; }
void AddNoteMenuItems(ContextualMenu menu) { menu.AppendAction("Add input", (a) => addInput(), ContextualMenu.MenuAction.AlwaysEnabled); menu.AppendAction("Add output", (a) => addOutput(), ContextualMenu.MenuAction.AlwaysEnabled); }
protected abstract void DoDisplayMenu(ContextualMenu menu, EventBase triggerEvent);