Esempio n. 1
0
        public virtual void MoveTo(IXtreeNode newParent, IXtreeNode oldParent, int idx, TreeNode movingNode)
        {
            int oldIdx = oldParent.Index(this);

            idx = AdjustIndex(newParent, movingNode, idx);

            // Make sure indexing is supported by the controller.
            if (oldIdx != -1)
            {
                // If we're moving the node internally to our own parent...
                if (newParent == oldParent)
                {
                    // Get the old index.
                    bool ret = AutoDeleteNode(oldParent);

                    // If this is before the new insert point, we can delete the old index
                    // and insert at idx-1, since everything is shifted back one entry.
                    // If the controller did not delete the node, then the insertion point
                    // is "idx", not "idx-1"
                    if ((oldIdx < idx) && (ret))
                    {
                        InsertNode(oldParent, idx - 1);
                    }
                    else
                    {
                        // the oldIdx occurs after the new point, so we can delete the old entry
                        // and insert the new one without changing the new index point.
                        InsertNode(oldParent, idx);
                    }
                }
                else
                {
                    // parent is different, so delete our node...
                    AutoDeleteNode(oldParent);
                    // Insert our field in the new parent.
                    InsertNode(newParent, idx);
                }
            }
        }
Esempio n. 2
0
		public virtual void MoveTo(IXtreeNode newParent, IXtreeNode oldParent, int idx, TreeNode movingNode)
		{
			int oldIdx = oldParent.Index(this);
			idx=AdjustIndex(newParent, movingNode, idx);

			// Make sure indexing is supported by the controller.
			if (oldIdx != -1)
			{
				// If we're moving the node internally to our own parent...
				if (newParent == oldParent)
				{
					// Get the old index.
					bool ret=AutoDeleteNode(oldParent);

					// If this is before the new insert point, we can delete the old index
					// and insert at idx-1, since everything is shifted back one entry.
					// If the controller did not delete the node, then the insertion point
					// is "idx", not "idx-1"
					if ( (oldIdx < idx) && (ret) )
					{
						InsertNode(oldParent, idx - 1);
					}
					else
					{
						// the oldIdx occurs after the new point, so we can delete the old entry
						// and insert the new one without changing the new index point.
						InsertNode(oldParent, idx);
					}
				}
				else
				{
					// parent is different, so delete our node...
					AutoDeleteNode(oldParent);
					// Insert our field in the new parent.
					InsertNode(newParent, idx);
				}
			}
		}