Beispiel #1
0
        private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            ClangTidyProperties Props = (ClangTidyProperties)propertyGrid1.SelectedObject;

            Props.SetHasUnsavedChanges(true);

            // When a CategoryVerb is selected, perform the corresponding action.
            PropertyDescriptor Property = e.ChangedItem.PropertyDescriptor;

            if (!(e.ChangedItem.Value is CategoryVerb))
            {
                return;
            }

            CategoryVerb Action = (CategoryVerb)e.ChangedItem.Value;

            if (Action == CategoryVerb.None)
            {
                return;
            }

            var Category = Property.Attributes.OfType <CategoryAttribute>().FirstOrDefault();

            if (Category == null)
            {
                return;
            }
            var SameCategoryProps = Props.GetProperties(new Attribute[] { Category });

            foreach (PropertyDescriptor P in SameCategoryProps)
            {
                if (P == Property)
                {
                    continue;
                }
                switch (Action)
                {
                case CategoryVerb.Disable:
                    P.SetValue(propertyGrid1.SelectedObject, false);
                    break;

                case CategoryVerb.Enable:
                    P.SetValue(propertyGrid1.SelectedObject, true);
                    break;

                case CategoryVerb.Inherit:
                    P.ResetValue(propertyGrid1.SelectedObject);
                    break;
                }
            }
            Property.ResetValue(propertyGrid1.SelectedObject);
            propertyGrid1.Invalidate();
        }