Ejemplo n.º 1
0
        internal PropertyVisibleDeepEnumerator(LinkedListNode node) : base(node)
        {
            // We may point to an invisible property so we must find for the first visible one after it

            // First we must ensure that all our ancestors are expanded. If not, this enumerator
            // will initially point to the upper enumerator that is collapsed
            PropertyEnumerator pEnumerator = new PropertyDeepEnumerator(Node);

            while (pEnumerator.HasParent)
            {
                pEnumerator.MoveParent();
                if ((pEnumerator.Property.Expanded == false) || (pEnumerator.Property.Visible == false))
                {
                    Node = pEnumerator.Node;
                }
            }

            if (this != LeftBound)
            {
                // Once we are on an expanded part of the tree we go to a visible property
                while ((this != RightBound) && (Property.Visible == false))
                {
                    MoveNext();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string str = "Deep++\n";

            PropertyDeepEnumerator enumerator = GetDeepEnumerator();

            while (enumerator.MoveNext() != enumerator.RightBound)
            {
                for (int i = 0; i < enumerator.Depth; i++)
                {
                    str += "-";
                }
                str += enumerator.Property.ToString() + "\n";
            }

            str += "\n\nDeep--\n";

            enumerator.MoveToRightBound();
            while (enumerator.MovePrev() != enumerator.LeftBound)
            {
                for (int i = 0; i < enumerator.Depth; i++)
                {
                    str += "-";
                }
                str += enumerator.Property.ToString() + "\n";
            }

            return(str);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes a property from the tree.
        /// </summary>
        /// <param name="propEnum">An enumerator pointing to the property to remove from the tree.</param>
        /// <returns>A deep enumerator on the property that would be naturally selected if the deleted
        /// item was selected.</returns>
        public PropertyEnumerator Delete(PropertyEnumerator propEnum)
        {
            // Store the previous property (deep)
            PropertyDeepEnumerator dEnumerator = new PropertyDeepEnumerator(propEnum.Node);

            dEnumerator.MovePrev();

            // Remove the property
            propEnum.Node.Owner.Remove(propEnum.Node);

            // Determine the next property of the property that was deleted
            if (dEnumerator.MoveNext() == dEnumerator.RightBound)
            {
                dEnumerator.MovePrev();
            }
            if (dEnumerator == dEnumerator.LeftBound)
            {
                dEnumerator = dEnumerator.RightBound.GetDeepEnumerator();
            }

            // Since the enumerator passed in argument now points to an invalid property,
            // we make it point to the next property (the previous one if no next exists)
            propEnum.Node = dEnumerator.Node;

            return(dEnumerator);
        }
Ejemplo n.º 4
0
        public static bool operator <(PropertyEnumerator propEnum1, PropertyEnumerator propEnum2)
        {
            PropertyDeepEnumerator currentEnumerator = new PropertyDeepEnumerator(propEnum1.Node);

            while (currentEnumerator.MoveNext() != currentEnumerator.RightBound)
            {
                if (currentEnumerator == propEnum2)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Searches a property given its ID inside the whole property tree but only from a given enumerator and beyond.
        /// The enumerator can be sibling or deep and will restrict the search accordingly.
        /// </summary>
        /// <param name="afterEnumerator">The enumerator from which the property will be searched.</param>
        /// <param name="propertyId">The ID of the property being searched.</param>
        /// <returns>A deep enumerator pointing to the found property. If not found it will point to RightBound.</returns>
        public PropertyEnumerator FindAfter(PropertyEnumerator afterEnumerator, int propertyId)
        {
            PropertyEnumerator propEnum = new PropertyDeepEnumerator(afterEnumerator.Node);

            while (propEnum.MoveNext() != propEnum.RightBound)
            {
                if (propEnum.Property.Id == propertyId)
                {
                    break;
                }
            }

            // If the element is not found, the enumerator will point to RightBound
            return(propEnum);
        }
Ejemplo n.º 6
0
        public bool IsDescendantOf(PropertyEnumerator enumAncestor)
        {
            // This is an agreement that a property is not a descendant of itself
            if (this == enumAncestor)
            {
                return(false);
            }

            PropertyDeepEnumerator currentEnum = GetDeepEnumerator();

            while (currentEnum.HasParent && (enumAncestor != currentEnum))
            {
                currentEnum.MoveParent();
            }

            return(enumAncestor == currentEnum);
        }
Ejemplo n.º 7
0
        internal PropertyVisibleSiblingEnumerator(LinkedListNode node) : base(node)
        {
            // We may point to an invisible property so we must find for the first visible one after it

            // First we must ensure that all our ancestors are expanded. If not, this enumerator
            // will initially point to RightBound
            PropertyEnumerator pEnumerator = new PropertyDeepEnumerator(Node);

            while (pEnumerator.HasParent)
            {
                pEnumerator.MoveParent();
                if ((pEnumerator.Property.Expanded == false) || (pEnumerator.Property.Visible == false))
                {
                    Node = RightBound.Node;
                    break;
                }
            }

            while ((this != RightBound) && (Property.Visible == false))
            {
                MoveNext();
            }
        }
Ejemplo n.º 8
0
        protected override void CalcLeftAndRightBounds()
        {
            if (_restrictToThisLinkedListAndUnder == null)
            {
                // Since this enumerator parses the entire tree, left and right bounds are the bounds
                // of the root linked list
                LinkedList parentList = Node.Owner;
                while (parentList.Parent != null)
                {
                    parentList = parentList.Parent.Owner;
                }

                // We use the constructor with 0 parameters to avoid recursion
                mLeftBound       = new PropertyDeepEnumerator();
                mLeftBound.Node  = parentList.LeftBound;
                mRightBound      = new PropertyDeepEnumerator();
                mRightBound.Node = parentList.RightBound;
            }
            else
            {
                // Since this enumerator parses only properties at and under this level, left and right bounds are the bounds
                // of the current node as if it was in a sibling enumerator

                mLeftBound      = new PropertySiblingEnumerator();
                mLeftBound.Node = Node.Owner.LeftBound;

                mRightBound      = new PropertySiblingEnumerator();
                mRightBound.Node = Node.Owner.RightBound;
            }

            mLeftBound.LeftBoundInternal  = LeftBound;
            mLeftBound.RightBoundInternal = RightBound;

            mRightBound.LeftBoundInternal  = LeftBound;
            mRightBound.RightBoundInternal = RightBound;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Searches a property given its ID inside the whole property tree but only from a given enumerator and beyond.
        /// The enumerator can be sibling or deep and will restrict the search accordingly.
        /// </summary>
        /// <param name="afterEnumerator">The enumerator from which the property will be searched.</param>
        /// <param name="propertyId">The ID of the property being searched.</param>
        /// <returns>A deep enumerator pointing to the found property. If not found it will point to RightBound.</returns>
        public PropertyEnumerator FindAfter(PropertyEnumerator afterEnumerator, int propertyId)
        {
            PropertyEnumerator propEnum = new PropertyDeepEnumerator(afterEnumerator.Node);
            while (propEnum.MoveNext() != propEnum.RightBound)
            {
                if (propEnum.Property.Id == propertyId)
                    break;
            }

            // If the element is not found, the enumerator will point to RightBound
            return propEnum;
        }
Ejemplo n.º 10
0
        internal PropertyVisibleSiblingEnumerator(LinkedListNode node) : base(node)
        {
            // We may point to an invisible property so we must find for the first visible one after it

            // First we must ensure that all our ancestors are expanded. If not, this enumerator
            // will initially point to RightBound
            PropertyEnumerator pEnumerator = new PropertyDeepEnumerator(Node);
            while (pEnumerator.HasParent)
            {
                pEnumerator.MoveParent();
                if ((pEnumerator.Property.Expanded == false) || (pEnumerator.Property.Visible == false))
                {
                    Node = RightBound.Node;
                    break;
                }
            }

            while ((this != RightBound) && (Property.Visible == false))
                MoveNext();
        }
Ejemplo n.º 11
0
        internal PropertyVisibleDeepEnumerator(LinkedListNode node) : base(node)
        {
            // We may point to an invisible property so we must find for the first visible one after it

            // First we must ensure that all our ancestors are expanded. If not, this enumerator
            // will initially point to the upper enumerator that is collapsed
            PropertyEnumerator pEnumerator = new PropertyDeepEnumerator(Node);
            while (pEnumerator.HasParent)
            {
                pEnumerator.MoveParent();
                if ((pEnumerator.Property.Expanded == false) || (pEnumerator.Property.Visible == false))
                    Node = pEnumerator.Node;
            }

            if (this != LeftBound)
            {
                // Once we are on an expanded part of the tree we go to a visible property
                while ((this != RightBound) && (Property.Visible == false))
                    MoveNext();
            }
        }
Ejemplo n.º 12
0
        protected override void CalcLeftAndRightBounds()
        {
            if (_restrictToThisLinkedListAndUnder == null)
            {
                // Since this enumerator parses the entire tree, left and right bounds are the bounds
                // of the root linked list
                LinkedList parentList = Node.Owner;
                while (parentList.Parent != null)
                    parentList = parentList.Parent.Owner;

                // We use the constructor with 0 parameters to avoid recursion
                mLeftBound = new PropertyDeepEnumerator();
                mLeftBound.Node = parentList.LeftBound;
                mRightBound = new PropertyDeepEnumerator();
                mRightBound.Node = parentList.RightBound;
            }
            else
            {
                // Since this enumerator parses only properties at and under this level, left and right bounds are the bounds
                // of the current node as if it was in a sibling enumerator

                mLeftBound = new PropertySiblingEnumerator();
                mLeftBound.Node = Node.Owner.LeftBound;

                mRightBound = new PropertySiblingEnumerator();
                mRightBound.Node = Node.Owner.RightBound;
            }

            mLeftBound.LeftBoundInternal = LeftBound;
            mLeftBound.RightBoundInternal = RightBound;

            mRightBound.LeftBoundInternal = LeftBound;
            mRightBound.RightBoundInternal = RightBound;
        }
Ejemplo n.º 13
0
        public static bool operator <(PropertyEnumerator propEnum1, PropertyEnumerator propEnum2)
        {
            PropertyDeepEnumerator currentEnumerator = new PropertyDeepEnumerator(propEnum1.Node);
            while (currentEnumerator.MoveNext() != currentEnumerator.RightBound)
            {
                if (currentEnumerator == propEnum2)
                    return true;
            }

            return false;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Removes a property from the tree.
        /// </summary>
        /// <param name="propEnum">An enumerator pointing to the property to remove from the tree.</param>
        /// <returns>A deep enumerator on the property that would be naturally selected if the deleted
        /// item was selected.</returns>
        public PropertyEnumerator Delete(PropertyEnumerator propEnum)
        {
            // Store the previous property (deep)
            PropertyDeepEnumerator dEnumerator = new PropertyDeepEnumerator(propEnum.Node);
            dEnumerator.MovePrev();

            // Remove the property
            propEnum.Node.Owner.Remove(propEnum.Node);

            // Determine the next property of the property that was deleted
            if (dEnumerator.MoveNext() == dEnumerator.RightBound)
                dEnumerator.MovePrev();
            if (dEnumerator == dEnumerator.LeftBound)
                dEnumerator = dEnumerator.RightBound.GetDeepEnumerator();

            // Since the enumerator passed in argument now points to an invalid property,
            // we make it point to the next property (the previous one if no next exists)
            propEnum.Node = dEnumerator.Node;

            return dEnumerator;
        }
Ejemplo n.º 15
0
        public bool CheckPropertyVisibility(PropertyEnumerator propEnum)
        {
            PropertyEnumerator currentEnum = new PropertyDeepEnumerator(propEnum.Node);
            do
            {
                if (currentEnum.Property.Visible == false)
                    return false;

                if (currentEnum.HasParent)
                {
                    currentEnum = currentEnum.Parent;

                    if (currentEnum.Property.Expanded == false)
                        return false;
                }
            }
            while (currentEnum.HasParent);

            return true;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Searches a property given its ID across the whole property tree.
        /// </summary>
        /// <param name="propertyId">The ID of the property being searched.</param>
        /// <returns>A deep enumerator pointing to the found property. If not found it will point to RightBound.</returns>
        public PropertyEnumerator Find(int propertyId)
        {
            PropertyDeepEnumerator enumerator = GetDeepEnumerator();

            return(FindAfter(enumerator, propertyId));
        }