/// <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; }
/// <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); }
/// <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); }