Beispiel #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null && context.Instance != null && provider != null)
            {
                FieldTable fdt = (FieldTable)context.Instance;
                this.service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (this.service != null)
                {
                    using (FormColumnCollection form = new FormColumnCollection(fdt.Proxy.Database, (List <ColumnProperty>)value))
                    {
                        if (this.service.ShowDialog(form) == DialogResult.OK)
                        {
                            value = form.Collection;
                        }
                    }
                }
            }

            return(value);
        }
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (value is string)
            {
                AbstractField field = null;
                switch (EnumDescription.GetFieldType((string)value))
                {
                case FieldType.Text:
                    field = new FieldText((FieldProxy)context.Instance);
                    break;

                case FieldType.Number:
                    field = new FieldDecimal((FieldProxy)context.Instance);
                    break;

                case FieldType.Date:
                    field = new FieldDate((FieldProxy)context.Instance);
                    break;

                case FieldType.Image:
                    field = new FieldImage((FieldProxy)context.Instance);
                    break;

                case FieldType.Url:
                    field = new FieldUrl((FieldProxy)context.Instance);
                    break;

                case FieldType.Select:
                    field = new FieldSelect((FieldProxy)context.Instance);
                    break;

                case FieldType.Boolean:
                    field = new FieldBool((FieldProxy)context.Instance);
                    break;

                case FieldType.Table:
                    field = new FieldTable((FieldProxy)context.Instance);
                    break;

                case FieldType.Rating:
                    field = new FieldRaiting((FieldProxy)context.Instance);
                    break;

                case FieldType.Reference:
                    field = new FieldReference((FieldProxy)context.Instance);
                    break;

                case FieldType.List:
                    field = new FieldList((FieldProxy)context.Instance);
                    break;

                case FieldType.Memo:
                    field = new FieldMemo((FieldProxy)context.Instance);
                    break;
                }

                return(field);
            }

            return(base.ConvertFrom(context, culture, value));
        }