Пример #1
0
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            bool hasMoved = mouseDownLocation.X != e.X || mouseDownLocation.Y != e.Y;

            if (hasSelected)
            {
                if (hasSecondSelected)
                {
                    ShapeComposite newGroup = new ShapeComposite("group");
                    newGroup.AddChild(SelectedShape);
                    newGroup.AddChild(SecondSelectedShape);

                    shapeList.Remove(SelectedShape);
                    shapeList.Remove(SecondSelectedShape);

                    SecondSelectedShape.selected = false;
                    SecondSelectedShape          = null;

                    Command groupShape = new AddShapeCommand(shapeList, newGroup);
                    history.Add(groupShape);

                    Command selectShape = new SelectShapeCommand(newGroup, this);
                    history.Add(selectShape);
                }

                if (hasMoved)
                {
                    Point   velocity  = new Point(e.Location.X - mouseDownLocation.X, e.Location.Y - mouseDownLocation.Y);
                    Command moveShape = new MoveShapeCommand(SelectedShape, velocity, shapeStartPosition);
                    history.Add(moveShape);
                }

                Invalidate();
            }
        }
Пример #2
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            mouseDownLocation = mouseStartLocation = e.Location;
            hasSelected       = false;

            // Op geselecteerde shape gedrukt dus er hoeft niks te gebeuren
            if (SelectedShape != null && SelectedShape.dimension.Contains(e.Location))
            {
                shapeStartPosition = SelectedShape.dimension.Location;
                hasSelected        = true;
                return;
            }

            // check overige shape of er 1 geselecteerd
            foreach (Shape s in shapeList)
            {
                if (s.dimension.Contains(e.Location))
                {
                    Command selectShape = new SelectShapeCommand(s, this);
                    history.Add(selectShape);

                    shapeStartPosition = s.dimension.Location;
                    hasSelected        = true;

                    ResizeShapeButton.Enabled = true;
                    Invalidate();
                    return;
                }
            }

            // in de void gedrukt
            if (SelectedShape != null)
            {
                Command deselectShape = new SelectShapeCommand(null, this);
                history.Add(deselectShape);

                ResizeShapeButton.Enabled = false;
                Invalidate();
            }
        }
Пример #3
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            mouseDownLocation = mouseStartLocation = e.Location;
            hasSecondSelected = false;

            if (hasSelected && ModifierKeys.HasFlag(Keys.Control))
            {
                foreach (Shape s in shapeList)
                {
                    if (s.dimension.Contains(e.Location))
                    {
                        Shape temp = this.SelectedShape;

                        Command selectShape = new SelectShapeCommand(s, this);
                        history.Add(selectShape);

                        this.SelectedShape = temp;

                        SecondSelectedShape = s;

                        shapeStartPosition = s.dimension.Location;
                        hasSecondSelected  = true;

                        ResizeShapeButton.Enabled = true;
                        Invalidate();
                        return;
                    }
                }
                return;
            }
            else
            {
                hasSelected = false;
                // Selected shape was selected, nothing has to happen.
                if (SelectedShape != null && SelectedShape.dimension.Contains(e.Location))
                {
                    shapeStartPosition = SelectedShape.dimension.Location;
                    hasSelected        = true;
                    return;
                }
            }

            // Check shapes if one was selected.
            foreach (Shape s in shapeList)
            {
                if (s.dimension.Contains(e.Location))
                {
                    Command selectShape = new SelectShapeCommand(s, this);
                    history.Add(selectShape);

                    shapeStartPosition = s.dimension.Location;
                    hasSelected        = true;

                    ResizeShapeButton.Enabled = true;
                    Invalidate();
                    return;
                }
            }

            // Pressed within the void.
            if (SelectedShape != null)
            {
                Command deselectShape = new SelectShapeCommand(null, this);
                history.Add(deselectShape);

                ResizeShapeButton.Enabled = false;
                Invalidate();
            }
        }
Пример #4
0
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            mouseDownLocation = mouseStartLocation = e.Location;
            hasSecondSelected = false;

            // foreach shape check if mouse hits shape
            //  - if(!ctrl pressed) selectedShapes.Clear()
            //  - selectedShapes.add(shape)
            // else if no shape selected
            // - selectedShapes.Clear()

            if (hasSelected && ModifierKeys.HasFlag(Keys.Control))
            {
                foreach (Shape s in shapeList)
                {
                    if (s.dimension.Contains(e.Location))
                    {
                        Shape temp = this.SelectedShape;

                        Command selectShape = new SelectShapeCommand(s, this);
                        history.Add(selectShape);

                        this.SelectedShape = temp;

                        SecondSelectedShape = s;

                        shapeStartPosition = s.dimension.Location;
                        hasSecondSelected  = true;

                        ResizeShapeButton.Enabled = true;
                        Invalidate();
                        return;
                    }
                }
                return;
            }
            else
            {
                hasSelected = false;
                // Op geselecteerde shape gedrukt dus er hoeft niks te gebeuren
                if (SelectedShape != null && SelectedShape.dimension.Contains(e.Location))
                {
                    shapeStartPosition = SelectedShape.dimension.Location;
                    hasSelected        = true;
                    return;
                }
            }

            // check overige shape of er 1 geselecteerd
            foreach (Shape s in shapeList)
            {
                if (s.dimension.Contains(e.Location))
                {
                    Command selectShape = new SelectShapeCommand(s, this);
                    history.Add(selectShape);

                    shapeStartPosition = s.dimension.Location;
                    hasSelected        = true;

                    ResizeShapeButton.Enabled = true;
                    Invalidate();
                    return;
                }
            }

            // in de void gedrukt
            if (SelectedShape != null)
            {
                Command deselectShape = new SelectShapeCommand(null, this);
                history.Add(deselectShape);

                ResizeShapeButton.Enabled = false;
                Invalidate();
            }
        }