Ejemplo n.º 1
0
        private void PushActivity(Cursor cursor)
        {
            if (cursor.PrimaryPush)
            {
                cursorScreenXPushed = cursor.X;
                cursorScreenYPushed = cursor.Y;

                rectangleCoordinatesOnPush = mCoordinates;

                float worldX = cursor.GetWorldX(managers);
                float worldY = cursor.GetWorldY(managers);

                var sideOver = GetSideOver(
                    worldX,
                    worldY);


                mSideGrabbed = sideOver;

                if (mSideGrabbed != ResizeSide.None && this.Pushed != null)
                {
                    Pushed(this, null);
                }
            }
        }
Ejemplo n.º 2
0
        public ResizeSide GetSideOver(float x, float y)
        {
            ResizeSide toReturn = ResizeSide.None;

            if (mShowHandles)
            {
                for (int i = 0; i < this.mHandles.Count; i++)
                {
                    if (mHandles[i].HasCursorOver(x, y))
                    {
                        toReturn = (ResizeSide)i;
                    }
                }
            }

            if (mShowHandles || AllowMoveWithoutHandles)
            {
                if (this.mLineRectangle.HasCursorOver(x, y))
                {
                    toReturn = ResizeSide.Middle;
                }
            }

            return(toReturn);
        }
Ejemplo n.º 3
0
        private void PushActivity(ResizeSide sideOver, Cursor cursor)
        {
            if (cursor.PrimaryPush)
            {
                mSideGrabbed = sideOver;

                if (mSideGrabbed != ResizeSide.None && this.Pushed != null)
                {
                    Pushed(this, null);
                }
            }
        }
Ejemplo n.º 4
0
        private void HandlesActivity()
        {
            Cursor cursor = InputLibrary.Cursor.Self;

            if (cursor.PrimaryPush)
            {
                mSideGrabbed = SelectionManager.Self.SideOver;
            }
            if (cursor.PrimaryDown && mHasMovedEnoughSincePush)
            {
                SideGrabbingActivity();
            }
            if (cursor.PrimaryClick)
            {
                mSideGrabbed = ResizeSide.None;
            }
        }
Ejemplo n.º 5
0
        private void HandlesActivity()
        {
            var cursor = InputLibrary.Cursor.Self;

            if (cursor.PrimaryPush)
            {
                SideGrabbed = SideOver;
            }
            if (cursor.PrimaryDown && grabbedInitialState.HasMovedEnough)
            {
                SideGrabbingActivity();
            }
            if (cursor.PrimaryClick)
            {
                SideGrabbed = ResizeSide.None;
            }
        }
Ejemplo n.º 6
0
        private void RefreshSideOver()
        {
            var worldX = Cursor.GetWorldX();
            var worldY = Cursor.GetWorldY();

            if (mResizeHandles.Visible == false)
            {
                SideOver = ResizeSide.None;
            }
            else
            {
                // If the user is already dragging then there's
                // no need to re-check which side the user is over
                if (Cursor.PrimaryPush || (!Cursor.PrimaryDown && !Cursor.PrimaryClick))
                {
                    SideOver = mResizeHandles.GetSideOver(worldX, worldY);
                }
            }
        }
Ejemplo n.º 7
0
        private void PushActivity(Cursor cursor)
        {
            if (cursor.PrimaryPush)
            {
                float worldX = cursor.GetWorldX(managers);
                float worldY = cursor.GetWorldY(managers);

                var sideOver = GetSideOver(
                    worldX,
                    worldY);


                mSideGrabbed = sideOver;

                if (mSideGrabbed != ResizeSide.None && this.Pushed != null)
                {
                    Pushed(this, null);
                }
            }
        }
Ejemplo n.º 8
0
        private void ClickActivity(Cursor cursor)
        {
            if (cursor.PrimaryClick)
            {
                mSideGrabbed = ResizeSide.None;

                this.Left   = RoundIfNecessary(this.Left);
                this.Top    = RoundIfNecessary(this.Top);
                this.Width  = RoundIfNecessary(this.Width);
                this.Height = RoundIfNecessary(this.Height);

                if (shouldRaiseEndRegionChanged)
                {
                    EndRegionChanged?.Invoke(this, null);
                    shouldRaiseEndRegionChanged = false;
                }

                UpdateHandles();
            }
        }
Ejemplo n.º 9
0
        private void PushActivity(Cursor cursor)
        {
            if (cursor.PrimaryPush)
            {
                float worldX = cursor.GetWorldX(managers);
                float worldY = cursor.GetWorldY(managers);

                var sideOver = GetSideOver(
                    worldX,
                    worldY);


                mSideGrabbed = sideOver;

                if (mSideGrabbed != ResizeSide.None)
                {
                    Pushed?.Invoke(this, null);
                    StartRegionChanged?.Invoke(this, null);
                }
            }
        }
Ejemplo n.º 10
0
 public RowResizeEventArgs(MouseEventArgs e, ResizeSide rs) : base(e.Button, e.Clicks, e.X, e.Y, e.Delta)
 {
     this.rs = rs;
 }
Ejemplo n.º 11
0
        private static void SetWindowsCursor(System.Windows.Forms.Control container, 
            ResizeSide sideGrabbed, ResizeSide sideOver, bool resetToArrow)
        {
            System.Windows.Forms.Cursor cursorToSet = Cursors.Arrow;

            var sideToUse = sideOver;
            if (sideGrabbed != ResizeSide.None)
            {
                sideToUse = sideGrabbed;
            }

            if (sideToUse != ResizeSide.None)
            {
                switch (sideToUse)
                {
                    case ResizeSide.TopLeft:
                    case ResizeSide.BottomRight:
                        cursorToSet = Cursors.SizeNWSE;
                        break;
                    case ResizeSide.TopRight:
                    case ResizeSide.BottomLeft:
                        cursorToSet = Cursors.SizeNESW;
                        break;
                    case ResizeSide.Top:
                    case ResizeSide.Bottom:
                        cursorToSet = Cursors.SizeNS;
                        break;
                    case ResizeSide.Left:
                    case ResizeSide.Right:
                        cursorToSet = Cursors.SizeWE;
                        break;
                    case ResizeSide.Middle:
                        cursorToSet = Cursors.SizeAll;
                        break;
                    case ResizeSide.None:

                        break;
                }

            }
            if (WinCursor.Current != cursorToSet)
            {
                if (cursorToSet != Cursors.Arrow || resetToArrow)
                {
                    WinCursor.Current = cursorToSet;
                    container.Cursor = cursorToSet;
                }
            }
        }
Ejemplo n.º 12
0
        private void PushActivity(ResizeSide sideOver, Cursor cursor)
        {
            if (cursor.PrimaryPush)
            {
                mSideGrabbed = sideOver;

                if (mSideGrabbed != ResizeSide.None && this.Pushed != null)
                {
                    Pushed(this, null);
                }
            }
        }
Ejemplo n.º 13
0
        private void HandlesActivity()
        {
            Cursor cursor = InputLibrary.Cursor.Self;

            if (cursor.PrimaryPush)
            {
                mSideGrabbed = SelectionManager.Self.SideOver;
            }
            if (cursor.PrimaryDown && mHasMovedEnoughSincePush)
            {
                SideGrabbingActivity();
            }
            if (cursor.PrimaryClick)
            {
                mSideGrabbed = ResizeSide.None;
            }
        }
Ejemplo n.º 14
0
        private void SetWindowsCursor(System.Windows.Forms.Control container,
                                      ResizeSide sideGrabbed, ResizeSide sideOver, bool resetToArrow, bool flipHorizontal, bool flipVertical)
        {
            System.Windows.Forms.Cursor cursorToSet = Cursors.Arrow;

            var sideToUse = sideOver;

            if (sideGrabbed != ResizeSide.None)
            {
                sideToUse = sideGrabbed;
            }

            bool flipCorners = (flipHorizontal && !flipVertical) ||
                               (!flipHorizontal && flipVertical);



            if (sideToUse != ResizeSide.None)
            {
                switch (sideToUse)
                {
                case ResizeSide.TopLeft:
                case ResizeSide.BottomRight:

                    if (flipCorners)
                    {
                        cursorToSet = Cursors.SizeNESW;
                    }
                    else
                    {
                        cursorToSet = Cursors.SizeNWSE;
                    }
                    break;

                case ResizeSide.TopRight:
                case ResizeSide.BottomLeft:
                    if (flipCorners)
                    {
                        cursorToSet = Cursors.SizeNWSE;
                    }
                    else
                    {
                        cursorToSet = Cursors.SizeNESW;
                    }
                    break;

                case ResizeSide.Top:
                case ResizeSide.Bottom:
                    cursorToSet = Cursors.SizeNS;
                    break;

                case ResizeSide.Left:
                case ResizeSide.Right:
                    cursorToSet = Cursors.SizeWE;
                    break;

                case ResizeSide.Middle:
                    if (ShowMoveCursorWhenOver)
                    {
                        cursorToSet = Cursors.SizeAll;
                    }
                    break;

                case ResizeSide.None:

                    break;
                }
            }
            if (WinCursor.Current != cursorToSet)
            {
                if (cursorToSet != Cursors.Arrow || resetToArrow)
                {
                    WinCursor.Current = cursorToSet;
                    container.Cursor  = cursorToSet;
                }
            }
        }
        void StartJoystickResize( TouchInputLayout.TrackerPrefabBasePrefabPair tracker, Vector2 currentPos, ResizeSide side)
        {
            if (!_isResizing)
            {
                _modifyStartPos = currentPos;

                _rectStartOfDrag = tracker._tracker.activeRegion;
                _resizeSide = side;
                trackerBeingModified = tracker;
            }

            _isResizing = true;
        }
Ejemplo n.º 16
0
        private void ClickActivity(Cursor cursor)

        {
            if (cursor.PrimaryClick)
            {
                mSideGrabbed = ResizeSide.None;

                this.Left = RoundIfNecessary(this.Left);
                this.Top = RoundIfNecessary(this.Top);
                this.Width = RoundIfNecessary(this.Width);
                this.Height= RoundIfNecessary(this.Height);

                if(shouldRaiseEndRegionChanged)
                {
                    EndRegionChanged?.Invoke(this, null);
                    shouldRaiseEndRegionChanged = false;
                }

                UpdateHandles();
            }
        }
Ejemplo n.º 17
0
        public void Update(Vector2 cursorInMapPosition)
        {
            box.Color               = Color.Ivory;
            sizeLabel.IsVisible     = false;
            positionLabel.IsVisible = false;

            #region Move

            if (!editor.IsResizingSection)
            {
                if (!canResize && !editor.IsMovingSection && bounds.Contains(cursorInMapPosition))
                {
                    box.Color               = Color.Lime;
                    editor.Cursor.Type      = CursorType.Move;
                    sizeLabel.IsVisible     = false;
                    positionLabel.IsVisible = true;

                    if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                    {
                        if (!isMoving)
                        {
                            previousSectionPosition  = bounds.Location;
                            mouseLeftButtonIsPressed = true;
                        }
                        isMoving = true;
                        editor.IsMovingSection = true;
                    }
                }

                if (!canResize && isMoving)
                {
                    box.Color = Color.Lime;
                    positionLabel.IsVisible = true;
                    sizeLabel.IsVisible     = false;
                    editor.Cursor.Type      = CursorType.Move;

                    // Update bounds of the map section representation in this editor
                    bounds.Location = new Point(
                        ((int)(cursorInMapPosition.X - bounds.Width / 2) / SCALE) * SCALE,
                        ((int)(cursorInMapPosition.Y - bounds.Height / 2) / SCALE) * SCALE
                        );

                    // The mouse button is released:
                    if (mouseLeftButtonIsPressed && Mouse.GetState().LeftButton == ButtonState.Released)
                    {
                        mouseLeftButtonIsPressed = false;
                        isMoving = false;
                        editor.IsMovingSection = false;

                        // Update all positions in the real map section
                        if (RealSection != null)
                        {
                            RealSection.UpdateAllPositions(bounds.Location - previousSectionPosition, bounds.Size);
                        }

                        preview.UpdatePreviewTilesFromRealSection();
                    }
                }
            }

            #endregion

            #region Resize

            if (!editor.IsMovingSection)
            {
                if (bounds.Contains(cursorInMapPosition))
                {
                    var leftSide   = new Rectangle(bounds.X - 32, bounds.Y, 64, bounds.Height);
                    var rightSide  = new Rectangle(bounds.X + bounds.Width - 32, bounds.Y, 64, bounds.Height);
                    var topSide    = new Rectangle(bounds.X, bounds.Y - 32, bounds.Width, 64);
                    var bottomSide = new Rectangle(bounds.X, bounds.Y + bounds.Height - 32, bounds.Width, 64);

                    if (!editor.IsResizingSection)
                    {
                        // The cursor is inside the right handle
                        if (leftSide.Contains(cursorInMapPosition))
                        {
                            canResize = true;

                            box.Color               = Color.Yellow;
                            editor.Cursor.Type      = CursorType.ResizeHorizontal;
                            sizeLabel.IsVisible     = true;
                            positionLabel.IsVisible = false;

                            // The mouse button is pressed inside the handle
                            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                            {
                                mouseLeftButtonIsPressed = true;
                                resizeSide = ResizeSide.Left;
                                editor.IsResizingSection = true;
                            }
                        }
                        else if (rightSide.Contains(cursorInMapPosition))
                        {
                            canResize = true;

                            box.Color               = Color.Yellow;
                            editor.Cursor.Type      = CursorType.ResizeHorizontal;
                            sizeLabel.IsVisible     = true;
                            positionLabel.IsVisible = false;

                            // The mouse button is pressed inside the handle
                            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                            {
                                mouseLeftButtonIsPressed = true;
                                resizeSide = ResizeSide.Right;
                                editor.IsResizingSection = true;
                            }
                        }
                        else if (topSide.Contains(cursorInMapPosition))
                        {
                            canResize = true;

                            box.Color               = Color.Yellow;
                            editor.Cursor.Type      = CursorType.ResizeVertical;
                            sizeLabel.IsVisible     = true;
                            positionLabel.IsVisible = false;

                            // The mouse button is pressed inside the handle
                            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                            {
                                mouseLeftButtonIsPressed = true;
                                resizeSide = ResizeSide.Top;
                                editor.IsResizingSection = true;
                            }
                        }
                        else if (bottomSide.Contains(cursorInMapPosition))
                        {
                            canResize = true;

                            box.Color               = Color.Yellow;
                            editor.Cursor.Type      = CursorType.ResizeVertical;
                            sizeLabel.IsVisible     = true;
                            positionLabel.IsVisible = false;

                            // The mouse button is pressed inside the handle
                            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                            {
                                mouseLeftButtonIsPressed = true;
                                resizeSide = ResizeSide.Bottom;
                                editor.IsResizingSection = true;
                            }
                        }
                        else
                        {
                            canResize = false;
                        }
                    }
                }

                if (resizeSide != ResizeSide.None)
                {
                    box.Color               = Color.Yellow;
                    sizeLabel.IsVisible     = true;
                    positionLabel.IsVisible = false;

                    if (resizeSide == ResizeSide.Left)
                    {
                        editor.Cursor.Type = CursorType.ResizeHorizontal;

                        int cursorPosition = ((int)cursorInMapPosition.X / SCALE) * SCALE;
                        int distance       = bounds.X - cursorPosition;
                        int width          = bounds.Width + distance;

                        if (width >= editor.Map.Game.InternalSize.Width)
                        {
                            bounds.X = cursorPosition;
                        }
                        if (width < editor.Map.Game.InternalSize.Width)
                        {
                            width = (int)editor.Map.Game.InternalSize.Width;
                        }

                        bounds.Width = width;
                    }
                    else if (resizeSide == ResizeSide.Right)
                    {
                        editor.Cursor.Type = CursorType.ResizeHorizontal;
                        int width = (((int)cursorInMapPosition.X / SCALE) * SCALE) - bounds.X;
                        if (width < editor.Map.Game.InternalSize.Width)
                        {
                            width = (int)editor.Map.Game.InternalSize.Width;
                        }
                        bounds.Width = width;
                    }
                    if (resizeSide == ResizeSide.Top)
                    {
                        editor.Cursor.Type = CursorType.ResizeVertical;

                        int cursorPosition = ((int)cursorInMapPosition.Y / SCALE) * SCALE;
                        int distance       = bounds.Y - cursorPosition;
                        int height         = bounds.Height + distance;

                        if (height >= editor.Map.Game.InternalSize.Height)
                        {
                            bounds.Y = cursorPosition;
                        }
                        if (height < editor.Map.Game.InternalSize.Height)
                        {
                            height = (int)editor.Map.Game.InternalSize.Height;
                        }

                        bounds.Height = height;
                    }
                    else if (resizeSide == ResizeSide.Bottom)
                    {
                        editor.Cursor.Type = CursorType.ResizeVertical;
                        int height = (((int)cursorInMapPosition.Y / SCALE) * SCALE) - bounds.Y;
                        if (height < editor.Map.Game.InternalSize.Height)
                        {
                            height = (int)editor.Map.Game.InternalSize.Height;
                        }
                        bounds.Height = height;
                    }

                    // The mouse button is released:
                    if (mouseLeftButtonIsPressed && Mouse.GetState().LeftButton == ButtonState.Released)
                    {
                        mouseLeftButtonIsPressed = false;
                        resizeSide = ResizeSide.None;
                        editor.IsResizingSection = false;

                        // Update all positions in the real map section
                        if (RealSection != null)
                        {
                            RealSection.UpdateAllPositions(bounds.Location - previousSectionPosition, bounds.Size);
                        }

                        preview.UpdatePreviewTilesFromRealSection();
                    }
                }
            }

            #endregion

            #region Load section

            if (bounds.Contains(cursorInMapPosition))
            {
                if (!mouseRightButtonIsPressed && Mouse.GetState().RightButton == ButtonState.Pressed)
                {
                    mouseRightButtonIsPressed = true;
                }
                if (mouseRightButtonIsPressed && Mouse.GetState().RightButton == ButtonState.Released)
                {
                    mouseRightButtonIsPressed = false;
                    editor.LoadSection(this);
                }
            }

            #endregion

            #region Labels

            positionLabel.Position = box.Bounds.Location.ToVector2() - new Vector2(0, 8);
            positionLabel.Text     = bounds.Location.X + ";" + bounds.Location.Y;

            sizeLabel.Position = box.Bounds.Location.ToVector2() - new Vector2(0, 8);
            sizeLabel.Text     = bounds.Size.X + "x" + bounds.Size.Y;

            #endregion

            box.Bounds       = ScreenBounds;
            preview.Position = ScreenBounds.Location;
            box.Update();
        }
Ejemplo n.º 18
0
        private void ClickActivity(Cursor cursor)

        {
            if (cursor.PrimaryClick)
            {
                mSideGrabbed = ResizeSide.None;

                this.Left = RoundIfNecessary(this.Left);
                this.Top = RoundIfNecessary(this.Top);
                this.Width = RoundIfNecessary(this.Width);
                this.Height= RoundIfNecessary(this.Height);


                UpdateHandles();
            }
        }
Ejemplo n.º 19
0
 public CellResizeEventArgs(MouseEventArgs e, ResizeSide rs)
     : base(e.Button, e.Clicks, e.X, e.Y, e.Delta)
 {
     this.rs = rs;
 }