void SelectShapes() { int mX = InputManager.CurrentMouseState.X; int mY = InputManager.CurrentMouseState.Y; if (!leftClicked && InputManager.IsPressed(MouseInput.LeftButton)) { foreach (mCanvas c in playground.Canvases) { c.ForAllShapes((aShape shape) => { if (shape.Hovered) { transforming = true; if (transformingShape != null) { transformingShape.Transforming = false; } transformingShape = shape; transformingShape.Transforming = true; //Draw new size if (shape.ShapeName == "ellipse") { drawingShape = new mEllipse(transformingShape.Width, transformingShape.Height, transformingShape.Color); } else { drawingShape = new mRectangle(transformingShape.Width, transformingShape.Height, transformingShape.Color); } drawingShape.X = transformingShape.X; drawingShape.Y = transformingShape.Y; drawingShape.LoadWhileDrawing(); } }); } } //Quick fix for resizing shapes ontop or under shapes if (leftClicked && transforming) { bool overTransformingShape = transformingShape.Contains(mX, mY); if (!overTransformingShape) { transforming = false; } } }
public override void LoadWhileDrawing() { decoratedShape.LoadWhileDrawing(); }
public void Update() { if (InputManager.IsKeyPressed(Keys.Q)) { if (curShape == eShape.Rect) { curShape = eShape.Ellps; } else { curShape = eShape.Rect; } } if (!leftClicked && InputManager.IsPressed(MouseInput.LeftButton)) { if (curShape == eShape.Rect) { currentShape = new mRectangle(1, 1, Color.Red); } if (curShape == eShape.Ellps) { currentShape = new mEllipse(1, 1, Color.Red); } xPos1 = InputManager.CurrentMouseState.X; yPos1 = InputManager.CurrentMouseState.Y; currentShape.X = xPos1; currentShape.Y = yPos1; currentShape.LoadWhileDrawing(); drawing = true; Console.WriteLine("Start drawing at: [" + xPos1 + " | " + yPos1 + "]"); } else if (leftClicked && InputManager.IsReleased(MouseInput.LeftButton)) { currentShape.Width = Util.Clamp(rWidth, 1, playground.Width); currentShape.Height = Util.Clamp(rHeight, 1, playground.Height); currentShape.Load(); playground.ExecuteCommand(new DrawCommand(currentShape, playground)); drawing = false; Console.WriteLine("Added: " + currentShape.ToString()); } else if (leftClicked) { xPos2 = InputManager.CurrentMouseState.X; yPos2 = InputManager.CurrentMouseState.Y; rWidth = xPos2 - xPos1; rHeight = yPos2 - yPos1; currentShape.Width = Util.Clamp(rWidth, 1, playground.Width); currentShape.Height = Util.Clamp(rHeight, 1, playground.Height); currentShape.LoadWhileDrawing(); } if (InputManager.IsPressed(MouseInput.LeftButton)) { leftClicked = true; } if (InputManager.IsReleased(Input.MouseInput.LeftButton)) { leftClicked = false; } }