コード例 #1
0
        /// <summary>
        /// Handles the DragDelta event of the Thumb control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DragDeltaEventArgs"/> instance containing the event data.</param>
        protected void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            ResizeThumb resizeThumb = sender as ResizeThumb;

            if (resizeThumb == null)
            {
                return;
            }

            Point  position = PointToScreen(Mouse.GetPosition(this.currentWindow));
            double deltaX   = position.X - this.dragMouseStartPosition.X;
            double deltaY   = position.Y - this.dragMouseStartPosition.Y;

            // Horizontal resize
            if ((resizeThumb.ResizeGripDirection & ResizeGripDirection.Left) == ResizeGripDirection.Left)
            {
                SetWindowWidth(this.windowInitialSize.Width - deltaX);
                this.currentWindow.Left = this.dragWindowStartPosition.X + deltaX;
            }
            else if ((resizeThumb.ResizeGripDirection & ResizeGripDirection.Right) == ResizeGripDirection.Right)
            {
                SetWindowWidth(this.windowInitialSize.Width + deltaX);
            }

            // Vertical resize
            if ((resizeThumb.ResizeGripDirection & ResizeGripDirection.Top) == ResizeGripDirection.Top)
            {
                SetWindowHeight(this.windowInitialSize.Height + deltaY);
                this.currentWindow.Top = this.dragWindowStartPosition.Y - deltaY;
            }
            else if ((resizeThumb.ResizeGripDirection & ResizeGripDirection.Bottom) == ResizeGripDirection.Bottom)
            {
                SetWindowHeight(this.windowInitialSize.Height + deltaY);
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the DragStarted event of the Thumb control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DragStartedEventArgs"/> instance containing the event data.</param>
        protected void Thumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            ResizeThumb resizeThumb = sender as ResizeThumb;

            if (resizeThumb == null)
            {
                return;
            }

            // Save settings here that will be used later
            this.dragMouseStartPosition  = PointToScreen(Mouse.GetPosition(this.currentWindow));
            this.dragWindowStartPosition = new Point(this.currentWindow.Left, this.currentWindow.Top);
            this.windowInitialSize       = new Size(this.currentWindow.Width, this.currentWindow.Height);
        }
コード例 #3
0
        /// <summary>
        /// Creates the thumb.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="visualCursor">The visual cursor.</param>
        /// <returns></returns>
        protected ResizeThumb CreateThumb(ResizeGripDirection direction, Cursor visualCursor)
        {
            ResizeThumb thumb = new ResizeThumb
            {
                ResizeGripDirection = direction,
                Cursor = visualCursor
            };

            thumb.DragStarted += Thumb_DragStarted;
            thumb.DragDelta   += Thumb_DragDelta;

            this.visualChildren.Add(thumb);

            return(thumb);
        }
コード例 #4
0
        /// <summary>
        /// Creates the thumb.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <param name="visualCursor">The visual cursor.</param>
        /// <returns></returns>
        protected ResizeThumb CreateThumb(ResizeGripDirection direction, Cursor visualCursor)
        {
            ResizeThumb thumb = new ResizeThumb
            {
                ResizeGripDirection = direction,
                Cursor = visualCursor
            };

            thumb.DragStarted += Thumb_DragStarted;
            thumb.DragDelta += Thumb_DragDelta;

            this.visualChildren.Add(thumb);

            return thumb;
        }