Example #1
0
        public void DoDrag(double horizontalChange, double verticalChange, RadWindow window)
        {
            this.UpdateMousePosition(horizontalChange, verticalChange);

            Rect  newLocation = Rect.Empty;
            Point mouseOffset = new Point(Math.Round(this.MousePosition.X - this.StartPoint.X),
                                          Math.Round(this.MousePosition.Y - this.StartPoint.Y));

            switch (this.DraggedThumbType)
            {
            case ThumbType.ElementNorthWestThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X + mouseOffset.X,
                                                    this.InitialRectangle.Y + mouseOffset.Y,
                                                    this.InitialRectangle.Width - mouseOffset.X,
                                                    this.InitialRectangle.Height - mouseOffset.Y,
                                                    this.InitialRectangle);
                break;

            case ThumbType.ElementNorthThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X,
                                                    this.InitialRectangle.Y + mouseOffset.Y,
                                                    this.InitialRectangle.Width,
                                                    this.InitialRectangle.Height - mouseOffset.Y,
                                                    this.InitialRectangle);
                break;

            case ThumbType.ElementNorthEastThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X,
                                                    this.InitialRectangle.Y + mouseOffset.Y,
                                                    this.InitialRectangle.Width + mouseOffset.X,
                                                    this.InitialRectangle.Height - mouseOffset.Y,
                                                    this.InitialRectangle);
                break;

            case ThumbType.ElementWestThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X + mouseOffset.X,
                                                    this.InitialRectangle.Y,
                                                    this.InitialRectangle.Width - mouseOffset.X,
                                                    this.InitialRectangle.Height,
                                                    this.InitialRectangle);
                break;

            case ThumbType.ElementEastThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X,
                                                    this.InitialRectangle.Y,
                                                    this.InitialRectangle.Width + mouseOffset.X,
                                                    this.InitialRectangle.Height,
                                                    this.InitialRectangle);
                break;

            case ThumbType.ElementSouthWestThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X + mouseOffset.X,
                                                    this.InitialRectangle.Y,
                                                    this.InitialRectangle.Width - mouseOffset.X,
                                                    this.InitialRectangle.Height + mouseOffset.Y,
                                                    this.InitialRectangle);
                break;

            case ThumbType.ElementSouthThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X,
                                                    this.InitialRectangle.Y,
                                                    this.InitialRectangle.Width,
                                                    this.InitialRectangle.Height + mouseOffset.Y,
                                                    this.InitialRectangle);
                break;

            case ThumbType.ElementSouthEastThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X,
                                                    this.InitialRectangle.Y,
                                                    this.InitialRectangle.Width + mouseOffset.X,
                                                    this.InitialRectangle.Height + mouseOffset.Y,
                                                    this.InitialRectangle);
                break;

            case ThumbType.TitleThumb:
                newLocation = window.CoerceLocation(this.InitialRectangle.X + mouseOffset.X,
                                                    this.InitialRectangle.Y + mouseOffset.Y,
                                                    this.InitialRectangle.Width,
                                                    this.InitialRectangle.Height,
                                                    this.InitialRectangle);
                break;
            }

            if (newLocation != Rect.Empty)
            {
////#if SILVERLIGHT
////                this.UpdateMousePosition(newLocation.X - window.Left, newLocation.Y - window.Top);
////#endif
                SetWindowSizeAndLocation(window, newLocation);
            }
        }