Exemple #1
0
 public Draw(int actionToChange, Tool tool, Point startingPosition, IDrawingStrategy strategy)
 {
     _tool = tool;
     _startingPoint = startingPosition;
     _currentPoint = startingPosition;
     _drawingStrategy = strategy;
     _actionToChange = actionToChange;
     _addedElements = new List<UIElement>();
 }
        public void ShouldChangeCurrentTool(eTool toolType)
        {
            //Given
            PaintingMediator paint = new PaintingMediator();

            //When
            paint.ChangeToolTo(toolType);

            //Then
            Tool expectedTool = new Tool(toolType);
            Assert.AreEqual(expectedTool, paint.GetCurrentTool());
        }
        public UIElement Draw(Canvas element, Tool tool, Point startingPoint, Point currentPoint)
        {
            DrawingShapeSetuper shapeSetuper = new DrawingShapeSetuper();
            Ellipse ellipse = new Ellipse();
            ellipse.Fill = new SolidColorBrush(tool.GetNativeColorObject());
            ellipse.Width = shapeSetuper.GetWidthOfShape(startingPoint, currentPoint);
            ellipse.Height = shapeSetuper.GetHeightOfShape(startingPoint, currentPoint);
            shapeSetuper.SetUpShape(ellipse, startingPoint, currentPoint);

            element.Children.Add(ellipse);

            return ellipse;
        }
        public UIElement Draw(Canvas element, Tool tool, Point startingPoint, Point currentPoint)
        {
            Line line = new Line();
            line.Fill = new SolidColorBrush(tool.GetNativeColorObject());
            line.Stroke = new SolidColorBrush(tool.GetNativeColorObject());
            line.X1 = startingPoint.X;
            line.X2 = currentPoint.X;
            line.Y1 = startingPoint.Y;
            line.Y2 = currentPoint.Y;

            element.Children.Add(line);

            return line;
        }
        public UIElement Draw(Canvas element, Tool tool, Point startingPoint, Point currentPoint)
        {
            FirstUsageAction(startingPoint);
            Rectangle rubber = new Rectangle();
            DrawingShapeSetuper shapeSetuper = new DrawingShapeSetuper();
            rubber.Width = 10;
            rubber.Height = 10;
            shapeSetuper.SetUpShape(rubber, _previousPoint, currentPoint);
            rubber.Fill = new SolidColorBrush(Color.FromRgb(255,255,255));

            element.Children.Add(rubber);

            _previousPoint = currentPoint;

            return rubber;
        }
        public UIElement Draw(Canvas canvas, Tool tool, Point startingPoint, Point currentPoint)
        {
            FirstUsageAction(startingPoint);
            Line pencilDrawing = new Line();
            pencilDrawing.Fill = new SolidColorBrush(tool.GetNativeColorObject());
            pencilDrawing.Stroke = new SolidColorBrush(tool.GetNativeColorObject());
            pencilDrawing.X1 = _previousPoint.X;
            pencilDrawing.X2 = currentPoint.X;
            pencilDrawing.Y1 = _previousPoint.Y;
            pencilDrawing.Y2 = currentPoint.Y;

            canvas.Children.Add(pencilDrawing);
            _previousPoint = currentPoint;

            return pencilDrawing;
        }