Пример #1
0
        private void miEditActions_Click(object sender, EventArgs e)
        {
            MethodDiagramViewer mv = this.DiagramViewer;

            if (mv != null)
            {
                AB_ForLoop           loop   = this.ActionObject as AB_ForLoop;
                MethodDesignerHolder holder = mv.DesignerHolder;
                MethodClass          mc     = loop.Method;
                DlgMethod            dlg    = mc.CreateSubMethodEditor(typeof(ActionGroupDesignerHolder), this.Parent.RectangleToScreen(this.Bounds), mv, loop.BranchId);

                try
                {
                    mc.SubMethod.Push(loop);
                    dlg.LoadActions(loop);
                    if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
                    {
                        UpdateAction(dlg.ActionResult);
                        mv.Changed = true;
                    }
                }
                catch (Exception err)
                {
                    MathNode.Log(this.FindForm(), err);
                }
                finally
                {
                    mc.SubMethod.Pop();
                    mc.CurrentSubEditor = null;
                }
            }
        }
        protected override void OnEditAction()
        {
            MethodDiagramViewer mv = this.DiagramViewer;

            if (mv != null)
            {
                AB_Squential av = this.ActionObject as AB_Squential;

                MethodDesignerHolder holder = mv.DesignerHolder;
                MethodClass          mc     = av.Method;
                DlgMethod            dlg    = mc.CreateSubMethodEditor(typeof(ActionGroupDesignerHolder), this.Parent.RectangleToScreen(this.Bounds), mv, av.BranchId);
                SubMethodInfoPointer smi    = null;
                try
                {
                    ISingleAction sa = av as ISingleAction;
                    if (sa != null)
                    {
                        smi = sa.ActionData.ActionMethod as SubMethodInfoPointer;
                        if (smi != null)
                        {
                            AB_SubMethodAction smb = this.ActionObject as AB_SubMethodAction;
                            smi.CreateParameters(smb);
                            av.Method.SubMethod.Push(smi);
                        }
                    }
                    //
                    dlg.LoadActions(av);
                    if (_caller == null)
                    {
                        _caller = this.FindForm();
                    }
                    if (dlg.ShowDialog(_caller) == DialogResult.OK)
                    {
                        AB_SubMethodAction abs = this.ActionObject as AB_SubMethodAction;
                        abs.CopyActionsFrom(dlg.ActionResult, dlg.ComponentIcons);
                        mv.Changed = true;
                    }
                }
                catch (Exception err)
                {
                    MathNode.Log(this.FindForm(), err);
                }
                finally
                {
                    if (smi != null)
                    {
                        if (av.Method.SubMethod.Count > 0)
                        {
                            av.Method.SubMethod.Pop();
                        }
                    }
                    mc.CurrentSubEditor = null;
                }
            }
        }
        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);
        }