예제 #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 (Owner == null)
     {
         Owner = loader.GetRootId();
     }
     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;
         }
         DlgMethod dlg = this.CreateMethodEditor(rcStart);
         dlg.LoadMethod(this, EnumParameterEditType.ReadOnly);
         if (dlg.EditSubAction(caller))
         {
             IsNewMethod = false;
             loader.GetRootId().SaveAction(this, loader.Writer);
             loader.NotifyChanges();
             return(true);
         }
     }
     catch (Exception err)
     {
         MathNode.Log(caller, err);
     }
     finally
     {
         ExitEditor();
         VPLUtil.CurrentRunContext = _origiContext;
     }
     return(false);
 }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    MethodClass scopeMethod = context.Instance as MethodClass;
                    if (scopeMethod != null)
                    {
                        //this version only edit FinalActions
                        ILimnorDesignPane dp = scopeMethod.Project.GetTypedData <ILimnorDesignPane>(scopeMethod.RootPointer.ClassId);
                        if (dp != null)
                        {
                            //save the method contents
                            BranchList           bl         = scopeMethod.ActionList;
                            string               methodName = scopeMethod.MethodName;
                            ParameterClass       returnType = scopeMethod.ReturnValue;
                            List <ComponentIcon> icons      = scopeMethod.ComponentIconList;

                            //switch method contents
                            scopeMethod.ActionList = scopeMethod.FinalActions.Actions;
                            scopeMethod.SetName("FinalActions");
                            List <ComponentIcon> icons2 = new List <ComponentIcon>();
                            foreach (ComponentIcon ic in icons)
                            {
                                icons2.Add((ComponentIcon)ic.Clone());
                            }
                            foreach (ComponentIconSubscopeVariable ic in scopeMethod.FinalActions.ComponentIconList)
                            {
                                icons2.Add((ComponentIcon)ic.Clone());
                            }
                            scopeMethod.SetComponentIcons(icons2);
                            //
                            Rectangle rc = new Rectangle(Cursor.Position, new Size(32, 232));
                            if (scopeMethod.Owner == null)
                            {
                                scopeMethod.Owner = dp.Loader.GetRootId();
                            }
                            DlgMethod dlg = scopeMethod.CreateBlockScopeMethodEditor(rc, 1);
                            try
                            {
                                dlg.LoadMethod(scopeMethod, EnumParameterEditType.ReadOnly);
                                dlg.Text = string.Format(CultureInfo.InvariantCulture, "Specify final actionsfor {0}", methodName);
                                if (edSvc.ShowDialog(dlg) == DialogResult.OK)
                                {
                                    scopeMethod.FinalActions.Actions = scopeMethod.ActionList;
                                    List <ComponentIconSubscopeVariable> lst = new List <ComponentIconSubscopeVariable>();
                                    foreach (ComponentIcon ic in scopeMethod.ComponentIconList)
                                    {
                                        ComponentIconSubscopeVariable sv = ic as ComponentIconSubscopeVariable;
                                        if (sv != null)
                                        {
                                            lst.Add(sv);
                                        }
                                    }
                                    scopeMethod.FinalActions.ComponentIconList = lst;
                                    XmlObjectWriter xw = dp.Loader.Writer;
                                    xw.WriteObject(scopeMethod.FinalActions.DataXmlNode, scopeMethod.FinalActions, null);
                                    value = scopeMethod.FinalActions;
                                }
                            }
                            catch (Exception err)
                            {
                                MathNode.LogError(DesignerException.FormExceptionText(err));
                            }
                            finally
                            {
                                //restore method contents
                                scopeMethod.SetName(methodName);
                                scopeMethod.ActionList = bl;
                                scopeMethod.SetComponentIcons(icons);
                                scopeMethod.ExitEditor();
                            }
                        }
                    }
                }
            }
            return(value);
        }
        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);
        }
예제 #6
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    ExceptionHandlerList.PropertyDescriptorExceptionHandler pd = context.PropertyDescriptor as ExceptionHandlerList.PropertyDescriptorExceptionHandler;
                    if (pd == null)
                    {
                        throw new DesignerException("Property descriptor [{0}] is not a PropertyDescriptorExceptionHandler", context.PropertyDescriptor == null ? "null" : context.PropertyDescriptor.GetType().FullName);
                    }
                    ExceptionHandler     eh       = pd.Handler;
                    BranchList           branches = eh.ActionList;
                    ExceptionHandlerList ehs      = context.Instance as ExceptionHandlerList;
                    if (ehs != null)
                    {
                        MethodClass scopeMethod = ehs.OwnerMethod;
                        if (scopeMethod != null)
                        {
                            if (branches == null)
                            {
                                branches = new BranchList(eh, new List <ActionBranch>());
                            }

                            ILimnorDesignPane dp = scopeMethod.Project.GetTypedData <ILimnorDesignPane>(scopeMethod.RootPointer.ClassId);
                            if (dp != null)
                            {
                                //save the method contents
                                BranchList           bl         = scopeMethod.ActionList;
                                string               methodName = scopeMethod.MethodName;
                                ParameterClass       returnType = scopeMethod.ReturnValue;
                                List <ComponentIcon> icons      = scopeMethod.ComponentIconList;

                                //switch method contents
                                scopeMethod.ActionList = branches;
                                scopeMethod.SetName(string.Format(CultureInfo.InvariantCulture, "HandlerFor{0}", eh.ExceptionType.Name));
                                scopeMethod.ReturnValue = null;
                                List <ComponentIcon> icons2 = new List <ComponentIcon>();
                                foreach (ComponentIcon ic in icons)
                                {
                                    icons2.Add((ComponentIcon)ic.Clone());
                                }
                                foreach (ComponentIconSubscopeVariable ic in eh.ComponentIconList)
                                {
                                    icons2.Add((ComponentIcon)ic.Clone());
                                }
                                icons2.Add(eh.ExceptionObject);
                                scopeMethod.SetComponentIcons(icons2);
                                //
                                Rectangle rc = new Rectangle(Cursor.Position, new Size(32, 232));
                                if (scopeMethod.Owner == null)
                                {
                                    scopeMethod.Owner = dp.Loader.GetRootId();
                                }
                                DlgMethod dlg = scopeMethod.CreateBlockScopeMethodEditor(rc, eh.ExceptionType.MemberId);
                                try
                                {
                                    dlg.LoadMethod(scopeMethod, EnumParameterEditType.ReadOnly);
                                    dlg.Text = string.Format(CultureInfo.InvariantCulture, "Create exception handler for {0}", eh.ExceptionType.Name);
                                    if (edSvc.ShowDialog(dlg) == DialogResult.OK)
                                    {
                                        bool delete = false;
                                        eh.ActionList = scopeMethod.ActionList;
                                        if (eh.ActionList.Count == 0)
                                        {
                                            if (MessageBox.Show(string.Format(CultureInfo.CurrentUICulture, "Do you want to remove this exception [{0}]?", eh.ExceptionType.Name), "Capture exception", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                            {
                                                delete = true;
                                            }
                                        }
                                        if (delete)
                                        {
                                            scopeMethod.RemoveExceptionCapture(eh);
                                        }
                                        else
                                        {
                                            List <ComponentIconSubscopeVariable> lst = new List <ComponentIconSubscopeVariable>();
                                            foreach (ComponentIcon ic in scopeMethod.ComponentIconList)
                                            {
                                                ComponentIconSubscopeVariable sv = ic as ComponentIconSubscopeVariable;
                                                if (sv != null)
                                                {
                                                    lst.Add(sv);
                                                }
                                            }
                                            eh.ComponentIconList = lst;
                                            scopeMethod.RootPointer.SaveMethod(scopeMethod, eh);
                                        }
                                    }
                                }
                                catch (Exception err)
                                {
                                    MathNode.LogError(DesignerException.FormExceptionText(err));
                                }
                                finally
                                {
                                    //restore method contents
                                    scopeMethod.SetName(methodName);
                                    scopeMethod.ActionList  = bl;
                                    scopeMethod.ReturnValue = returnType;
                                    scopeMethod.SetComponentIcons(icons);
                                    scopeMethod.ExitEditor();
                                }
                            }
                        }
                    }
                }
            }
            return(value);
        }