예제 #1
0
        public bool Edit(XmlObjectWriter writer, IMethod context, Form caller, bool isNewAction)
        {
            LimnorProject        project = _class.Project;
            FormActionParameters dlgData = new FormActionParameters();

            if (_parameters == null)
            {
                _parameters = new ParameterValueCollection();
            }
            ActionMethod.ValidateParameterValues(_parameters);
            dlgData.SetScopeMethod(context);
            dlgData.LoadAction(this, _class.XmlData);
            DialogResult ret = dlgData.ShowDialog(caller);

            if (ret == DialogResult.OK)
            {
                _class.SaveAction(this, writer);
                ILimnorDesignPane pane = project.GetTypedData <ILimnorDesignPane>(_class.ClassId);
                if (pane != null)
                {
                    pane.OnActionChanged(_class.ClassId, this, isNewAction);
                    pane.OnNotifyChanges();
                }
                else
                {
                    DesignUtil.WriteToOutputWindowAndLog("Error editong ActionAssignInstance. ClassPointer [{0}] is not in design mode when creating an action. Please close the design pane and re-open it.", _class.ClassId);
                }
                return(true);
            }
            return(false);
        }
예제 #2
0
 public void OnFinishEdit(UInt32 actionBranchId, ILimnorDesignerLoader loader)
 {
     try
     {
         ILimnorDesignPane dp = loader.DesignPane;
         if (dp == null)
         {
             throw new DesignerException("ILimnorDesignPane not found for class {0}", loader.GetRootId());
         }
         IEvent       ep = _event;
         EventAction  ea = null;                //event-actions mapping
         ClassPointer a  = loader.GetRootId();
         if (a != null)
         {
             List <EventAction> lst = a.EventHandlers;
             if (lst != null)
             {
                 foreach (EventAction e in lst)
                 {
                     if (e.GetAssignActionId() == actionBranchId && e.Event.IsSameObjectRef(ep))
                     {
                         ea = e;
                         break;
                     }
                 }
             }
         }
         if (ea == null)
         {
             ea       = new EventAction();
             ea.Event = ep;
             if (actionBranchId != 0)
             {
                 ea.SetAssignActionId(actionBranchId);
             }
         }
         _handlerOwner = ea;
         ea.AddAction(this);
         a.SaveEventHandler(ea);
         dp.OnNotifyChanges();
         dp.OnAssignAction(ea);
     }
     catch (Exception err)
     {
         MathNode.Log(TraceLogClass.MainForm, err);
     }
     finally
     {
         this.ExitEditor();
     }
 }
예제 #3
0
        public bool Edit(XmlObjectWriter writer, IMethod context, Form caller, bool isNewAction)
        {
            IMathExpression mathExp = MathExp;

            if (mathExp != null)
            {
                ActionExecMath       a2       = (ActionExecMath)this.Clone();
                Rectangle            rc       = new Rectangle(0, 0, 100, 30);
                System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position;
                rc.X = curPoint.X;
                rc.Y = curPoint.Y;
                a2.MathExp.ScopeMethod = context;
                IMathEditor dlg = a2.MathExp.CreateEditor(rc);
                if (((Form)dlg).ShowDialog(caller) == DialogResult.OK)
                {
                    MathExpMethod mem = new MathExpMethod();
                    mem.Action         = this;
                    mem.MathExpression = dlg.MathExpression;
                    ActionMethod       = mem;
                    if (_class != null)
                    {
                        LimnorProject     project = _class.Project;
                        ILimnorDesignPane pane    = project.GetTypedData <ILimnorDesignPane>(_class.ClassId);
                        if (pane != null)
                        {
                            pane.OnActionChanged(_class.ClassId, this, isNewAction);
                            pane.OnNotifyChanges();
                        }
                        else
                        {
                            DesignUtil.WriteToOutputWindowAndLog("Error Editng ActionExecMath. ClassPointer [{0}] is not in design mode when creating an action. Please close the design pane and re-open it.", _class.ClassId);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
        public override bool Edit(UInt32 actionBranchId, Rectangle rcStart, ILimnorDesignerLoader loader, Form caller)
        {
            if (this.Owner == null)
            {
                this.Owner = loader.GetRootId();
            }
            DlgMethod dlg = this.CreateMethodEditor(rcStart);

            try
            {
                _origiContext = VPLUtil.CurrentRunContext;
                if (loader.Project.IsWebApplication)
                {
                    if (this.RunAt == EnumWebRunAt.Client)
                    {
                        VPLUtil.CurrentRunContext = EnumRunContext.Client;
                    }
                    else
                    {
                        VPLUtil.CurrentRunContext = EnumRunContext.Server;
                    }
                }
                else
                {
                    VPLUtil.CurrentRunContext = EnumRunContext.Server;
                }
                dlg.LoadMethod(this, EnumParameterEditType.Edit);
                if (dlg.ShowDialog(caller) == DialogResult.OK)
                {
                    _display = null;
                    XmlNode nodeMethodCollection = loader.Node.SelectSingleNode(XmlTags.XML_CONSTRUCTORS);
                    if (nodeMethodCollection == null)
                    {
                        nodeMethodCollection = loader.Node.OwnerDocument.CreateElement(XmlTags.XML_CONSTRUCTORS);
                        loader.Node.AppendChild(nodeMethodCollection);
                    }
                    XmlNode nodeMethod = nodeMethodCollection.SelectSingleNode(
                        string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                      "{0}[@{1}='{2}']",
                                      XmlTags.XML_Item, XmlTags.XMLATT_MethodID, MemberId));
                    if (nodeMethod == null)
                    {
                        nodeMethod = nodeMethodCollection.OwnerDocument.CreateElement(XmlTags.XML_Item);
                        nodeMethodCollection.AppendChild(nodeMethod);
                    }
                    XmlUtil.SetAttribute(nodeMethod, XmlTags.XMLATT_MethodID, MemberId);
                    XmlUtil.SetAttribute(nodeMethod, XmlTags.XMLATT_NAME, Name);
                    XmlObjectWriter wr = loader.Writer;
                    wr.WriteObjectToNode(nodeMethod, this);
                    if (wr.HasErrors)
                    {
                        MathNode.Log(wr.ErrorCollection);
                    }
                    ILimnorDesignPane pane = loader.Project.GetTypedData <ILimnorDesignPane>(loader.ObjectMap.ClassId);

                    pane.OnNotifyChanges();
                    return(true);
                }
            }
            catch (Exception err)
            {
                MathNode.Log(caller, err);
            }
            finally
            {
                ExitEditor();
                VPLUtil.CurrentRunContext = _origiContext;
            }
            return(false);
        }