Ejemplo n.º 1
0
        public static ContextMenuItem CreateAndRegister(VisioShape shape, string eventId, string name,
                                                        bool isFlyOut = false)
        {
            ContextMenuItem menuItem = new ContextMenuItem(shape, eventId, name, isFlyOut);

            if (!Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
            {
                //Assign to local varibale and not field to avoid updatemenuitem being called
                menuItem.name      = name;
                menuItem.isEnabled = true;
                menuItem.Shape.AddMenuItem(menuItem);
            }
            else
            {
                if (
                    menuItem.Shape.Shape.CellExists[
                        string.Format(VisioFormulas.Action_Action, menuItem.EventId), (short)VisExistsFlags.visExistsAnywhere] ==
                    Constants.CellExists)
                {
                    menuItem.name =
                        menuItem.Shape.Shape.CellsU[string.Format(VisioFormulas.Action_MenuName, menuItem.EventId)].ResultStr["Value"];
                    menuItem.isEnabled =
                        !(menuItem.Shape.Shape.CellsU[string.Format(VisioFormulas.Action_Disabled, menuItem.EventId)].ResultIU > 0);
                }
            }
            return(menuItem);
        }
Ejemplo n.º 2
0
 public void OnContextMenuEvent(Application app, int sequencenum, string contextstring)
 {
     try
     {
         if (eventRegistry.ContainsKey(contextstring) && !Globals.RationallyAddIn.Application.IsUndoingOrRedoing)
         {
             Log.Info($"ContextMenuEvent {contextstring} was fired.");
             ContextMenuItem item = eventRegistry[contextstring];
             item.Action?.Invoke();
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         throw new RationallyException($"Exception on context menu {contextstring} occured.", ex);
     }
 }
Ejemplo n.º 3
0
 public void RegisterMenuEvent(string actionId, ContextMenuItem item) => eventRegistry[actionId] = item;