コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: ShapeFactory.cs プロジェクト: VladaCat/Paint
        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");
            }
        }
コード例 #3
0
ファイル: BusinessLogic.cs プロジェクト: VladaCat/Paint
        public void Init(EShapeType type, int thickness, PaintColor color)
        {
            _newshape           = _shape.CreateShape(type);
            _newshape.Thickness = thickness;
            _newshape.Color     = color;

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

            _storage.Add(exp);

            var act = _storage.GetShapeForIndex(0);

            Assert.AreSame(exp, act);
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: VladaCat/Paint
        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();
        }
コード例 #7
0
        public override Shape GetShape(EShapeType shapeType)
        {
            switch (shapeType)
            {
            case EShapeType.Square:
                return(new Square());

            case EShapeType.Rectangle:
                return(new Rectangle());
            }
            return(null);
        }
コード例 #8
0
ファイル: BusinessLogic.cs プロジェクト: VladaCat/Paint
        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);
        }
コード例 #9
0
ファイル: Units.cs プロジェクト: gdpaulmil/WPF_ServerClient
        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;
        }
コード例 #10
0
ファイル: BussinesLogicTest.cs プロジェクト: VladaCat/Paint
        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);
        }
コード例 #11
0
ファイル: MainForm.cs プロジェクト: VladaCat/Paint
 private void RoundingRectButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.RoundingRect;
 }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: VladaCat/Paint
 private void HexagonButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Hexagon;
 }
コード例 #13
0
ファイル: MainForm.cs プロジェクト: VladaCat/Paint
 private void TriangleButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Triangle;
 }
コード例 #14
0
ファイル: MainForm.cs プロジェクト: VladaCat/Paint
 private void EllipseButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Ellipse;
 }
コード例 #15
0
ファイル: MainForm.cs プロジェクト: VladaCat/Paint
 private void CurveButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Curve;
 }
コード例 #16
0
ファイル: MainForm.cs プロジェクト: VladaCat/Paint
 private void DotButton_Click(object sender, EventArgs e)
 {
     _currentMode = EShapeType.Dot;
 }
コード例 #17
0
ファイル: AbstractShape.cs プロジェクト: VladaCat/Paint
 public AbstractShape(EShapeType name)
 {
     this.name = name;
 }
コード例 #18
0
 public abstract Shape GetShape(EShapeType shapeType);