Esempio n. 1
0
        private void HandleMouseMove(MouseMessage msg)
        {
            var fact = VisibleSize / TotalSize;
            var scrollStart = (mScrollOffset / TotalSize) * Size;
            var knobRect = new RectangleF(Position.X + (Vertical ? 0 : scrollStart),
                Position.Y + (Vertical ? scrollStart : 0), Vertical ? Thickness : (Size * fact),
                Vertical ? (Size * fact) : Thickness);

            mIsKnobHovered = knobRect.Contains(msg.Position);

            if (mIsKnobDown == false)
                return;

            var knoby = msg.Position.Y - mKnobOffset.Y - Position.Y;
            if (knoby < 0)
                knoby = 0;

            scrollStart = knoby;
            scrollStart /= Size;
            scrollStart *= TotalSize;
            mScrollOffset = scrollStart;
            if (mScrollOffset + VisibleSize > TotalSize)
                mScrollOffset = TotalSize - VisibleSize;

            if (ScrollChanged != null)
                ScrollChanged(mScrollOffset);
        }
Esempio n. 2
0
        private void HandleMouseDown(MouseMessage msg)
        {
            var fact        = VisibleSize / TotalSize;
            var scrollStart = (mScrollOffset / TotalSize) * Size;
            var knobRect    = new RectangleF(Position.X + (Vertical ? 0 : scrollStart),
                                             Position.Y + (Vertical ? scrollStart : 0), Vertical ? Thickness : (Size * fact),
                                             Vertical ? (Size * fact) : Thickness);

            mIsKnobDown = knobRect.Contains(msg.Position);
            mKnobOffset = new Vector2(msg.Position.X - knobRect.X, msg.Position.Y - knobRect.Y);
        }
Esempio n. 3
0
        private void OnMouseDown(MouseMessage msg)
        {
            if (msg.IsHandled)
                return;

            var oldFocus = mIsFocused;
            mIsFocused = new RectangleF(Position.X, Position.Y, mSize.X, mSize.Y).Contains(msg.Position);
            if(oldFocus == false && mIsFocused)
            {
                mCaretVisible = true;
                mLastBlinkTime = DateTime.Now;
            }
        }
Esempio n. 4
0
        private void OnMouseDown(MouseMessage msg)
        {
            if (msg.IsHandled)
            {
                return;
            }

            var oldFocus = mIsFocused;

            mIsFocused = new RectangleF(Position.X, Position.Y, mSize.X, mSize.Y).Contains(msg.Position);
            if (oldFocus == false && mIsFocused)
            {
                mCaretVisible  = true;
                mLastBlinkTime = DateTime.Now;
            }
        }
Esempio n. 5
0
        private void HandleMouseDown(MouseMessage msg)
        {
            if (msg.Buttons == MouseButton.Left)
            {
                mIsLeftClick = mTargetRectangle.Contains(msg.Position);
                return;
            }

            if (msg.Buttons != MouseButton.Right)
            {
                return;
            }

            mIsClicked    = mTargetRectangle.Contains(msg.Position);
            mLastMousePos = msg.Position;
        }
Esempio n. 6
0
        private void HandleMouseWheel(MouseMessage msg)
        {
            if (msg.Delta > 0)
            {
                mZoomFactor *= 0.8f;
            }
            else
            {
                mZoomFactor /= 0.8f;
            }

            mZoomFactor  = Math.Min(0.5f, mZoomFactor);
            mCenterPos.X = Math.Max(mZoomFactor, Math.Min(1.0f - mZoomFactor, mCenterPos.X));
            mCenterPos.Y = Math.Max(mZoomFactor, Math.Min(1.0f - mZoomFactor, mCenterPos.Y));
            var leftPos = mCenterPos.X - mZoomFactor;
            var topPos  = mCenterPos.Y - mZoomFactor;

            mSourceRectangle = new RectangleF(leftPos * Width, topPos * Height, Width * 2 * mZoomFactor, Height * 2 * mZoomFactor);
        }
Esempio n. 7
0
        private void HandleMouseUp(MouseMessage msg)
        {
            if (msg.Buttons == MouseButton.Left)
            {
                if (mIsLeftClick && mTargetRectangle.Contains(msg.Position))
                {
                    var facx = (msg.Position.X - mTargetRectangle.X) / mTargetRectangle.Width;
                    var facy = (msg.Position.Y - mTargetRectangle.Y) / mTargetRectangle.Height;

                    var sourcex = mSourceRectangle.Left + facx * mSourceRectangle.Width;
                    var sourcey = mSourceRectangle.Top + facy * mSourceRectangle.Height;

                    sourcex /= Width;
                    sourcey /= Height;

                    sourcex *= 64.0f;
                    sourcey *= 64.0f;
                    sourcex  = Math.Max(0, Math.Min(64, sourcex));
                    sourcey  = Math.Max(0, Math.Min(64, sourcey));
                    sourcex *= Metrics.TileSize;
                    sourcey *= Metrics.TileSize;
                    sourcey  = 64.0f * Metrics.TileSize - sourcey;

                    if (LocationSelected != null)
                    {
                        LocationSelected(new Vector2(sourcex, sourcey));
                    }
                }

                mIsLeftClick = false;
                return;
            }

            if (msg.Buttons != MouseButton.Right)
            {
                return;
            }

            mIsClicked = false;
        }
Esempio n. 8
0
        private void HandleMouseMove(MouseMessage msg)
        {
            if (mIsClicked)
            {
                var diff = msg.Position - mLastMousePos;
                mCenterPos.X -= diff.X / 300.0f * mZoomFactor;
                mCenterPos.Y -= diff.Y / 300.0f * mZoomFactor;
                mCenterPos.X  = Math.Max(mZoomFactor, Math.Min(1.0f - mZoomFactor, mCenterPos.X));
                mCenterPos.Y  = Math.Max(mZoomFactor, Math.Min(1.0f - mZoomFactor, mCenterPos.Y));
                var leftPos = mCenterPos.X - mZoomFactor;
                var topPos  = mCenterPos.Y - mZoomFactor;

                mSourceRectangle = new RectangleF(leftPos * Width, topPos * Height, Width * 2 * mZoomFactor, Height * 2 * mZoomFactor);
            }

            if (mTargetRectangle.Contains(msg.Position))
            {
                var facx = (msg.Position.X - mTargetRectangle.X) / mTargetRectangle.Width;
                var facy = (msg.Position.Y - mTargetRectangle.Y) / mTargetRectangle.Height;

                var sourcex = mSourceRectangle.Left + facx * mSourceRectangle.Width;
                var sourcey = mSourceRectangle.Top + facy * mSourceRectangle.Height;

                sourcex /= Width;
                sourcey /= Height;

                sourcex *= 64.0f;
                sourcey *= 64.0f;
                sourcex  = Math.Max(0, Math.Min(63, sourcex));
                sourcey  = Math.Max(0, Math.Min(63, sourcey));

                mIndexDraw.Text = "Selected ADT: " + (int)Math.Floor(sourcex) + "/" + (int)Math.Floor(sourcey);

                CheckIndexLocation(msg.Position);
            }

            mLastMousePos = msg.Position;
        }
Esempio n. 9
0
        private void HandleMouseMove(MouseMessage msg)
        {
            var fact        = VisibleSize / TotalSize;
            var scrollStart = (mScrollOffset / TotalSize) * Size;
            var knobRect    = new RectangleF(Position.X + (Vertical ? 0 : scrollStart),
                                             Position.Y + (Vertical ? scrollStart : 0), Vertical ? Thickness : (Size * fact),
                                             Vertical ? (Size * fact) : Thickness);

            mIsKnobHovered = knobRect.Contains(msg.Position);

            if (mIsKnobDown == false)
            {
                return;
            }

            var knoby = msg.Position.Y - mKnobOffset.Y - Position.Y;

            if (knoby < 0)
            {
                knoby = 0;
            }

            scrollStart   = knoby;
            scrollStart  /= Size;
            scrollStart  *= TotalSize;
            mScrollOffset = scrollStart;
            if (mScrollOffset + VisibleSize > TotalSize)
            {
                mScrollOffset = TotalSize - VisibleSize;
            }

            if (ScrollChanged != null)
            {
                ScrollChanged(mScrollOffset);
            }
        }
Esempio n. 10
0
        private void HandleMouseDown(MouseMessage msg)
        {
            var fact = VisibleSize / TotalSize;
            var scrollStart = (mScrollOffset / TotalSize) * Size;
            var knobRect = new RectangleF(Position.X + (Vertical ? 0 : scrollStart),
                Position.Y + (Vertical ? scrollStart : 0), Vertical ? Thickness : (Size * fact),
                Vertical ? (Size * fact) : Thickness);

            mIsKnobDown = knobRect.Contains(msg.Position);
            mKnobOffset = new Vector2(msg.Position.X - knobRect.X, msg.Position.Y - knobRect.Y);
        }
Esempio n. 11
0
        private void HandleMouseWheel(MouseMessage msg)
        {
            if (msg.Delta > 0)
                mZoomFactor *= 0.8f;
            else
                mZoomFactor /= 0.8f;

            mZoomFactor = Math.Min(0.5f, mZoomFactor);
            mCenterPos.X = Math.Max(mZoomFactor, Math.Min(1.0f - mZoomFactor, mCenterPos.X));
            mCenterPos.Y = Math.Max(mZoomFactor, Math.Min(1.0f - mZoomFactor, mCenterPos.Y));
            var leftPos = mCenterPos.X - mZoomFactor;
            var topPos = mCenterPos.Y - mZoomFactor;

            mSourceRectangle = new RectangleF(leftPos * Width, topPos * Height, Width * 2 * mZoomFactor, Height * 2 * mZoomFactor);
        }
Esempio n. 12
0
        private void HandleMouseMove(MouseMessage msg)
        {
            if(mIsClicked)
            {
                var diff = msg.Position - mLastMousePos;
                mCenterPos.X -= diff.X / 300.0f * mZoomFactor;
                mCenterPos.Y -= diff.Y / 300.0f * mZoomFactor;
                mCenterPos.X = Math.Max(mZoomFactor, Math.Min(1.0f - mZoomFactor, mCenterPos.X));
                mCenterPos.Y = Math.Max(mZoomFactor, Math.Min(1.0f - mZoomFactor, mCenterPos.Y));
                var leftPos = mCenterPos.X - mZoomFactor;
                var topPos = mCenterPos.Y - mZoomFactor;

                mSourceRectangle = new RectangleF(leftPos * Width, topPos * Height, Width * 2 * mZoomFactor, Height * 2 * mZoomFactor);
            }

            if (mTargetRectangle.Contains(msg.Position))
            {
                var facx = (msg.Position.X - mTargetRectangle.X) / mTargetRectangle.Width;
                var facy = (msg.Position.Y - mTargetRectangle.Y) / mTargetRectangle.Height;

                var sourcex = mSourceRectangle.Left + facx * mSourceRectangle.Width;
                var sourcey = mSourceRectangle.Top + facy * mSourceRectangle.Height;

                sourcex /= Width;
                sourcey /= Height;

                sourcex *= 64.0f;
                sourcey *= 64.0f;
                sourcex = Math.Max(0, Math.Min(63, sourcex));
                sourcey = Math.Max(0, Math.Min(63, sourcey));

                mIndexDraw.Text = "Selected ADT: " + (int)Math.Floor(sourcex) + "/" + (int)Math.Floor(sourcey);

                CheckIndexLocation(msg.Position);
            }

            mLastMousePos = msg.Position;
        }
Esempio n. 13
0
        private void HandleMouseUp(MouseMessage msg)
        {
            if(msg.Buttons == MouseButton.Left)
            {
                if(mIsLeftClick && mTargetRectangle.Contains(msg.Position))
                {
                    var facx = (msg.Position.X - mTargetRectangle.X) / mTargetRectangle.Width;
                    var facy = (msg.Position.Y - mTargetRectangle.Y) / mTargetRectangle.Height;

                    var sourcex = mSourceRectangle.Left + facx * mSourceRectangle.Width;
                    var sourcey = mSourceRectangle.Top + facy * mSourceRectangle.Height;

                    sourcex /= Width;
                    sourcey /= Height;

                    sourcex *= 64.0f;
                    sourcey *= 64.0f;
                    sourcex = Math.Max(0, Math.Min(64, sourcex));
                    sourcey = Math.Max(0, Math.Min(64, sourcey));
                    sourcex *= Metrics.TileSize;
                    sourcey *= Metrics.TileSize;
                    sourcey = 64.0f * Metrics.TileSize - sourcey;

                    if (LocationSelected != null)
                        LocationSelected(new Vector2(sourcex, sourcey));
                }

                mIsLeftClick = false;
                return;
            }

            if (msg.Buttons != MouseButton.Right)
                return;

            mIsClicked = false;
        }
Esempio n. 14
0
        private void HandleMouseDown(MouseMessage msg)
        {
            if(msg.Buttons == MouseButton.Left)
            {
                mIsLeftClick = mTargetRectangle.Contains(msg.Position);
                return;
            }

            if (msg.Buttons != MouseButton.Right)
                return;

            mIsClicked = mTargetRectangle.Contains(msg.Position);
            mLastMousePos = msg.Position;
        }