Пример #1
0
        private void buttonInsert_Click(object sender, EventArgs e)
        {
            FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(null, null, new DataTypePointer(new TypePointer(typeof(IProperty))));

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                IProperty p = dlg.SelectedObject as IProperty;
                if (p != null)
                {
                    bool bFound = false;
                    for (int i = 0; i < _table.Rows.Count; i++)
                    {
                        IProperty p0 = _table.Rows[i][0] as IProperty;
                        if (p0 != null)
                        {
                            if (p0.IsSameObjectRef(p))
                            {
                                dataGridView1.Rows[i].Selected = true;
                                bFound = true;
                                break;
                            }
                        }
                    }
                    if (!bFound)
                    {
                        _table.Rows.Add(p, null);
                        dataGridView1.Refresh();
                    }
                }
            }
        }
Пример #2
0
        public override void OnDoubleClick(Control host)
        {
            Form f = host.FindForm();

            host.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            if (f != null)
            {
                f.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            }
            IObjectPointer pp     = _valuePointer;
            IMethod        method = null;
            MathNodeRoot   r      = this.root;

            if (r != null)
            {
                method = r.ScopeMethod;
            }
            FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(pp, method, null);

            if (dlg != null)
            {
                if (dlg.ShowDialog(f) == DialogResult.OK)
                {
                    _valuePointer = dlg.SelectedObject as IObjectPointer;
                    host.Invalidate();
                }
            }
            host.Cursor = System.Windows.Forms.Cursors.Default;
            if (f != null)
            {
                f.Cursor = System.Windows.Forms.Cursors.Default;
            }
        }
Пример #3
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)
         {
             MethodDataTransfer mdt = context.Instance as MethodDataTransfer;
             if (mdt == null)
             {
                 IAction act = context.Instance as IAction;
                 if (act != null)
                 {
                     mdt = act.ActionMethod as MethodDataTransfer;
                 }
             }
             if (mdt != null)
             {
                 FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(null, mdt.Action.ScopeMethod, null);
                 dlg.SetMultipleSelection(true);
                 dlg.ObjectSubType = EnumObjectSelectSubType.Property;
                 if (edSvc.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                 {
                     if (dlg.SelectedProperties != null)
                     {
                         foreach (IProperty p in dlg.SelectedProperties)
                         {
                             mdt.AddProperty(p);
                         }
                         PropertyGrid pg   = null;
                         Type         t    = edSvc.GetType();
                         PropertyInfo pif0 = t.GetProperty("OwnerGrid");
                         if (pif0 != null)
                         {
                             object g = pif0.GetValue(edSvc, null);
                             pg = g as PropertyGrid;
                         }
                         if (pg != null && pg.SelectedGridItem != null)
                         {
                             pg.SelectedGridItem.Expanded = true;
                         }
                         mdt.OnChanged();
                         return(true);
                     }
                 }
             }
         }
     }
     return(string.Empty);
 }
Пример #4
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (service != null)
         {
             IObjectPointer mm = value as IObjectPointer;
             if (mm == null)
             {
                 PropertyPointer pp = new PropertyPointer();
                 IDataScope      dv = context.Instance as IDataScope;
                 if (dv != null)
                 {
                     pp.Scope = dv.ScopeDataType;
                     pp.Owner = dv.ScopeOwner;
                 }
                 mm = pp;
             }
             if (mm != null)
             {
                 IMethod      imScope = null;
                 Type         t       = service.GetType();
                 PropertyInfo pif0    = t.GetProperty("OwnerGrid");
                 if (pif0 != null)
                 {
                     object           pv = pif0.GetValue(service, null);
                     MathPropertyGrid pg = pv as MathPropertyGrid;
                     if (pg != null)
                     {
                         imScope = pg.ScopeMethod;
                     }
                 }
                 if (imScope == null)
                 {
                     IScopeMethodHolder mh = context.Instance as IScopeMethodHolder;
                     if (mh != null)
                     {
                         imScope = mh.GetScopeMethod();
                     }
                 }
                 DataTypePointer scope = null;
                 IOwnerScope     ios   = context.Instance as IOwnerScope;
                 if (ios != null)
                 {
                     scope = ios.OwnerScope;
                 }
                 if (scope == null)
                 {
                     ParameterValue pv = context.Instance as ParameterValue;
                     if (pv != null && pv.DataType != null && pv.DataType.BaseClassType != null)
                     {
                         if (typeof(Delegate).IsAssignableFrom(pv.DataType.BaseClassType))
                         {
                             scope = pv.DataType;
                         }
                     }
                 }
                 FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(mm, imScope, scope);
                 if (dlg != null)
                 {
                     OnDialogCreated(dlg);
                     if (service.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK)
                     {
                         bool   isValid = true;
                         string msg     = string.Empty;
                         if (MethodEditContext.IsWebPage)
                         {
                             IObjectPointer iop = dlg.SelectedObject as IObjectPointer;
                             if (iop != null)
                             {
                                 if (MethodEditContext.UseClientPropertyOnly)
                                 {
                                     if (iop.RunAt == EnumWebRunAt.Server)
                                     {
                                         isValid = false;
                                         msg     = "Server value is not allowed";
                                     }
                                 }
                                 else if (MethodEditContext.UseServerPropertyOnly)
                                 {
                                     if (iop.RunAt == EnumWebRunAt.Client)
                                     {
                                         isValid = false;
                                         msg     = "Client value is not allowed";
                                     }
                                 }
                             }
                         }
                         if (!isValid)
                         {
                             MessageBox.Show(msg, "Select value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         }
                         else
                         {
                             value = dlg.SelectedObject;
                             if (context.PropertyDescriptor.IsReadOnly)
                             {
                                 //manually set it
                                 PropertyInfo pif = context.Instance.GetType().GetProperty(context.PropertyDescriptor.Name);
                                 pif.SetValue(context.Instance, value, new object[] { });
                             }
                         }
                     }
                     dlg.ResetSelectLValue();
                 }
             }
         }
     }
     return(value);
 }