public void Visit(aShape shape) { shape.Width = width; shape.Height = height; shape.X = x; shape.Y = y; shape.Load(); }
public override void Load() { decoratedShape.Load(); }
public void Update() { int mX = InputManager.CurrentMouseState.X; int mY = InputManager.CurrentMouseState.Y; //Toggles there Hover var when mouse if over SelectShapes(); if (leftClicked && !moving) { movingShape = getHovered(); if (movingShape != null) { moving = true; //Temp shape for quick acces aShape s = movingShape; if (s.GetType() == typeof(ShapeComposite)) { group = (ShapeComposite)s; movingShape = group; } //Setting up a temp shape to draw while moving if (s.ShapeName == "rectangle") { drawingShape = new mRectangle(s.Width, s.Height, s.Color); } else if (s.ShapeName == "ellipse") { drawingShape = new mEllipse(s.Width, s.Height, s.Color); } else if (s.ShapeName == "group") { ShapeComposite drawingGroup = new ShapeComposite(); drawingGroup.Add(group.GetChildren()); drawingGroup.Visible = true; drawingShape = drawingGroup; drawingShape.Visible = true; } drawingShape.X = s.X; drawingShape.Y = s.Y; drawingShape.Load(); deltaX = mX - s.X; deltaY = mY - s.Y; movingShape.Visible = false; } } if (leftClicked && moving) { drawingShape.X = mX - deltaX; drawingShape.Y = mY - deltaY; } else if (!leftClicked && moving) { moving = false; playground.ExecuteCommand(new MoveCommand(group != null ? group : movingShape, drawingShape.X, drawingShape.Y)); if (group != null) { group = null; } movingShape.Visible = true; } if (InputManager.IsPressed(MouseInput.LeftButton)) { leftClicked = true; } if (InputManager.IsReleased(Input.MouseInput.LeftButton)) { leftClicked = false; } }
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; } }