示例#1
0
        // Move this window underneath the last window with the same parent.
        void IToolkitWindow.Lower()
        {
            // Find the last window with the same parent as this.
            DrawingWindow toWindow = null;

            for (int to = toolkit.windowCount - 1; to >= 0; to--)
            {
                toWindow = toolkit.windows[to];
                if (parent.IsParentOf(toWindow))
                {
                    break;
                }
            }
            (this as IToolkitWindow).MoveToBelow(toWindow as IToolkitWindow);
            //Console.WriteLine("DrawingWindow.Lower, " + sink);
        }
示例#2
0
        // Move the window at position from to position to
        // Also move all the children in the from windows hierarchy
        protected void MoveWindowTo(DrawingWindow fromWindow, DrawingWindow toWindow)
        {
            // Find the from position.
            int from;

            for (from = 0; from < toolkit.windowCount; from++)
            {
                if (toolkit.windows[from] == fromWindow)
                {
                    break;
                }
            }
            // Find the to position.
            int to;

            for (to = 0; to < toolkit.windowCount; to++)
            {
                if (toolkit.windows[to] == toWindow)
                {
                    break;
                }
            }
            if (to == toolkit.windowCount)
            {
                to--;
            }

            if (from == to + 1 || from == to)
            {
                return;
            }
            DrawingWindow[] move       = new DrawingWindow[16];
            int             nextMove   = 0;
            int             toPosition = to;

            // Move all children of "win" into the move array.
            // Mark the children with null if they have been moved.
            for (int i = from; i < toolkit.windowCount; i++)
            {
                DrawingWindow current = toolkit.windows[i];
                if (fromWindow.IsParentOf(current) || current == fromWindow)
                {
                    if (nextMove == move.Length)
                    {
                        DrawingWindow[] newMove = new DrawingWindow[move.Length * 2];
                        move.CopyTo(newMove, 0);
                        move = newMove;
                    }
                    toolkit.windows[i] = null;
                    move[nextMove++]   = current;
                    if (i <= toPosition)
                    {
                        to--;
                    }
                }
            }

            // Fill in the null "holes".
            int nonNullItem = from;

            for (int i = from; i < toolkit.windowCount - nextMove; i++)
            {
                DrawingWindow window = toolkit.windows[i];
                // Make sure we fill it with the next non null window.
                for (;; nonNullItem++)
                {
                    if (toolkit.windows[nonNullItem] != null)
                    {
                        toolkit.windows[i] = toolkit.windows[nonNullItem++];
                        break;
                    }
                }
            }

            // Make room for the new windows.
            Array.Copy(toolkit.windows, to + 1, toolkit.windows, to + 1 + nextMove, toolkit.windowCount - 1 - to - nextMove);
            // Copy the move entries after the to location.
            Array.Copy(move, 0, toolkit.windows, to + 1, nextMove);
        }
	// Move the window at position from to position to
	// Also move all the children in the from windows hierarchy
	protected void MoveWindowTo(DrawingWindow fromWindow, DrawingWindow toWindow)
	{
		// Find the from position.
		int from;
		for (from = 0; from < toolkit.windowCount; from++)
		{
			if (toolkit.windows[from] == fromWindow)
				break;
		}
		// Find the to position.
		int to;
		for (to = 0; to < toolkit.windowCount; to++)
		{
			if (toolkit.windows[to] == toWindow)
				break;
		}
		if(to == toolkit.windowCount)
		{
			to--;
		}

		if (from == to + 1 || from == to)
			return;
		DrawingWindow[] move = new DrawingWindow[16];
		int nextMove = 0;
		int toPosition = to;
		// Move all children of "win" into the move array.
		// Mark the children with null if they have been moved.
		for (int i = from; i < toolkit.windowCount; i++)
		{
			DrawingWindow current = toolkit.windows[i];
			if (fromWindow.IsParentOf(current) || current == fromWindow)
			{
				if (nextMove == move.Length)
				{
					DrawingWindow[] newMove = new DrawingWindow[move.Length * 2];
					move.CopyTo(newMove, 0);
					move = newMove;
				}
				toolkit.windows[i] = null;
				move[nextMove++] = current;
				if (i <= toPosition)
				{
					to--;
				}
			}
		}

		// Fill in the null "holes".
		int nonNullItem = from;
		for(int i = from; i < toolkit.windowCount - nextMove; i++)
		{
			DrawingWindow window = toolkit.windows[i];
			// Make sure we fill it with the next non null window.
			for(;; nonNullItem++)
			{
				if (toolkit.windows[nonNullItem] != null)
				{
					toolkit.windows[i] = toolkit.windows[nonNullItem++];
					break;
				}
			}
		}

		// Make room for the new windows.
		Array.Copy(toolkit.windows,to + 1, toolkit.windows, to + 1 + nextMove, toolkit.windowCount - 1 - to - nextMove);
		// Copy the move entries after the to location.
		Array.Copy(move, 0, toolkit.windows , to + 1, nextMove);
	}