public static ActionClass createAction(IClass holder, IProperty ei, XmlObjectWriter writer, XmlNode node, IMethod scopeMethod, IActionsHolder actsHolder, Form caller)
 {
     if (ei != null)
     {
         IPropertyEx pp = ei as IPropertyEx;
         if (pp != null)
         {
             ActionClass act = new ActionClass(pp.RootPointer);
             act.ActionMethod = pp.CreateSetterMethodPointer(act);
             act.ActionName   = act.ActionMethod.DefaultActionName;
             act.ActionHolder = actsHolder;
             if (pp.RootPointer.CreateNewAction(act, writer, scopeMethod, caller))
             {
                 return(act);
             }
         }
         else
         {
             PropertyClass pc = ei as PropertyClass;
             if (pc != null)
             {
                 PropertyClass pc2 = (PropertyClass)pc.Clone();
                 pc2.SetHolder(holder);
                 ActionClass act = new ActionClass(holder.RootPointer);
                 act.ActionMethod = pc2.CreateSetterMethodPointer(act);
                 act.ActionName   = act.ActionMethod.DefaultActionName;                      // pc.Holder.CodeName + ".Set" + pc.Name;
                 act.ActionHolder = actsHolder;
                 if (holder.RootPointer.CreateNewAction(act, writer, scopeMethod, caller))
                 {
                     return(act);
                 }
             }
             else
             {
             }
         }
     }
     return(null);
 }
Esempio n. 2
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);
 }