Example #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 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);
        }