Ejemplo n.º 1
0
        private void PnlDrawingArea_MouseUp(object sender, MouseEventArgs e)
        {
            if (IsSelecting)
            {
                string shapeName = ShowDialog(Lang.ShapeNameMessage, "");

                if (shapeName != null)
                {
                    UserShapeCreators.Add(new UserShapeCreator(Shapes, FirstPoint, new Point(e.X, e.Y), shapeName));
                    ButtonsUserShapes();
                }
                IsSelecting = false;
                DoDrawing(Shapes);
            }
            if (UserShapeCreator != null)
            {
                UserShape userShape = UserShapeCreator.GetUserShape();
                userShape.CopyToListShapes(Shapes, FirstPoint, new Point(e.X, e.Y));
                DoDrawing(Shapes);
            }

            if (ShapeCreator != null)
            {
                IShape currShape = ShapeCreator.GetShape();
                currShape.Point1 = FirstPoint;
                currShape.Point2 = new Point(e.X, e.Y);
                Shapes.Add(currShape);
                TempShape = null;
                DoDrawing(Shapes);
            }
        }
Ejemplo n.º 2
0
        private void PnlDrawingArea_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && UserShapeCreator != null)
            {
                UserShape userShape = UserShapeCreator.GetUserShape();
                userShape.CopyToListShapes(TempShapes, FirstPoint, new Point(e.X, e.Y));
                foreach (IShape shape in TempShapes)
                {
                    Shapes.Add(shape);
                }
                DoDrawing(Shapes);
                foreach (IShape shape in TempShapes)
                {
                    Shapes.Remove(shape);
                }
                TempShapes.Clear();
            }

            if (e.Button == MouseButtons.Left && IsSelecting)
            {
                RedRectangle redRectangle = new RedRectangle();
                redRectangle.Point1 = FirstPoint;
                redRectangle.Point2 = new Point(e.X, e.Y);
                Shapes.Add(redRectangle);
                DoDrawing(Shapes);
                Shapes.Remove(redRectangle);
            }

            if (e.Button == MouseButtons.Left && ShapeCreator != null)
            {
                TempShape        = ShapeCreator.GetShape();
                TempShape.Point1 = FirstPoint;
                TempShape.Point2 = new Point(e.X, e.Y);
                Shapes.Add(TempShape);
                DoDrawing(Shapes);
                Shapes.Remove(TempShape);
            }
        }