Ejemplo n.º 1
0
 public void Visit(mRectangle rectangle)
 {
     rectangle.Width  = width;
     rectangle.Height = height;
     rectangle.X      = x;
     rectangle.Y      = y;
     rectangle.Load();
 }
Ejemplo n.º 2
0
        public ShapeSelectTool(mPlayground iPlayground)
        {
            playground                = iPlayground;
            selectionRect             = new mRectangle(1, 1, Color.LightBlue);
            selectionRect.BorderColor = Color.MidnightBlue;
            selectionRect.BorderSize  = 2;
            selectionRect.DrawBorder  = true;
            selectionRect.Selected    = true;
            selectionRect.Load();

            typing = false;
        }
Ejemplo n.º 3
0
        public void Update()
        {
            if (textBox != null)
            {
                textBox.Update();
            }

            /*TODO: Move to 'UI' or/and keyboard shortcut*/
            if (InputManager.IsKeyPressed(Keys.B))
            {
                foreach (mCanvas c in playground.Canvases)
                {
                    c.ForAllShapes((aShape shape) => {
                        if (shape.Selected)
                        {
                            shape.DrawBorder = !shape.DrawBorder;
                        }
                    });
                }
            }

            if (InputManager.IsKeyDown(Keys.LeftControl) && InputManager.IsKeyPressed(Keys.G))
            {
                List <aShape>  selectedShapes = getSelectedShapes();
                ShapeComposite firstGroup     = isGroupInSelection(selectedShapes);
                if (firstGroup != null)
                {
                    selectedShapes.Remove(firstGroup);
                }
                ShapeComposite group = null;
                if (selectedShapes.Count > 1)
                {
                    group = new ShapeComposite();
                    foreach (aShape s in selectedShapes)
                    {
                        group.Add(s);
                    }
                }
                if (group != null)
                {
                    deleteShapes(selectedShapes);
                    if (firstGroup != null)
                    {
                        firstGroup.Add(group);
                    }
                    else
                    {
                        playground.AddShape(group);
                    }
                }

                Reset();
            }

            if (leftClicked && !selecting && InputManager.IsKeyDown(Keys.LeftControl))
            {
                selecting = true;

                int mX = InputManager.CurrentMouseState.X;
                int mY = InputManager.CurrentMouseState.Y;

                selectionRect.X = mX;
                selectionRect.Y = mY;
            }
            else if (leftClicked && selecting && InputManager.IsKeyDown(Keys.LeftControl))
            {
                int newWidth  = Util.Clamp(InputManager.CurrentMouseState.X - selectionRect.X, 1, playground.Width);
                int newHeight = Util.Clamp(InputManager.CurrentMouseState.Y - selectionRect.Y, 1, playground.Height);

                Console.WriteLine("Width: " + newWidth);

                selectionRect.Width  = newWidth;
                selectionRect.Height = newHeight;
                selectionRect.Load();
            }
            else if (!leftClicked && selecting && InputManager.IsKeyDown(Keys.LeftControl))
            {
                selecting = false;

                foreach (mCanvas c in playground.Canvases)
                {
                    c.ForAllShapes((aShape iShape) => {
                        if (selectionRect.Intersects(iShape))
                        {
                            iShape.Selected = true;
                        }
                    });
                }

                if (selectionRect.Width > 0)
                {
                    selectionRect.Width  = 1;
                    selectionRect.Height = 1;
                    selectionRect.Load();
                }
            }
            else
            {
                foreach (mCanvas c in playground.Canvases)
                {
                    c.ForAllShapes(SelectShape);
                }
            }


            if (!typing)
            {
                //For adding text
                if (InputManager.IsKeyPressed(Keys.Up))
                {
                    typing = true;
                    AddText(TextPos.Top);
                }
                else if (InputManager.IsKeyPressed(Keys.Left))
                {
                    typing = true;
                    AddText(TextPos.Left);
                }
                else if (InputManager.IsKeyPressed(Keys.Down))
                {
                    typing = true;
                    AddText(TextPos.Bottom);
                }
                else if (InputManager.IsKeyPressed(Keys.Right))
                {
                    typing = true;
                    AddText(TextPos.Right);
                }
            }

            if (!typing && (InputManager.IsKeyPressed(Keys.Delete) || InputManager.IsKeyPressed(Keys.Back)))
            {
                deleteShapes();
            }

            if (InputManager.IsPressed(MouseInput.LeftButton))
            {
                leftClicked = true;
            }

            if (InputManager.IsReleased(Input.MouseInput.LeftButton))
            {
                leftClicked = false;
            }
        }
Ejemplo n.º 4
0
 public void Load()
 {
     textboxRect.Load();
 }
Ejemplo n.º 5
0
 public void Load()
 {
     buttonRect.Load();
 }