public Shape GetShape(EShapeType shapeType)
        {
            if (shapeType == null)
            {
                return(null);
            }

            switch (shapeType)
            {
            case EShapeType.Square:
                return(new Square());

                break;

            case EShapeType.Rectangle:
                return(new Rectangle());

                break;

            case EShapeType.Circle:
                return(new Circle());

                break;
            }

            return(null);
        }
Beispiel #2
0
        public IShape CreateShape(EShapeType currentMode)
        {
            switch (currentMode)
            {
            case EShapeType.Dot:
                return(new Dot());

            case EShapeType.Line:
                return(new Line());

            case EShapeType.Curve:
                return(new Curve());

            case EShapeType.Rect:
                return(new Rect());

            case EShapeType.Ellipse:
                return(new Ellipse());

            case EShapeType.Triangle:
                return(new Triangle());

            case EShapeType.Hexagon:
                return(new Hexagon());

            case EShapeType.RoundingRect:
                return(new RoundingRect());

            default: throw new Exception("This figure doesn't exist");
            }
        }
Beispiel #3
0
        public void Init(EShapeType type, int thickness, PaintColor color)
        {
            _newshape           = _shape.CreateShape(type);
            _newshape.Thickness = thickness;
            _newshape.Color     = color;

            _storage.Add(_newshape);
        }
Beispiel #4
0
 public ShapeInfo(ShapeInfo anotherInfo)
 {
     shapeId          = anotherInfo.shapeId;
     shapeType        = anotherInfo.shapeType;
     shapePosition    = anotherInfo.shapePosition;
     shapePositionIds = anotherInfo.shapePositionIds;
     shapeRotation    = anotherInfo.shapeRotation;
     shapeRotationId  = anotherInfo.shapeRotationId;
 }
Beispiel #5
0
        public void AddTestCase(EShapeType type)
        {
            IShape exp = _factory.CreateShape(type);

            _storage.Add(exp);

            var act = _storage.GetShapeForIndex(0);

            Assert.AreSame(exp, act);
        }
Beispiel #6
0
        public Paint()
        {
            InitializeComponent();
            _currentMode = EShapeType.Curve;

            _bl = new BusinessLogic(new Storage(), new ShapeFactory(), new JsonLogic());
            _bl.Init(_currentMode, _currentBrashSize, _curentcolor);

            _currentBitmap       = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height);
            _bufferedBitmap      = _currentBitmap.Clone() as PaintBitmap;
            pictureBoxMain.Image = _currentBitmap.ToImage();
        }
        public override Shape GetShape(EShapeType shapeType)
        {
            switch (shapeType)
            {
            case EShapeType.Square:
                return(new Square());

            case EShapeType.Rectangle:
                return(new Rectangle());
            }
            return(null);
        }
Beispiel #8
0
        public void NewShape(EShapeType type, int thickness, PaintColor color, int cornes, ShapeSize size)
        {
            _newshape           = _shape.CreateShape(type);
            _newshape.Thickness = thickness;
            _newshape.Color     = color;

            if (_newshape is Hexagon)
            {
                (_newshape as Hexagon).Cornes = cornes;
                (_newshape as Hexagon).Size   = size;
            }
            _storage.Add(_newshape);
        }
Beispiel #9
0
        public ObjectShape(EShapeType type, Vector size, Color c)
        {
            switch (type)
            {
                case EShapeType.Circle:
                    shape = new Ellipse();
                    break;
                case EShapeType.Square:
                    shape = new Rectangle();
                    break;
            }

            shape.Width = size.X;
            shape.Height = size.Y;
            shape.Fill = new SolidColorBrush(c);
            this.color = c;
            this.size = size;
        }
Beispiel #10
0
        public void MoveMegaTest(EShapeType type, int dx, int dy, int startX, int startY, int finX, int finY)
        {
            IShape expShape = _shape.CreateShape(type);

            expShape.Location       = new ShapePoint(dx + startX, dy + startY);
            expShape.FinishLocation = new ShapePoint(dx + finX, dy + finY);

            IShape actShape = _shape.CreateShape(type);

            actShape.Location       = new ShapePoint(startX, startY);
            actShape.FinishLocation = new ShapePoint(finX, finY);

            _bl.Move(dx, dy, actShape);


            Assert.AreEqual(expShape.Location.X, actShape.Location.X);
            Assert.AreEqual(expShape.Location.Y, actShape.Location.Y);
            Assert.AreEqual(expShape.FinishLocation.X, actShape.FinishLocation.X);
            Assert.AreEqual(expShape.FinishLocation.Y, actShape.FinishLocation.Y);
        }
Beispiel #11
0
 private void RoundingRectButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.RoundingRect;
 }
Beispiel #12
0
 private void HexagonButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Hexagon;
 }
Beispiel #13
0
 private void TriangleButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Triangle;
 }
Beispiel #14
0
 private void EllipseButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Ellipse;
 }
Beispiel #15
0
 private void CurveButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Curve;
 }
Beispiel #16
0
 private void DotButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Dot;
 }
Beispiel #17
0
 public AbstractShape(EShapeType name)
 {
     this.name = name;
 }
Beispiel #18
0
 public abstract Shape GetShape(EShapeType shapeType);