Exemplo n.º 1
0
 public Field GetNewField(ObjectClass objectClass)
 {
     this.comboTemplate.SelectedItem = objectClass;
     if (ShowDialog() == DialogResult.OK)
     {
         return(this.database.Classes.AddField(Template, this.textName.Text, EnumDescription.GetFieldType((string)this.comboType.SelectedItem)));
     }
     else
     {
         return(null);
     }
 }
        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));
        }