コード例 #1
0
        /// <summary>
        /// Throws the panel to the specified destination.
        /// </summary>
        /// <param name="destination">The destination.</param>
        protected void Throw(Point destination)
        {
            if (this.Throwable)
            {
                Size screenSize = this.GUI.SpriteRenderer.Viewport.Size;
                if (this.Left > 0 && this.Right < screenSize.Width && this.Top > 0 && this.Bottom < screenSize.Height)
                {
                    this.throwWayPoint = new WaypointController(this.Location)
                    {
                        Progression = Progression.Decreasing
                    };

                    // prevent throwing out of screen
                    if (destination.X < 0 ||
                        destination.X + this.Width > screenSize.Width ||
                        destination.Y < 0 ||
                        destination.Y + this.Height > screenSize.Height)
                    {
                        var lbc = new LiangBarskyClipping(new Rectangle(0, 0, screenSize.Width - this.Width, screenSize.Height - this.Height));
                        destination = lbc.ClipLineEndPoint(this.Location, destination);
                    }

                    this.throwWayPoint.AddWaypoint(destination, null);
                    this.throwWayPoint.Start(this.MiyagiSystem, true, c => this.Location = c);
                }
            }
        }
コード例 #2
0
ファイル: InputManager.cs プロジェクト: wubin-ericsson/mogre
        /// <summary>
        /// Handles mouse moves.
        /// </summary>
        /// <param name="oldLocation">The old mouse location.</param>
        /// <param name="newLocation">The new mouse location.</param>
        protected virtual void OnMouseMoved(Point oldLocation, Point newLocation)
        {
            if (this.CursorClipArea != null && !this.CursorClipArea.Value.Contains(newLocation))
            {
                var clip = new LiangBarskyClipping(this.CursorClipArea.Value);
                this.mouseLocation = newLocation = clip.ClipLineEndPoint(this.CursorClipArea.Value.Center, newLocation);
            }

            // MouseGestures
            if (this.pressedMouseButtons[this.MouseGesturesButton])
            {
                Point delta = newLocation - this.oldMouseGesturePositon;
                if (Math.Abs(delta.X) >= this.MouseGestureMinDistance || Math.Abs(delta.Y) >= this.MouseGestureMinDistance)
                {
                    this.AddMouseGesture(this.GetMouseGestures(this.oldMouseGesturePositon.AngleBetween(newLocation)), this.oldMouseGesturePositon);
                    this.oldMouseGesturePositon = newLocation;
                }
            }

            if (this.MouseLocationChanged != null)
            {
                this.MouseLocationChanged(this, new ChangedValueEventArgs <Point>(oldLocation, newLocation));
            }
        }