Beispiel #1
0
        private void StopDrag(Vector2 point)
        {
            WindowController.Instance.OnTouch -= StopDragTouch;

            if (m_dragging)
            {
                m_dragging = false;

                Vector2 local = this.Transform.GetClientPoint(point);

                Vector2 move = local - m_dragShift;

                float multiplier = s_dragMultiplier;

                if (m_dragVScroller)
                {
                    move       = new Vector2(move.X, -move.Y);
                    multiplier = m_contentView.Size.Y / Size.Y;
                }
                else
                if (m_dragHScroller)
                {
                    move       = new Vector2(-move.X, move.Y);
                    multiplier = m_contentView.Size.X / Size.X;
                }

                float targetX = m_contentView.Position.X + move.X * multiplier;// * 2;
                if (targetX < -m_contentView.Size.X + Size.X)
                {
                    targetX = -m_contentView.Size.X + Size.X;
                }
                if (targetX > 0)
                {
                    targetX = 0;
                }

                float targetY = m_contentView.Position.Y + move.Y * multiplier;// * 2;
                if (targetY < -m_contentView.Size.Y + Size.Y)
                {
                    targetY = -m_contentView.Size.Y + Size.Y;
                }
                if (targetY > 0)
                {
                    targetY = 0;
                }

                Vector2 target = new Vector2(targetX, targetY);
                if ((target - m_contentView.Position).LengthSquared() > 0)
                {
                    m_contentView.Move(target, 120, null);
                }
            }
        }
Beispiel #2
0
        private void StopDrag(Vector2 point)
        {
            WindowController.Instance.OnTouch -= StopDragTouch;

            if (m_dragging)
            {
                m_dragging = false;

                Vector2 local = this.Transform.GetClientPoint(point);

                Vector2 move = local - m_dragShift;

                float multiplier = s_dragMultiplier;

                if (m_dragVScroller)
                {
                    move       = new Vector2(move.X, -move.Y);
                    multiplier = m_contentView.Size.Y / (m_verticalScrollBar.Size.Y - m_verticalScrollBarIndicator.Size.Y);
                }
                else
                if (m_dragHScroller)
                {
                    move       = new Vector2(-move.X, move.Y);
                    multiplier = m_contentView.Size.X / (m_horizontalScrollBar.Size.X - m_horizontalScrollBarIndicator.Size.X);
                }

                float targetX = m_contentView.Position.X + move.X * multiplier;
                if (targetX < -m_contentView.Size.X + Size.X)
                {
                    targetX = -m_contentView.Size.X + Size.X;
                }
                if (targetX > 0)
                {
                    targetX = 0;
                }

                float targetY = m_contentView.Position.Y + move.Y * multiplier;
                if (targetY < -m_contentView.Size.Y + Size.Y)
                {
                    targetY = -m_contentView.Size.Y + Size.Y;
                }
                if (targetY > 0)
                {
                    targetY = 0;
                }

                Vector2 target = new Vector2(targetX, targetY);
                if (Vector2.DistanceSquared(target, m_contentView.Position) > float.Epsilon)
                {
                    m_contentView.Move(target, 120, null);
                }
            }
        }