private void DragActivity(Cursor cursor)
        {
            if (cursor.PrimaryDown &&
                (cursor.XChange != 0 || cursor.YChange != 0) &&
                mSideGrabbed != ResizeSide.None)
            {
                RecordOldValues();

                float widthMultiplier  = 0;
                float heightMultiplier = 0;
                float xMultiplier      = 0;
                float yMultiplier      = 0;

                GetMultipliersFromSideGrabbed(ref widthMultiplier, ref heightMultiplier, ref xMultiplier, ref yMultiplier);

                xMultiplier      /= managers.Renderer.Camera.Zoom;
                yMultiplier      /= managers.Renderer.Camera.Zoom;
                widthMultiplier  /= managers.Renderer.Camera.Zoom;
                heightMultiplier /= managers.Renderer.Camera.Zoom;

                this.Left   = mCoordinates.X + xMultiplier * cursor.XChange;
                this.Top    = mCoordinates.Y + yMultiplier * cursor.YChange;
                this.Width  = mCoordinates.Width + widthMultiplier * cursor.XChange;
                this.Height = mCoordinates.Height + heightMultiplier * cursor.YChange;

                RegionChanged?.Invoke(this, null);
                shouldRaiseEndRegionChanged = true;
            }
        }
Example #2
0
        private void KeyboardActivity(Keyboard keyBoard)
        {
            if (this.Visible)
            {
                bool changed = false;

                // don't do this if CTRL is held - that's reserved for camera movement
                bool isCtrlHeld =
                    keyBoard.KeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl) ||
                    keyBoard.KeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl);

                if (!isCtrlHeld)
                {
                    if (keyBoard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Left)
                        ||
                        keyBoard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Right)
                        ||
                        keyBoard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Up)
                        ||
                        keyBoard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Down))
                    {
                        // record before any changes are made
                        RecordOldValues();
                        StartRegionChanged?.Invoke(this, null);
                    }


                    if (keyBoard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Left))
                    {
                        this.Left--;
                        // Width should take care of this
                        //this.Right--;
                        changed = true;
                    }
                    if (keyBoard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Right))
                    {
                        this.Left++;
                        // Width should take care of this
                        //this.Right--;
                        changed = true;
                    }
                    if (keyBoard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Up))
                    {
                        this.Top--;
                        changed = true;
                    }
                    if (keyBoard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.Down))
                    {
                        this.Top++;
                        changed = true;
                    }

                    if (changed)
                    {
                        RegionChanged?.Invoke(this, null);
                        EndRegionChanged?.Invoke(this, null);
                    }
                }
            }
        }
        private void DragActivity(Cursor cursor)
        {
            var currentCursorScreenX = cursor.X;
            var currentCursorScreenY = cursor.Y;

            if (cursor.PrimaryDown &&
                (cursor.XChange != 0 || cursor.YChange != 0) &&
                mSideGrabbed != ResizeSide.None)
            {
                var changeSincePushX = currentCursorScreenX - cursorScreenXPushed;
                var changeSincePushY = currentCursorScreenY - cursorScreenYPushed;

                RecordOldValues();

                GetMultipliersFromSideGrabbed(out float widthMultiplier,
                                              out float heightMultiplier,
                                              out float xMultiplier,
                                              out float yMultiplier);

                xMultiplier      /= managers.Renderer.Camera.Zoom;
                yMultiplier      /= managers.Renderer.Camera.Zoom;
                widthMultiplier  /= managers.Renderer.Camera.Zoom;
                heightMultiplier /= managers.Renderer.Camera.Zoom;


                this.Left   = rectangleCoordinatesOnPush.X + xMultiplier * changeSincePushX;
                this.Top    = rectangleCoordinatesOnPush.Y + yMultiplier * changeSincePushY;
                this.Width  = rectangleCoordinatesOnPush.Width + widthMultiplier * changeSincePushX;
                this.Height = rectangleCoordinatesOnPush.Height + heightMultiplier * changeSincePushY;

                if (SnappingGridSize != null)
                {
                    //MathFunctions.RoundFloat(value, SnappingGridSize.Value);
                    this.Left   = MathFunctions.RoundFloat(this.Left, SnappingGridSize.Value);
                    this.Top    = MathFunctions.RoundFloat(this.Top, SnappingGridSize.Value);
                    this.Width  = MathFunctions.RoundFloat(this.Width, SnappingGridSize.Value);
                    this.Height = MathFunctions.RoundFloat(this.Height, SnappingGridSize.Value);
                }

                RegionChanged?.Invoke(this, null);
                shouldRaiseEndRegionChanged = true;
            }
        }
 private void HandleRegionChanged(object sender, EventArgs e)
 {
     RegionChanged?.Invoke();
 }
Example #5
0
 void RegionChangedInternal(object sender, EventArgs e)
 {
     RegionChanged?.Invoke(this, null);
 }
 private void OnRegionChanged(EventArgs args) => RegionChanged?.Invoke(this, args);
Example #7
0
 protected virtual void OnRegionChanged(MapRegionChangedEventArgs e)
 {
     RegionChanged?.Invoke(this, e);
 }