Esempio n. 1
0
        public void Get_Shape_type_execption()
        {
            var doubleList = new List <double>()
            {
                1, 2
            };

            var result = shape.GetShape(doubleList);

            Assert.IsType <IShape>(result);
        }
        public void GetShape_CreateCircle_Success()
        {
            // Arrange
            const double radius = 12d;

            // Act
            var shape = _shapeCreator.GetShape(radius);

            // Assert
            var circle = shape as Circle;

            Assert.NotNull(circle);
            Assert.Equal(radius, circle.Radius);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Укажите стороны фигуры через запятую: ");
            string input = Console.ReadLine();


            InputHandler inputHandler = new InputHandler();
            var          digitList    = inputHandler.TransformInput(input);

            ShapeCreator shapeCreator = new ShapeCreator();
            var          shapeForm    = shapeCreator.GetShape(digitList);

            ShapeChooser shapeChooser = new ShapeChooser();
            var          area         = shapeChooser.GetShape(shapeForm);

            Console.WriteLine("Площадь фигуры = " + area);
            Console.ReadLine();
        }
Esempio n. 5
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);
            }
        }