示例#1
0
        private void miSetEvents_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer   mv     = MethodViewer.GetCurrentViewer();
            ILimnorDesignerLoader loader = mv.Loader;
            DlgSelectEvent        dlg    = new DlgSelectEvent();

            dlg.LoadData(_menuData);
            DialogResult ret = dlg.ShowDialog(this.FindForm());

            if (dlg.FrequentlyUsedMethodsChanged)
            {
                _menuData.RemoveMenuCollection();
                loader.DesignPane.ResetContextMenu();
            }
            if (ret == DialogResult.OK)
            {
                IEvent ei = dlg.ReturnEventInfo;
                if (ei != null)
                {
                    EventPointer ep = ei as EventPointer;
                    if (ep == null)
                    {
                        EventClass ec = ei as EventClass;
                        if (ec != null)
                        {
                            EventClass ec2 = (EventClass)ec.Clone();
                            ec2.SetHolder(this.ClassPointer);
                            CustomEventPointer cep = new CustomEventPointer(ec2, this.ClassPointer);
                            ei = cep;
                        }
                    }
                    assignAction(ei);
                }
            }
        }
        public static MenuItemDataEvent CreateMenuItem(IEvent p, LimnorContextMenuCollection menus)
        {
            EventPointer pp = p as EventPointer;

            if (pp != null)
            {
                return(new EventItem(pp.ObjectKey, menus.Owner, pp.Info));
            }
            else
            {
                EventClass pc = p as EventClass;
                if (pc != null)
                {
                    return(new EventItemClassPointer(pc.DisplayName, menus.Owner, pc));
                }
                else
                {
                    IPropertyWrapper w = p as IPropertyWrapper;
                    if (w != null)
                    {
                    }
                }
            }
            throw new DesignerException("Unsupported property type {0} for CreateMenuItem", p.GetType());
        }
示例#3
0
        public override bool ExecuteMenuCommand(LimnorProject project, IClass holder, XmlNode node, MultiPanes pane, IMethod scopeMethod, IActionsHolder actsHolder)
        {
            EventPointer ep = new EventPointer();

            ep.SetEventInfo(_val);
            ep.Owner = Owner;
            return(pane.AssignActions(ep, pane.FindForm()));
        }
示例#4
0
        public override IEvent CreateEventPointer(IClass holder)
        {
            EventPointer ep = new EventPointer();

            ep.SetEventInfo(_val);
            ep.Owner = holder;
            return(ep);
        }
        public void LoadData(LimnorContextMenuCollection type)
        {
            _menus = type;
            //
            List <MenuItemDataEvent> es = _menus.PrimaryEvents;

            if (es != null && es.Count > 0)
            {
                foreach (MenuItemDataEvent e in es)
                {
                    lstP.Items.Add(e);
                }
            }
            es = _menus.SecondaryEvents;
            if (es != null && es.Count > 0)
            {
                foreach (MenuItemDataEvent e in es)
                {
                    lstS.Items.Add(e);
                }
            }
            SortedDictionary <string, IEvent>   all         = _menus.GetAllEvents();
            SortedDictionary <string, TreeNode> customNodes = new SortedDictionary <string, TreeNode>();

            foreach (KeyValuePair <string, IEvent> kv in all)
            {
                EventPointer ei = kv.Value as EventPointer;
                if (ei != null)
                {
                    treeViewAll.Nodes.Add(new TreeNodeEvent(false, ei));
                }
                else
                {
                    EventClass ec = kv.Value as EventClass;
                    if (ec != null)
                    {
                        TreeNodeCustomEvent tnc = new TreeNodeCustomEvent(ec.IsStatic, ec);
                        customNodes.Add(tnc.Text, tnc);
                    }
                }
            }
            int i = 0;

            foreach (KeyValuePair <string, TreeNode> kv in customNodes)
            {
                treeViewAll.Nodes.Insert(i++, kv.Value);
            }
        }
        public override bool ExecuteMenuCommand(LimnorProject project, IClass holder, XmlNode node, MultiPanes pane, IMethod scopeMethod, IActionsHolder actsHolder)
        {
            DlgSelectEvent dlg = new DlgSelectEvent();

            dlg.LoadData(_menuData);
            DialogResult ret = dlg.ShowDialog(pane.FindForm());

            if (dlg.FrequentlyUsedMethodsChanged)
            {
                _menuData.RemoveMenuCollection();
                pane.Loader.DesignPane.ResetContextMenu();
            }
            if (ret == DialogResult.OK)
            {
                IEvent ei = dlg.ReturnEventInfo;
                if (ei != null)
                {
                    EventPointer ep = ei as EventPointer;
                    if (ep != null)
                    {
                        return(pane.AssignActions(ep, pane.FindForm()));
                    }
                    else
                    {
                        EventClass ec = ei as EventClass;
                        if (ec != null)
                        {
                            EventClass ec2 = (EventClass)ec.Clone();
                            ec2.SetHolder(holder);
                            CustomEventPointer cep = new CustomEventPointer(ec2, this.Owner);
                            return(pane.AssignActions(cep, pane.FindForm()));
                        }
                    }
                }
            }
            return(false);
        }
 private void taskExecuter(IEventPointer eventPointer, object[] eventParameters)
 {
     try
     {
         foreach (EventAction ea in eventHandlers)
         {
             EventPointer ep = eventPointer as EventPointer;
             if (ea.Event.IsSameObjectRef(ep))
             {
                 List <ParameterClass> eventValues = new List <ParameterClass>();
                 if (eventParameters != null && eventParameters.Length > 0)
                 {
                     ParameterInfo[] pifs = ep.Parameters;
                     if (pifs.Length != eventParameters.Length)
                     {
                         throw new DesignerException("Event {0} parameter count mismatch", ep.MemberName);
                     }
                     for (int i = 0; i < pifs.Length; i++)
                     {
                         ParameterClass p = new ParameterClass(new TypePointer(pifs[i].ParameterType));
                         p.Name           = pifs[i].Name;
                         p.ObjectInstance = eventParameters[i];
                         eventValues.Add(p);
                     }
                 }
                 //execute the event handlers
                 TaskIdList actIdList = ea.TaskIDList;
                 foreach (TaskID tid in actIdList)
                 {
                     UInt32 classId = tid.ClassId;
                     //if (tid.IsGroup)
                     //{
                     //}
                     //else
                     //{
                     //find the action in the list of all actions
                     List <IAction> acts = null;
                     if (classId == _map.ClassId)
                     {
                         acts = actions;
                     }
                     else
                     {
                         ObjectIDmap classmap = _map.GetMapByClassId(classId);
                         if (classmap != null)
                         {
                             ActionEventCollection av = classmap.GetTypedData <ActionEventCollection>();
                             if (av == null)
                             {
                                 av = new ActionEventCollection(classmap);
                                 classmap.SetTypedData <ActionEventCollection>(av);
                                 av.LoadActions();
                             }
                             acts = av.actions;
                         }
                     }
                     if (acts != null)
                     {
                         foreach (IAction a in acts)
                         {
                             if (a.ActionId == tid.ActionId)
                             {
                                 a.Execute(eventValues);
                                 break;
                             }
                         }
                     }
                     //}
                 }
                 break;
             }
         }
     }
     catch (Exception err)
     {
         MathNode.Log(err);
     }
 }