public virtual void Synchronize()
        {
            PropertyGridItemElement visualItem = VisualItem as PropertyGridItemElement;

            if (visualItem != null)
            {
                PropertyGridItem dataItem = visualItem.Data as PropertyGridItem;
                bool             indented = dataItem.Level > 0;
                if (indented)
                {
                    this.Visibility = ElementVisibility.Visible;
                }
                else
                {
                    this.Visibility = ElementVisibility.Hidden;
                }
            }
        }
        public override void Initialize(object owner, object value)
        {
            base.Initialize(owner, value);
            PropertyGridItem data = (owner as PropertyGridItemElement).Data as PropertyGridItem;

            if (data == null)
            {
                return;
            }
            BaseDropDownListEditorElement editorElement = this.EditorElement as BaseDropDownListEditorElement;

            editorElement.ListElement.BindingContext = data.PropertyGridTableElement.BindingContext;
            editorElement.DropDownStyle = RadDropDownStyle.DropDownList;
            if (data.TypeConverter.GetStandardValuesSupported((ITypeDescriptorContext)data))
            {
                ICollection   standardValues = (ICollection)data.TypeConverter.GetStandardValues((ITypeDescriptorContext)data);
                List <string> stringList     = new List <string>();
                if (standardValues != null)
                {
                    foreach (object obj in (IEnumerable)standardValues)
                    {
                        stringList.Add(data.TypeConverter.ConvertToString(obj));
                    }
                }
                string str = data.TypeConverter.ConvertToString(data.Value);
                if (!data.TypeConverter.GetStandardValuesExclusive((ITypeDescriptorContext)data))
                {
                    editorElement.DropDownStyle = RadDropDownStyle.DropDown;
                    if (!string.IsNullOrEmpty(str) && !stringList.Contains(str))
                    {
                        stringList.Insert(0, str);
                    }
                }
                editorElement.DataSource    = (object)stringList;
                editorElement.SelectedValue = (object)str;
            }
            editorElement.DoubleClick += new EventHandler(this.editorElement_DoubleClick);
            editorElement.MouseMove   += new MouseEventHandler(this.editorElement_MouseMove);
        }
        public override void Synchronize()
        {
            base.Synchronize();
            PropertyGridItem data = (PropertyGridItem)this.Data;

            if (data == null)
            {
                return;
            }
            this.CheckBoxElement.ToggleStateChanging -= new StateChangingEventHandler(this.checkBoxElement_ToggleStateChanging);
            this.CheckBoxElement.ToggleStateChanged  -= new StateChangedEventHandler(this.checkBoxElement_ToggleStateChanged);
            this.CheckBoxElement.IsThreeState         = data.IsThreeState;
            if ((object)data.PropertyType == (object)typeof(bool))
            {
                this.CheckBoxElement.ToggleState = (bool)data.Value ? Telerik.WinControls.Enumerations.ToggleState.On : Telerik.WinControls.Enumerations.ToggleState.Off;
            }
            else if ((object)data.PropertyType == (object)typeof(bool?))
            {
                bool?nullable = data.Value as bool?;
                if (nullable.HasValue)
                {
                    this.CheckBoxElement.ToggleState = nullable.Value ? Telerik.WinControls.Enumerations.ToggleState.On : Telerik.WinControls.Enumerations.ToggleState.Off;
                }
                else
                {
                    this.CheckBoxElement.ToggleState = Telerik.WinControls.Enumerations.ToggleState.Indeterminate;
                }
            }
            else if ((object)data.PropertyType == (object)typeof(Telerik.WinControls.Enumerations.ToggleState))
            {
                this.CheckBoxElement.ToggleState = (Telerik.WinControls.Enumerations.ToggleState)data.Value;
            }
            else if (data.TypeConverter != null && data.TypeConverter.CanConvertTo(typeof(Telerik.WinControls.Enumerations.ToggleState)))
            {
                this.CheckBoxElement.ToggleState = (Telerik.WinControls.Enumerations.ToggleState)data.TypeConverter.ConvertTo(data.Value, typeof(Telerik.WinControls.Enumerations.ToggleState));
            }
            this.checkBoxElement.ToggleStateChanged  += new StateChangedEventHandler(this.checkBoxElement_ToggleStateChanged);
            this.checkBoxElement.ToggleStateChanging += new StateChangingEventHandler(this.checkBoxElement_ToggleStateChanging);
        }
        protected virtual void DropEditor()
        {
            UITypeEditor editor = this.Editor;

            if (editor == null)
            {
                return;
            }
            try
            {
                PropertyGridItemElement ancestor1 = this.FindAncestor <PropertyGridItemElement>();
                if (ancestor1 == null)
                {
                    return;
                }
                PropertyGridItem data = ancestor1.Data as PropertyGridItem;
                if (data == null)
                {
                    return;
                }
                this.currentValue = !this.Validate() ? data.Value : this.Converter.ConvertFromString((ITypeDescriptorContext)data, Thread.CurrentThread.CurrentCulture, this.Text);
                object obj      = editor.EditValue((ITypeDescriptorContext)data, (IServiceProvider)this.editorService, this.currentValue);
                bool   expanded = data.Expanded;
                PropertyGridTableElement ancestor2 = this.FindAncestor <PropertyGridTableElement>();
                if (data.Expandable)
                {
                    data.Collapse();
                    ancestor1.UpdateLayout();
                }
                this.Value = obj;
                this.Text  = this.Converter.ConvertToString((ITypeDescriptorContext)data, Thread.CurrentThread.CurrentCulture, obj);
                ancestor2?.EndEdit();
                data.Expanded = expanded;
            }
            catch (Exception ex)
            {
            }
        }
        public virtual void Synchronize()
        {
            PropertyGridItem item = VisualItem.Data as PropertyGridItem;

            if (item != null)
            {
                if (item.Level == 0)
                {
                    this.Visibility = ElementVisibility.Collapsed;
                }
                else
                {
                    this.Visibility = ElementVisibility.Visible;
                }
            }
            PropertyGridItemElement visualItem = VisualItem as PropertyGridItemElement;

            if (visualItem != null)
            {
                this.SetValue(IsRootItemWithChildrenProperty, visualItem.Data.GridItems.Count > 0 && visualItem.Data.Level == 0);
                this.SetValue(IsInEditModeProperty, visualItem.GetValue(PropertyGridItemElement.IsInEditModeProperty));
            }
        }
        public override void Initialize(object owner, object value)
        {
            PropertyGridItem data = (owner as PropertyGridItemElement).Data as PropertyGridItem;

            System.Type propertyType = data.PropertyType;
            if ((object)propertyType == (object)typeof(Decimal) || (object)propertyType == (object)typeof(double) || ((object)propertyType == (object)typeof(float) || (object)propertyType == (object)typeof(Decimal?)) || ((object)propertyType == (object)typeof(double?) || (object)propertyType == (object)typeof(float?)))
            {
                ((RadSpinElement)this.EditorElement).DecimalPlaces = 2;
            }
            else
            {
                ((RadSpinElement)this.EditorElement).DecimalPlaces = 0;
            }
            if ((object)Nullable.GetUnderlyingType(propertyType) != null)
            {
                ((RadSpinElement)this.EditorElement).EnableNullValueInput = true;
            }
            else
            {
                ((RadSpinElement)this.EditorElement).EnableNullValueInput = false;
            }
            base.Initialize(owner, value);
            this.SetMinAndMaxValue(data);
        }
        public virtual void Synchronize()
        {
            PropertyGridItem data = this.VisualItem.Data as PropertyGridItem;

            if (data != null)
            {
                if (data.Level == 0)
                {
                    this.Visibility = ElementVisibility.Collapsed;
                }
                else
                {
                    this.Visibility = ElementVisibility.Visible;
                }
            }
            PropertyGridItemElement visualItem = this.VisualItem as PropertyGridItemElement;

            if (visualItem == null)
            {
                return;
            }
            int num1 = (int)this.SetValue(PropertyGridRowHeaderElement.IsRootItemWithChildrenProperty, (object)(bool)(data.GridItems.Count <= 0 ? 0 : (visualItem.Data.Level == 0 ? 1 : 0)));
            int num2 = (int)this.SetValue(PropertyGridRowHeaderElement.IsInEditModeProperty, visualItem.GetValue(PropertyGridItemElement.IsInEditModeProperty));
        }
 public override IVirtualizedElement <PropertyGridItemBase> CreateElement(
     PropertyGridItemBase data,
     object context)
 {
     if (this.propertyGridElement != null)
     {
         CreatePropertyGridItemElementEventArgs e = new CreatePropertyGridItemElementEventArgs(data);
         PropertyGridItem propertyGridItem        = data as PropertyGridItem;
         if (propertyGridItem != null)
         {
             e.ItemElementType = (object)propertyGridItem.PropertyType == (object)typeof(bool) || (object)propertyGridItem.PropertyType == (object)typeof(bool?) || (object)propertyGridItem.PropertyType == (object)typeof(ToggleState) ? typeof(PropertyGridCheckBoxItemElement) : ((object)propertyGridItem.PropertyType != (object)typeof(Color) ? typeof(PropertyGridItemElement) : typeof(PropertyGridColorItemElement));
         }
         if (data is PropertyGridGroupItem)
         {
             e.ItemElementType = typeof(PropertyGridGroupElement);
         }
         this.propertyGridElement.OnCreateItemElement(e);
         if ((object)e.ItemElementType != null)
         {
             return((IVirtualizedElement <PropertyGridItemBase>)Activator.CreateInstance(e.ItemElementType));
         }
     }
     return(base.CreateElement(data, context));
 }
 /// <summary>
 /// Detaches the currently attached logical item.
 /// </summary>
 public override void Detach()
 {
     this.item.PropertyChanged -= new PropertyChangedEventHandler(item_PropertyChanged);
     this.item = null;
 }
 public CreatePropertyGridItemEventArgs(Type itemType, PropertyGridItem parent)
 {
     this.itemType = itemType;
     this.parent   = parent;
 }
        protected virtual void SetMinAndMaxValue(PropertyGridItem item)
        {
            RadRangeAttribute attribute = item.Attributes[typeof(RadRangeAttribute)] as RadRangeAttribute;

            if (attribute != null)
            {
                this.MinValue = (Decimal)attribute.MinValue;
                this.MaxValue = (Decimal)attribute.MaxValue;
            }
            else
            {
                switch (System.Type.GetTypeCode(item.PropertyType))
                {
                case TypeCode.SByte:
                    this.MinValue = new Decimal((int)sbyte.MinValue);
                    this.MaxValue = new Decimal((int)sbyte.MaxValue);
                    break;

                case TypeCode.Byte:
                    this.MinValue = new Decimal(0);
                    this.MaxValue = new Decimal((int)byte.MaxValue);
                    break;

                case TypeCode.Int16:
                    this.MinValue = new Decimal((int)short.MinValue);
                    this.MaxValue = new Decimal((int)short.MaxValue);
                    break;

                case TypeCode.UInt16:
                    this.MinValue = new Decimal(0);
                    this.MaxValue = new Decimal((int)ushort.MaxValue);
                    break;

                case TypeCode.Int32:
                    this.MinValue = new Decimal(int.MinValue);
                    this.MaxValue = new Decimal(int.MaxValue);
                    break;

                case TypeCode.UInt32:
                    this.MinValue = new Decimal(0);
                    this.MaxValue = new Decimal((long)uint.MaxValue);
                    break;

                case TypeCode.Int64:
                    this.MinValue = new Decimal(long.MinValue);
                    this.MaxValue = new Decimal(long.MaxValue);
                    break;

                case TypeCode.UInt64:
                    this.MinValue = new Decimal(0);
                    this.MaxValue = new Decimal(-1, -1, 0, false, (byte)0);
                    break;

                case TypeCode.Single:
                    this.MinValue = new Decimal(-1, -1, -1, true, (byte)0);
                    this.MaxValue = new Decimal(-1, -1, -1, false, (byte)0);
                    break;

                case TypeCode.Double:
                    this.MinValue = new Decimal(-1, -1, -1, true, (byte)0);
                    this.MaxValue = new Decimal(-1, -1, -1, false, (byte)0);
                    break;

                case TypeCode.Decimal:
                    this.MinValue = new Decimal(-1, -1, -1, true, (byte)0);
                    this.MaxValue = new Decimal(-1, -1, -1, false, (byte)0);
                    break;
                }
            }
        }
示例#12
0
 /// <summary>
 /// Sets the current.
 /// </summary>
 /// <param name="item">The item.</param>
 public virtual void SetCurrent(PropertyGridItem item)
 {
 }
示例#13
0
 public override void Detach()
 {
     this.item.PropertyChanged -= new PropertyChangedEventHandler(((PropertyGridItemElementBase)this).item_PropertyChanged);
     this.item = (PropertyGridItem)null;
 }
示例#14
0
        protected virtual PropertyGridItemCollection GetChildItems(PropertyGridItem parentItem, object obj, Type objType)
        {
            PropertyGridItemCollection items = new PropertyGridItemCollection(new List <PropertyGridItem>());

            if (obj == null)
            {
                return(items);
            }

            try
            {
                if (!this.TypeConverter.GetPropertiesSupported(this))
                {
                    return(items);
                }
                PropertyDescriptorCollection descriptors = this.TypeConverter.GetProperties(this, dataBoundItem, new Attribute[] { new BrowsableAttribute(true) });
                if (descriptors == null)
                {
                    return(items);
                }
                if (((descriptors == null) || (descriptors.Count == 0)) && (((objType != null) && objType.IsArray) && (obj != null)))
                {
                    Array array = (Array)obj;
                    for (int i = 0; i < array.Length; i++)
                    {
                        PropertyGridItem item = new PropertyGridItem(this.PropertyGridTableElement, parentItem);
                        item.Accessor = new ArrayItemAccessor(item, i);
                        items.AddProperty(item);
                    }
                    return(items);
                }
                bool createInstanceSupported = this.TypeConverter.GetCreateInstanceSupported(this);
                foreach (PropertyDescriptor childDescriptor in descriptors)
                {
                    PropertyGridItem item;
                    try
                    {
                        object component = obj;
                        if (obj is ICustomTypeDescriptor)
                        {
                            component = ((ICustomTypeDescriptor)obj).GetPropertyOwner(childDescriptor);
                        }
                        childDescriptor.GetValue(component);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    if (createInstanceSupported)
                    {
                        item          = new PropertyGridItem(this.PropertyGridTableElement, parentItem);
                        item.Accessor = new ImmutableItemAccessor(item, childDescriptor);
                    }
                    else
                    {
                        item          = new PropertyGridItem(this.PropertyGridTableElement, parentItem);
                        item.Accessor = new DescriptorItemAccessor(item, childDescriptor);
                    }
                    items.AddProperty(item);
                }
            }
            catch (Exception)
            {
            }
            return(items);
        }
示例#15
0
 public PropertyGridItem(PropertyGridTableElement propertyGridElement, PropertyGridItem parentItem)
     : base(propertyGridElement)
 {
     this.parentItem = parentItem;
 }