public void Visit(aShape shape)
 {
     if (shape.GetType() == typeof(ShapeTextDecorator))
     {
         ShapeTextDecorator s = (ShapeTextDecorator)shape;
         Visit(s);
     }
     else if (shape.GetType() == typeof(ShapeComposite))
     {
         ShapeComposite s = (ShapeComposite)shape;
         Visit(s);
     }
     else if (shape.GetType() == typeof(mRectangle))
     {
         mRectangle s = (mRectangle)shape;
         Visit(s);
     }
     else if (shape.GetType() == typeof(mEllipse))
     {
         mEllipse s = (mEllipse)shape;
         Visit(s);
     }
 }
        public void Execute()
        {
            textShape = new ShapeTextDecorator(shape);
            if (shape.GetType() == typeof(ShapeComposite))
            {
                ShapeComposite temp = (ShapeComposite)shape;
                textShape = new ShapeTextDecorator(temp.GetChildren()[0]);
                textShape.AddText(text, textPos);
                temp.GetChildren()[temp.GetChildren().FindIndex(ind => ind.Equals(temp.GetChildren()[0]))] = textShape;

                playground.AddShape(temp);
                playground.RemoveShape(shape);
            }
            else
            {
                textShape.AddText(text, textPos);

                playground.AddShape(textShape);
                playground.RemoveShape(shape);
            }
        }
        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;
            }
        }