public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); DesignerFlexibleFloat flexFloatAtt = property.Attribute as DesignerFlexibleFloat; if (flexFloatAtt != null) { unitLabel.Text = flexFloatAtt.Units; } DesignerFlexibleInteger flexIntegerAtt = property.Attribute as DesignerFlexibleInteger; if (flexIntegerAtt != null) { unitLabel.Text = flexIntegerAtt.Units; } CanUseDefinition canUseDefinition = (CanUseDefinition)property.Property.GetValue(obj, null); if (AIType.Current != null) { Type type = canUseDefinition.PropertyType; foreach (Definition definition in AIType.Current.Definitions) { PropertyInfo[] properties = definition.Object.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo prop in properties) { if (!prop.CanRead || prop.PropertyType != type) { continue; } comboBox.Items.Add(definition.Name + '.' + prop.Name); } } } if (canUseDefinition.DefinitionName != string.Empty && canUseDefinition.DefinitionMember != string.Empty) { string str = canUseDefinition.DefinitionName + '.' + canUseDefinition.DefinitionMember; if (!comboBox.Items.Contains(str)) { comboBox.Items.Insert(0, str); } comboBox.Text = str; } }
public override void SetProperty(DesignerPropertyInfo property, object obj) { base.SetProperty(property, obj); DesignerFlexibleFloat flexFloatAtt = property.Attribute as DesignerFlexibleFloat; if (flexFloatAtt != null) { minNumericUpDown.DecimalPlaces = flexFloatAtt.Precision; minNumericUpDown.Minimum = (decimal)flexFloatAtt.Min; minNumericUpDown.Maximum = (decimal)flexFloatAtt.Max; minNumericUpDown.Increment = (decimal)flexFloatAtt.Steps; maxNumericUpDown.DecimalPlaces = flexFloatAtt.Precision; maxNumericUpDown.Minimum = (decimal)flexFloatAtt.Min; maxNumericUpDown.Maximum = (decimal)flexFloatAtt.Max; maxNumericUpDown.Increment = (decimal)flexFloatAtt.Steps; FlexiblePropertyFloat flexProp = (FlexiblePropertyFloat)property.Property.GetValue(obj, null); minNumericUpDown.Value = (decimal)flexProp.Min; maxNumericUpDown.Value = (decimal)flexProp.Max; unitLabel.Text = flexFloatAtt.Units; } DesignerFlexibleInteger flexIntegerAtt = property.Attribute as DesignerFlexibleInteger; if (flexIntegerAtt != null) { minNumericUpDown.DecimalPlaces = 0; minNumericUpDown.Minimum = (decimal)flexIntegerAtt.Min; minNumericUpDown.Maximum = (decimal)flexIntegerAtt.Max; minNumericUpDown.Increment = (decimal)flexIntegerAtt.Steps; maxNumericUpDown.DecimalPlaces = 0; maxNumericUpDown.Minimum = (decimal)flexIntegerAtt.Min; maxNumericUpDown.Maximum = (decimal)flexIntegerAtt.Max; maxNumericUpDown.Increment = (decimal)flexIntegerAtt.Steps; FlexiblePropertyInteger flexProp = (FlexiblePropertyInteger)property.Property.GetValue(obj, null); minNumericUpDown.Value = (decimal)flexProp.Min; maxNumericUpDown.Value = (decimal)flexProp.Max; unitLabel.Text = flexIntegerAtt.Units; } }