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;
            }
        }
示例#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);
 }