Пример #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (editorService != null)
                {
                    ObjectEditorForm frmEdit = new ObjectEditorForm();
                    object           temp    = ((ICloneable)value).Clone();
                    frmEdit.ObjectToEdit = temp;
                    DialogResult result = editorService.ShowDialog(frmEdit);
                    if (result == DialogResult.OK)
                    {
                        CopyProps((TypeInfo)value, (TypeInfo)temp);
                        return(value);
                    }
                    else
                    {
                        return(value);
                    }
                }
            }

            return(value);
        }
Пример #2
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                _editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (_editorService != null)
                {
                    var isInheritedType                 = false;
                    var isInheritedTypeWinForms         = false;
                    MemberDescriptor propertyDescriptor =
                        GeneratorController.Current.MainForm.ObjectInfoGrid.SelectedGridItem.PropertyDescriptor;

                    if (propertyDescriptor != null)
                    {
                        if (propertyDescriptor.Name == "Inherited Type")
                        {
                            isInheritedType = true;
                        }
                        if (propertyDescriptor.Name == "Inherited Type for WinForms")
                        {
                            isInheritedTypeWinForms = true;
                        }
                        if (propertyDescriptor.Name == "Criteria Objects" && value == null)
                        {
                            value = new TypeInfo();
                        }
                    }

                    object       temp;
                    DialogResult result;
                    using (var frmEdit = new ObjectEditorForm())
                    {
                        if (isInheritedType || isInheritedTypeWinForms)
                        {
                            if (value == null)
                            {
                                value = new TypeInfo();
                            }

                            ((TypeInfo)value).IsInheritedType         = isInheritedType;
                            ((TypeInfo)value).IsInheritedTypeWinForms = isInheritedTypeWinForms;
                        }

                        temp = ((ICloneable)value).Clone();
                        frmEdit.ObjectToEdit = temp;
                        result = _editorService.ShowDialog(frmEdit);
                    }
                    if (result == DialogResult.OK)
                    {
                        Copy(value, temp);
                        return(value);
                    }

                    return(value);
                }
            }

            return(value);
        }