public static CustomStroke stringToStroke(JObject serialized, CustomStrokeCollection strokes) { switch (serialized.ToObject <SerializedStroke>().ShapeType) { case "RECTANGLE": SerializedShape rectangle = serialized.ToObject <SerializedShape>(); var rectangleStroke = new BaseRectangleStroke(rectangle.Id, rectangle.Index, getExtrimities(rectangle.ShapeInfo), strokes, (Color)ColorConverter.ConvertFromString(rectangle.ShapeInfo.Color)); return(rectangleStroke); case "TRIANGLE": SerializedShape triangle = serialized.ToObject <SerializedShape>(); var triangleStroke = new BaseTrangleStroke(triangle.Id, triangle.Index, getExtrimities(triangle.ShapeInfo), strokes, (Color)ColorConverter.ConvertFromString(triangle.ShapeInfo.Color)); return(triangleStroke); case "ELLIPSE": SerializedShape elipse = serialized.ToObject <SerializedShape>(); var elipseStroke = new BaseElipseStroke(elipse.Id, elipse.Index, getExtrimities(elipse.ShapeInfo), strokes, (Color)ColorConverter.ConvertFromString(elipse.ShapeInfo.Color)); return(elipseStroke); case "CLASS": SerializedTextable classCase = serialized.ToObject <SerializedTextable>(); var classStroke = new ClassStroke(classCase.Id, classCase.Index, getExtrimities(classCase.ShapeInfo), strokes, UseCaseStroke.fromServerStyle(classCase.ShapeInfo.Content)); return(classStroke); case "TEXT": SerializedTextable text = serialized.ToObject <SerializedTextable>(); var textStroke = new TextStroke(text.Id, text.Index, getExtrimities(text.ShapeInfo), strokes, UseCaseStroke.fromServerStyle(text.ShapeInfo.Content)); return(textStroke); case "USE": SerializedTextable use = serialized.ToObject <SerializedTextable>(); var useStroke = new UseCaseStroke(use.Id, use.Index, getExtrimities(use.ShapeInfo), strokes, UseCaseStroke.fromServerStyle(use.ShapeInfo.Content)); return(useStroke); case "ACTOR": SerializedTextable actor = serialized.ToObject <SerializedTextable>(); var actorStroke = new PersonStroke(actor.Id, actor.Index, getExtrimities(actor.ShapeInfo), strokes, actor.ShapeInfo.Content[0]); return(actorStroke); case "LINE": SerializedLine line = serialized.ToObject <SerializedLine>(); var points = line.ShapeInfo.Points.ConvertAll <StylusPoint>(point => { return(new StylusPoint(point.X, point.Y)); }); var lineStroke = new BaseLine( line.Id, line.Index, new StylusPointCollection(points), strokes, line.ShapeInfo.FirstAnchorId, line.ShapeInfo.FirstAnchorIndex, line.ShapeInfo.SecondAnchorId, line.ShapeInfo.SecondAnchorIndex, line.ShapeInfo.FirstEndLabel, line.ShapeInfo.SecondEndLabel, line.ShapeInfo.FirstEndRelation, line.ShapeInfo.SecondEndRelation); return(lineStroke); } return(null); }
public override ShapeInfo GetShapeInfo() { return(new TextableShapeInfo { Center = new ShapePoint() { X = this.Center.X, Y = this.Center.Y }, Height = this.Height, Width = this.Width, Content = UseCaseStroke.toServerStyle(this.textContent), Color = new ColorConverter().ConvertToString(this.DrawingAttributes.Color) }); }