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