Ejemplo n.º 1
0
        public PropertyEnumerator InsertRootCategory(PropertyEnumerator beforeCategory, int id, string catName)
        {
            if (beforeCategory == _activePropertyCollection.GetDeepEnumerator().RightBound)
                return AppendRootCategory(id, catName);

            System.Diagnostics.Debug.Assert(DisplayMode == PropertyGrid.DisplayModes.Categorized, "Properties can only be inserted in categorized mode.");

            System.Diagnostics.Debug.Assert(beforeCategory.HasParent == false, "Root categories can only be inserted at the root.");

            RootCategory category = new RootCategory(id, catName);
            category.ParentGridInternal = _parentCtrl;

            PropertyEnumerator propEnum = _activePropertyCollection.InsertBefore(beforeCategory, category);

            // When there is no category yet or (when we are in SelectedObject and the new category should be the
            // first one) then set the new category as the first displayed one
            PropertyEnumerator catEnum = ((PropertyEnumerator)propEnum.Clone()).MovePrev();
            if ((FirstDisplayedProperty == _activePropertyCollection.GetVisibleDeepEnumerator().RightBound) ||
                (_parentCtrl.IsInsideSelectedObjects && (catEnum == propEnum.LeftBound)))
                FirstDisplayedProperty = propEnum.GetVisibleDeepEnumerator();

            InvalidateVisibleItemCount();

            if (Handle != IntPtr.Zero)    // necessary test ?
                Invalidate();

            CheckScrollbar();

            _parentCtrl.OnPropertyCreated(new PropertyCreatedEventArgs(propEnum));

            return propEnum;
        }
Ejemplo n.º 2
0
        public PropertyEnumerator AppendRootCategory(int id, string catName)
        {
            System.Diagnostics.Debug.Assert(DisplayMode == PropertyGrid.DisplayModes.Categorized, "Properties can only be inserted in categorized mode.");

            RootCategory category = new RootCategory(id, catName);
            category.ParentGridInternal = _parentCtrl;

            PropertyEnumerator propEnum = _activePropertyCollection.Append(_activePropertyCollection.GetDeepEnumerator(), category);

            if (FirstDisplayedProperty == _activePropertyCollection.GetVisibleDeepEnumerator().RightBound)
                FirstDisplayedProperty = propEnum.GetVisibleDeepEnumerator();

            InvalidateVisibleItemCount();

	        if (Handle != IntPtr.Zero)    // necessary test ?
                Invalidate();

            if (FirstProperty.Count == 1)
                SelectProperty(FirstProperty);

            CheckScrollbar();

            _parentCtrl.OnPropertyCreated(new PropertyCreatedEventArgs(propEnum));

            return propEnum;
        }