Пример #1
0
 /// <summary>
 ///     Constructor to create an ellipse.
 /// </summary>
 /// <param name="height">Height of ellipse.</param>
 /// <param name="width">Width of ellipse.</param>
 /// <param name="strokeWidth">Stroke Width/</param>
 /// <param name="strokeColor">Stroke Color.</param>
 /// <param name="shapeFill">Fill color of the shape.</param>
 /// <param name="start">The left bottom coordinate of the smallest rectangle enclosing the shape.</param>
 /// <param name="points">List of points, if any.</param>
 /// <param name="angle">Angle of Rotation.</param>
 public Ellipse(int height,
                int width,
                float strokeWidth,
                BoardColor strokeColor,
                BoardColor shapeFill,
                Coordinate start,
                List <Coordinate> points,
                float angle) :
     base(ShapeType.ELLIPSE, height, width, strokeWidth, strokeColor, shapeFill, start, points, angle)
 {
 }
Пример #2
0
 /// <summary>
 ///     Constructor to initialise MainShape with a shape.
 /// </summary>
 /// <param name="s">The type of shape.</param>
 public MainShape(ShapeType s)
 {
     ShapeIdentifier = s;
     Height          = 0;
     Width           = 0;
     StrokeWidth     = 0;
     ShapeFill       = new BoardColor(255, 255, 255);
     StrokeColor     = new BoardColor(0, 0, 0);
     Start           = new Coordinate(0, 0);
     Points          = new List <Coordinate>();
     AngleOfRotation = 0;
 }
Пример #3
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="s">Type of shape.</param>
 /// <param name="height">Height of the Shape.</param>
 /// <param name="width">Width of the Shape.</param>
 /// <param name="strokeWidth">Width of shape outline stroke.</param>
 /// <param name="strokeColor">Color of shape outline stroke.</param>
 /// <param name="shapeFill">Shape fill of the shape.</param>
 /// <param name="start">The left bottom coordinate of the smallest rectangle surrounding the shape.</param>
 /// <param name="points">Points in case it is a polyline or a line.</param>
 /// <param name="angle">Angle of Rotation of the Shape</param>
 public MainShape(ShapeType s, int height, int width, float strokeWidth, BoardColor strokeColor,
                  BoardColor shapeFill, Coordinate start, List <Coordinate> points, float angle)
 {
     ShapeIdentifier = s;
     Height          = height;
     Width           = width;
     StrokeWidth     = strokeWidth;
     StrokeColor     = strokeColor.Clone();
     ShapeFill       = shapeFill.Clone();
     Start           = start.Clone();
     Points          = points.Select(cord => new Coordinate(cord.R, cord.C)).ToList();
     AngleOfRotation = angle;
 }
Пример #4
0
 /// <summary>
 ///     Constructor to create a Line.
 /// </summary>
 /// <param name="height">Height of line.</param>
 /// <param name="width">Width of line.</param>
 /// <param name="strokeWidth">Stroke Width/</param>
 /// <param name="strokeColor">Stroke Color.</param>
 /// <param name="shapeFill">Fill color of the shape.</param>
 /// <param name="start">The left bottom coordinate of the smallest rectangle enclosing the shape.</param>
 /// <param name="points">List of points, if any.</param>
 /// <param name="angle">Angle of Rotation.</param>
 public Line(int height,
             int width,
             float strokeWidth,
             BoardColor strokeColor,
             BoardColor shapeFill,
             Coordinate start,
             List <Coordinate> points,
             float angle) :
     base(ShapeType.LINE, height, width, strokeWidth, strokeColor, shapeFill, start, points, angle)
 {
     AddToList(start.Clone());
     AddToList(new Coordinate(start.R + height, start.C + width));
 }
        /// <summary>
        ///     Changes the stroke of the shape.
        /// </summary>
        /// <param name="strokeColor">Modified fill color of outline stroke of shape..</param>
        /// <param name="shapeId">Id of the shape on which operation is performed.</param>
        /// <returns>The List of operations on Shapes for UX to render.</returns>
        public override List <UXShape> ChangeStrokeColor(BoardColor strokeColor, string shapeId)
        {
            // get the actual BoardServer object stored in the server
            var shapeFromManager = _stateManager.GetBoardShape(shapeId);

            // Create a new BoardShape to perform modification since this changes should not be directly reflected in the object stored in the Manager.
            var newBoardShape = shapeFromManager.Clone();

            newBoardShape.MainShapeDefiner.StrokeColor = strokeColor.Clone();

            var Operations = UpdateManager(shapeFromManager, newBoardShape, Operation.MODIFY);

            return(Operations);
        }
 public override List <UXShape> CreateShape(ShapeType shapetype, Coordinate start, Coordinate end,
                                            float strokeWidth, BoardColor strokeColor, string shapeId = null, bool shapeComp = false)
 {
     return(new List <UXShape>());
 }
 public override List <UXShape> ChangeStrokeColor(BoardColor strokeColor, string shapeId)
 {
     return(new List <UXShape>());
 }
 public override List <UXShape> ChangeShapeFill(BoardColor shapeFill, string shapeId)
 {
     return(new List <UXShape>());
 }
Пример #9
0
 public abstract List <UXShape> CreateShape(ShapeType shapeType, Coordinate start, Coordinate end,
                                            float strokeWidth, BoardColor strokeColor, string shapeId = null, bool shapeComp = false);
Пример #10
0
 public abstract List <UXShape> ChangeStrokeColor(BoardColor strokeColor, string shapeId);
Пример #11
0
 public abstract List <UXShape> ChangeShapeFill(BoardColor shapeFill, string shapeId);
 /// <summary>
 ///     Creates Ellipse/Circle.
 /// </summary>
 /// <param name="start"> Coordinate of mouse down event. </param>
 /// <param name="end"> Current cordinate to display real-time shape creation before/at mouse up event. </param>
 /// <param name="strokeWidth"> Shape boundary stroke width. </param>
 /// <param name="strokeColor"> Color of shape boundary stroke. </param>
 /// <param name="shapeId"> Id of the shape. Null if shape creation just started. </param>
 /// <param name="shapeComp"> indicative of a mouse up event. </param>
 /// <returns> List of UXShapes for UX to render. </returns>
 public List <UXShape> CreateEllipse(Coordinate start, Coordinate end, float strokeWidth, BoardColor strokeColor,
                                     string shapeId = null, bool shapeComp = false)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 ///     Changes the Stroke Color of the shape outline.
 /// </summary>
 /// <param name="strokeColor"> Stroke Color. </param>
 /// <param name="shapeId">Id of the shape. </param>
 /// <returns> List of UXShapes for UX to render. </returns>
 public List <UXShape> ChangeStrokeColor(BoardColor strokeColor, string shapeId)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 ///     Changes the Fill Color of the shape.
 /// </summary>
 /// <param name="shapeFill"> Shape Fill Color. </param>
 /// <param name="shapeId">Id of the shape. </param>
 /// <returns> List of UXShapes for UX to render. </returns>
 public List <UXShape> ChangeShapeFill(BoardColor shapeFill, string shapeId)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        ///     Creates shape based on mouse drag.
        /// </summary>
        /// <param name="shapeType">Denotes which shape to create.</param>
        /// <param name="start">Start of mouse drag.</param>
        /// <param name="end">End of mouse drag.</param>
        /// <param name="strokeWidth">Width of the outline stroke.</param>
        /// <param name="strokeColor">Color of the outline stroke.</param>
        /// <param name="shapeId">Id of the shape.</param>
        /// <param name="shapeComp">Denotes whether the shape is complete, or if it is for real-time rendering.</param>
        /// <returns>The List of operations on Shapes for UX to render.</returns>
        public override List <UXShape> CreateShape(ShapeType shapeType, Coordinate start, Coordinate end,
                                                   float strokeWidth, BoardColor strokeColor, string shapeId = null,
                                                   bool shapeComp = false)
        {
            // shapeId null signifies a new shape creation.
            if (shapeId == null)
            {
                _lastDrawn         = null;
                _isLastDrawPending = false;
            }

            // List of Operations to be send to UX
            var operations = new List <UXShape>();

            // required to clear the previous shape in internal storage for real time rendering, before forming the new shape
            if (_lastDrawn != null && shapeType != _lastDrawn.MainShapeDefiner.ShapeIdentifier)
            {
                // Delete the Object that was already created in the canvas
                var oldShapeId = _lastDrawn.Uid;
                var oldShape   = new UXShape(UXOperation.DELETE, _lastDrawn.MainShapeDefiner, oldShapeId);
                operations.Add(oldShape);

                // In this case previous shape won't be used for creating new shape
                _lastDrawn = null;
            }

            //creation of a completely new shape
            string newShapeId = null;

            if (_lastDrawn == null)
            {
                var newMainShape = ShapeFactory.MainShapeCreatorFactory(shapeType, start, end, null);

                // setting params for new shape
                newMainShape.StrokeColor = strokeColor.Clone();
                newMainShape.StrokeWidth = strokeWidth;

                var newUxShape = new UXShape(UXOperation.CREATE, newMainShape, null);
                newShapeId = newUxShape.WindowsShape.Uid;
                operations.Add(newUxShape);

                var userLevel = 0; // to be changed
                var userId    = _stateManager.GetUser();

                // creating the new BoardShape to send to server
                _lastDrawn = new BoardShape(newMainShape, userLevel, DateTime.Now, DateTime.Now, newShapeId, userId,
                                            Operation.CREATE);
            }
            else
            {
                var modifiedPrevShape =
                    ShapeFactory.MainShapeCreatorFactory(shapeType, start, end, _lastDrawn.MainShapeDefiner);
                var newUxShape = new UXShape(UXOperation.CREATE, modifiedPrevShape, null);
                newShapeId = newUxShape.WindowsShape.Uid;
                operations.Add(newUxShape);

                _lastDrawn.MainShapeDefiner = modifiedPrevShape;
                _lastDrawn.LastModifiedTime = DateTime.Now;
                _lastDrawn.RecentOperation  = Operation.CREATE;
            }

            // sending the Updates to the Client Side Server
            _isLastDrawPending = true;
            if (shapeComp)
            {
                // send updates to server .. clone of _lastDrawn
                var newBoardShape = _lastDrawn.Clone();
                newBoardShape.RecentOperation  = Operation.CREATE;
                newBoardShape.Uid              = newShapeId;
                newBoardShape.LastModifiedTime = DateTime.Now;
                newBoardShape.CreationTime     = DateTime.Now;
                _stateManager.SaveOperation(newBoardShape);

                //reset the variables
                _lastDrawn         = null;
                _isLastDrawPending = false;
            }

            return(operations);
        }