public void ConvertFloatArrayToDashes_Should_Return_Dashes_String() { var dashes = new float[] { 2.0f, 2.0f, 0.0f, 2.0f, 0.0f, 2.0f }; var expected = "2 2 0 2 0 2"; var target = StyleHelper.ConvertFloatArrayToDashes(dashes); Assert.Equal(expected, target); }
public void ConvertFloatArrayToDashes_Should_Not_Throw() { var target = StyleHelper.ConvertFloatArrayToDashes(null); Assert.Null(target); }
private static IShapeStyle ToStyle(SP.Paint paint, IFactory factory) { var style = factory.CreateShapeStyle("Style"); if (paint == null) { return(style); } switch (paint.Shader) { case SP.ColorShader colorShader: style.Stroke = ToArgbColor(colorShader, factory); style.Fill = ToArgbColor(colorShader, factory); break; case SP.LinearGradientShader linearGradientShader: // TODO: break; case SP.TwoPointConicalGradientShader twoPointConicalGradientShader: // TODO: break; case SP.PictureShader pictureShader: // TODO: break; default: break; } style.Thickness = paint.StrokeWidth; style.LineCap = ToLineCap(paint.StrokeCap); if (paint.PathEffect is SP.DashPathEffect dashPathEffect && dashPathEffect.Intervals != null) { style.Dashes = StyleHelper.ConvertFloatArrayToDashes(dashPathEffect.Intervals); style.DashOffset = dashPathEffect.Phase; } if (paint.Typeface != null) { if (paint.Typeface.FamilyName != null) { style.TextStyle.FontName = paint.Typeface.FamilyName; } style.TextStyle.FontSize = paint.TextSize; style.TextStyle.TextHAlignment = ToTextHAlignment(paint.TextAlign); if (paint.Typeface.Weight == SP.FontStyleWeight.Bold) { style.TextStyle.FontStyle.Bold = true; } if (paint.Typeface.Style == SP.FontStyleSlant.Italic) { style.TextStyle.FontStyle.Italic = true; } } return(style); }