public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var baseProperties = base.GetProperties(context, value, attributes); var valueAttributes = new Attribute[] { new RangeAttribute(0, 255), new EditorAttribute(DesignTypes.SliderEditor, DesignTypes.UITypeEditor) }; var properties = new PropertyDescriptor[4]; properties[0] = new PropertyDescriptorWrapper("Val0", baseProperties["Val0"], valueAttributes); properties[1] = new PropertyDescriptorWrapper("Val1", baseProperties["Val1"], valueAttributes); properties[2] = new PropertyDescriptorWrapper("Val2", baseProperties["Val2"], valueAttributes); properties[3] = new PropertyDescriptorWrapper("Val3", baseProperties["Val3"], valueAttributes); return(new PropertyDescriptorCollection(properties)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var baseProperties = base.GetProperties(context, value, attributes); var converterAttribute = new TypeConverterAttribute(typeof(DegreeConverter)); var editorAttribute = new EditorAttribute(DesignTypes.SliderEditor, DesignTypes.UITypeEditor); var angleAttributes = new Attribute[] { new RangeAttribute(-Math.PI, Math.PI), converterAttribute, editorAttribute }; var properties = new PropertyDescriptor[3]; properties[0] = new PropertyDescriptorWrapper("X", baseProperties["X"], angleAttributes); properties[1] = new PropertyDescriptorWrapper("Y", baseProperties["Y"], angleAttributes); properties[2] = new PropertyDescriptorWrapper("Z", baseProperties["Z"], angleAttributes); return(new PropertyDescriptorCollection(properties)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var baseProperties = base.GetProperties(context, value, attributes); var precisionAttribute = new PrecisionAttribute(0, 1); var editorAttribute = new EditorAttribute(DesignTypes.SliderEditor, DesignTypes.UITypeEditor); var hueAttributes = new Attribute[] { new RangeAttribute(0, 179), precisionAttribute, editorAttribute }; var satValAttributes = new Attribute[] { new RangeAttribute(0, 255), precisionAttribute, editorAttribute }; var properties = new PropertyDescriptor[3]; properties[0] = new PropertyDescriptorWrapper("H", baseProperties["Val0"], hueAttributes); properties[1] = new PropertyDescriptorWrapper("S", baseProperties["Val1"], satValAttributes); properties[2] = new PropertyDescriptorWrapper("V", baseProperties["Val2"], satValAttributes); return(new PropertyDescriptorCollection(properties)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var baseProperties = base.GetProperties(context, value, attributes); var propertyAttributes = context == null ? AttributeCollection.Empty : context.PropertyDescriptor.Attributes; var editorAttribute = propertyAttributes[typeof(EditorAttribute)] ?? new EditorAttribute(DesignTypes.NumericUpDownEditor, DesignTypes.UITypeEditor); var valueAttributes = new Attribute[] { propertyAttributes[typeof(PrecisionAttribute)], propertyAttributes[typeof(RangeAttribute)], editorAttribute }; var properties = new PropertyDescriptor[4]; properties[0] = new PropertyDescriptorWrapper("B", baseProperties["Val0"], valueAttributes); properties[1] = new PropertyDescriptorWrapper("G", baseProperties["Val1"], valueAttributes); properties[2] = new PropertyDescriptorWrapper("R", baseProperties["Val2"], valueAttributes); properties[3] = new PropertyDescriptorWrapper("A", baseProperties["Val3"], valueAttributes); var names = new[] { "B", "G", "R", "A" }; return(new PropertyDescriptorCollection(properties).Sort(names)); }