Ejemplo n.º 1
0
 public override void FindActionsByOwnerType <T>(List <IActionMethodPointer> results, List <UInt32> usedBranches, List <UInt32> usedMethods)
 {
     if (usedBranches.Contains(this.BranchId))
     {
         return;
     }
     usedBranches.Add(this.BranchId);
     if (_decisionTable != null)
     {
         for (int i = 0; i < _decisionTable.ConditionCount; i++)
         {
             if (_decisionTable[i].Condition != null)
             {
                 Dictionary <UInt32, IMethodPointerNode> ms = new Dictionary <uint, IMethodPointerNode>();
                 _decisionTable[i].Condition.GetMethodPointers(ms);
                 if (ms.Count > 0)
                 {
                     foreach (KeyValuePair <UInt32, IMethodPointerNode> mp in ms)
                     {
                         if (mp.Value.MethodExecuter is T)
                         {
                             IActionMethodPointer ia = mp.Value.MethodObject as IActionMethodPointer;
                             if (ia != null)
                             {
                                 results.Add(ia);
                             }
                         }
                     }
                 }
             }
             if (_decisionTable[i].Actions != null)
             {
                 for (int k = 0; k < _decisionTable[i].Actions.Count; k++)
                 {
                     if (_decisionTable[i].Actions[k].Action == null)
                     {
                         _decisionTable[i].Actions[k].Action = GetActionInstance(_decisionTable[i].Actions[k].ActionId);
                     }
                     if (_decisionTable[i].Actions[k].Action != null)
                     {
                         MethodClass.CollectActionsByOwnerType <T>(_decisionTable[i].Actions[k].Action, results, usedMethods);
                     }
                 }
             }
         }
     }
 }
        private void checkTarget(TreeNodeObject node, BoolEventArgs e)
        {
            e.Result = false;
            TreeNodeCustomMethodPointer tncmp = node as TreeNodeCustomMethodPointer;

            if (tncmp != null)
            {
                if (tncmp.Method != null)
                {
                    if (tncmp.Method.ReturnBaseType != null && !typeof(void).IsAssignableFrom(tncmp.Method.ReturnBaseType))
                    {
                        e.Result = true;
                    }
                }
            }
            else
            {
                IActionMethodPointer mp = node.OwnerPointer as IActionMethodPointer;
                if (mp != null)
                {
                    if (!mp.NoReturn)
                    {
                        e.Result = true;
                    }
                }
                else
                {
                    MethodClass mc = node.OwnerPointer as MethodClass;
                    if (mc != null && mc.MethodReturnType != null)
                    {
                        if (!(typeof(void).Equals(mc.MethodReturnType.ParameterLibType)))
                        {
                            e.Result = true;
                        }
                    }
                }
            }
        }
        protected override void OnLoad(XmlNode node)
        {
            MathNodeRoot r = this.root;

            if (r != null)
            {
                XmlObjectReader xr = r.Reader as XmlObjectReader;
                if (xr != null)
                {
                    XmlNode nodeMethod = node.SelectSingleNode(XmlSerialization.XML_METHOD);
                    if (nodeMethod != null)
                    {
                        _methodPointer = (IActionMethodPointer)xr.ReadObject(nodeMethod, null);
                        _id            = XmlUtil.GetAttributeUInt(nodeMethod, XmlTags.XMLATT_NodeId);
                        InitializeChildren();
                    }
                }
                else
                {
                    throw new DesignerException("Reader not available calling MathNodeMethodPointer.OnLoad");
                }
            }
        }
 public void OnReadFromXmlNode(IXmlCodeReader reader, XmlNode node)
 {
     _methodPointer = (IActionMethodPointer)reader.ReadObject(node, null);
     _id            = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_NodeId);
 }
        public override void OnDoubleClick(Control host)
        {
            Form f = host.FindForm();

            if (f != null)
            {
                f.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            }
            host.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            IMethod m = null;

            if (_methodPointer != null)
            {
                m = _methodPointer.MethodPointed;
            }
            MethodClass scopeMethod = null;
            MathExpCtrl mctrl       = host as MathExpCtrl;

            if (mctrl != null)
            {
                scopeMethod = mctrl.ScopeMethod as MethodClass;
                if (scopeMethod == null)
                {
                    MathNodeRoot r = mctrl.Root;
                    if (r != null)
                    {
                        scopeMethod = r.ScopeMethod as MethodClass;
                    }
                }
            }
            FrmObjectExplorer dlg = DesignUtil.CreateSelectMethodDialog(scopeMethod, m);

            if (dlg != null)
            {
                dlg.SetCheckTaget(checkTarget);
                if (dlg.ShowDialog(f) == DialogResult.OK)
                {
                    IAction act = null;
                    if (_methodPointer != null)
                    {
                        act = _methodPointer.Action;
                    }
                    MethodClass mc = dlg.SelectedObject as MethodClass;
                    if (mc != null)
                    {
                        _methodPointer = mc.CreateMethodPointer(act) as IActionMethodPointer;
                    }
                    else
                    {
                        _methodPointer = (IActionMethodPointer)dlg.SelectedObject;
                    }
                    _methodPointer.Action = act;
                    ChildNodeCount        = _methodPointer.ParameterCount;
                    host.Invalidate();
                }
            }
            host.Cursor = System.Windows.Forms.Cursors.Default;
            if (f != null)
            {
                f.Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
Ejemplo n.º 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)
         {
             IMethod m = value as IMethod;
             IActionMethodPointer im     = null;
             MethodPointer        method = value as MethodPointer;
             if (m == null)
             {
                 IMethodPointerHolder mh = context.Instance as IMethodPointerHolder;
                 if (mh != null)
                 {
                     im = mh.GetMethodPointer();
                     if (im != null)
                     {
                         m = im.MethodPointed;
                     }
                 }
             }
             MethodClass  scopeMethod = null;
             Type         t           = edSvc.GetType();
             PropertyInfo pif0        = t.GetProperty("OwnerGrid");
             if (pif0 != null)
             {
                 object           g  = pif0.GetValue(edSvc, null);
                 MathPropertyGrid pg = g as MathPropertyGrid;
                 if (pg != null)
                 {
                     scopeMethod = pg.ScopeMethod as MethodClass;
                 }
             }
             if (scopeMethod == null)
             {
                 IAction ia = context.Instance as IAction;
                 if (ia != null)
                 {
                     scopeMethod = ia.ScopeMethod as MethodClass;
                 }
             }
             FrmObjectExplorer dlg = DesignUtil.CreateSelectMethodDialog(scopeMethod, m);
             if (edSvc.ShowDialog(dlg) == DialogResult.OK)
             {
                 IAction act = null;
                 if (method != null)
                 {
                     act = method.Action;
                 }
                 if (act == null)
                 {
                     if (im != null)
                     {
                         act = im.Action;
                     }
                 }
                 IPropertyEx p = dlg.SelectedObject as IPropertyEx;
                 if (p != null)
                 {
                     value = p.CreateSetterMethodPointer(act);
                 }
                 else
                 {
                     MethodPointer mp = dlg.SelectedObject as MethodPointer;
                     if (mp != null)
                     {
                         mp.Action = act;
                         value     = mp;
                     }
                     else
                     {
                         CustomMethodPointer cmp = dlg.SelectedObject as CustomMethodPointer;
                         if (cmp != null)
                         {
                             cmp.Action = act;
                             value      = cmp;
                         }
                     }
                 }
             }
         }
     }
     return(value);
 }
Ejemplo n.º 7
0
        static public void ValidateParameterValues(ParameterValueCollection parameters, IList <IParameter> ps, IActionMethodPointer owner)
        {
            List <ParameterValue> pvs = new List <ParameterValue>();

            for (int i = 0; i < ps.Count; i++)
            {
                bool bFound = false;
                foreach (ParameterValue pv in parameters)
                {
                    if (string.Compare(ps[i].Name, pv.Name, StringComparison.Ordinal) == 0)
                    {
                        bFound = true;
                        DataTypePointer dp = ps[i] as DataTypePointer;
                        if (dp != null)
                        {
                            pv.SetDataType(dp);
                        }
                        else
                        {
                            pv.SetDataType(ps[i].ParameterLibType);
                        }
                        pvs.Add(pv);
                        break;
                    }
                }
                if (!bFound)
                {
                    ParameterValue p = owner.CreateDefaultParameterValue(i);
                    pvs.Add(p);
                }
            }
            parameters.Clear();
            parameters.AddRange(pvs);
        }
Ejemplo n.º 8
0
        static public void ValidateParameterValues(ParameterValueCollection parameters, Type[] ps, IActionMethodPointer owner)
        {
            List <ParameterValue> pvs = new List <ParameterValue>();

            if (ps != null)
            {
                for (int i = 0; i < ps.Length; i++)
                {
                    bool bFound = false;
                    if (i < parameters.Count && parameters[i] != null)
                    {
                        if (parameters[i].ParameterLibType != null)
                        {
                            if (parameters[i].ValueType == EnumValueType.ConstantValue && ps[i].IsAssignableFrom(parameters[i].ParameterLibType))
                            {
                                bFound = true;
                                parameters[i].SetDataType(ps[i]);
                                pvs.Add(parameters[i]);
                            }
                            else
                            {
                                bFound = true;
                                pvs.Add(parameters[i]);
                            }
                        }
                    }
                    if (!bFound)
                    {
                        ParameterValue p = owner.CreateDefaultParameterValue(i);
                        if (p != null)
                        {
                            pvs.Add(p);
                        }
                    }
                }
            }
            parameters.Clear();
            parameters.AddRange(pvs);
        }