示例#1
0
        public GroupRule Add(string name)
        {
            GroupRule groupRule = new GroupRule();

            groupRule.Name = name;
            this.Add(groupRule);
            return(groupRule);
        }
        public override object GetValue(object component)
        {
            GroupRule groupRule = (GroupRule)component;

            if (this.Name == "FromValue")
            {
                return(this.field.Parse(groupRule.FromValue));
            }
            return(this.field.Parse(groupRule.ToValue));
        }
        public override void SetValue(object component, object value)
        {
            GroupRule groupRule = (GroupRule)component;

            if (this.Name == "FromValue")
            {
                groupRule.FromValue = Field.ToStringInvariant(value);
            }
            else
            {
                groupRule.ToValue = Field.ToStringInvariant(value);
            }
        }
示例#4
0
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, false);
            GroupRule groupRule = (GroupRule)value;
            Field     field     = groupRule.GetField();
            PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null);

            for (int i = 0; i < properties.Count; i++)
            {
                if (properties[i].IsBrowsable)
                {
                    if (groupRule.UseCustomColors && (properties[i].Name == "ColorCount" || properties[i].Name == "ColoringMode" || properties[i].Name == "ColorPalette" || properties[i].Name == "FromColor" || properties[i].Name == "MiddleColor" || properties[i].Name == "ToColor" || properties[i].Name == "BorderColor" || properties[i].Name == "GradientType" || properties[i].Name == "HatchStyle" || properties[i].Name == "Text" || properties[i].Name == "ToolTip" || properties[i].Name == "SecondaryColor"))
                    {
                        propertyDescriptorCollection.Add(TypeDescriptor.CreateProperty(value.GetType(), properties[i], new ReadOnlyAttribute(true)));
                    }
                    else if (properties[i].Name == "ColorPalette" && groupRule.ColoringMode != ColoringMode.DistinctColors)
                    {
                        propertyDescriptorCollection.Add(TypeDescriptor.CreateProperty(value.GetType(), properties[i], new ReadOnlyAttribute(true)));
                    }
                    else
                    {
                        if ((properties[i].Name == "FromColor" || properties[i].Name == "MiddleColor" || properties[i].Name == "ToColor") && groupRule.ColoringMode == ColoringMode.DistinctColors)
                        {
                            propertyDescriptorCollection.Add(TypeDescriptor.CreateProperty(value.GetType(), properties[i], new ReadOnlyAttribute(true)));
                            continue;
                        }
                        if (properties[i].Name == "CustomColors" && !groupRule.UseCustomColors)
                        {
                            ArrayList arrayList = new ArrayList();
                            foreach (Attribute attribute in properties[i].Attributes)
                            {
                                if (attribute is CategoryAttribute || attribute is DescriptionAttribute)
                                {
                                    arrayList.Add(attribute);
                                }
                            }
                            propertyDescriptorCollection.Add(new ReadOnlyCollectionDescriptor(properties[i].Name, (Attribute[])arrayList.ToArray(typeof(Attribute))));
                        }
                        else if (field != null && (properties[i].Name == "FromValue" || properties[i].Name == "ToValue"))
                        {
                            if (field.IsNumeric())
                            {
                                Attribute[] array = new Attribute[properties[i].Attributes.Count];
                                properties[i].Attributes.CopyTo(array, 0);
                                GroupRulePropertyDescriptor value2 = new GroupRulePropertyDescriptor(field, properties[i].Name, array);
                                propertyDescriptorCollection.Add(value2);
                            }
                            else
                            {
                                propertyDescriptorCollection.Add(TypeDescriptor.CreateProperty(value.GetType(), properties[i], new ReadOnlyAttribute(true)));
                            }
                        }
                        else
                        {
                            propertyDescriptorCollection.Add(properties[i]);
                        }
                    }
                }
            }
            return(propertyDescriptorCollection);
        }
示例#5
0
 protected override void OnInsertComplete(int index, object value)
 {
     base.OnInsertComplete(index, value);
     GroupRule groupRule = (GroupRule)value;
 }
示例#6
0
 public void Remove(GroupRule value)
 {
     base.List.Remove(value);
 }
示例#7
0
 public int Add(GroupRule value)
 {
     return(base.List.Add(value));
 }