public override void DrawRectangle(IPen pen, IColor fillColor, float x, float y, float width, float height) { Color sdFillColor = ((ColorHandler)fillColor).Handle; using (GraphicsPath path = CreateRectangle(x, y, width, height)) { if (sdFillColor != Color.Transparent) { fCanvas.FillPath(new SolidBrush(sdFillColor), path); } if (pen != null) { Pen sdPen = ((PenHandler)pen).Handle; fCanvas.DrawPath(sdPen, path); } } if (fSVGGfx != null) { if (sdFillColor != Color.Transparent) { fSVGGfx.SetColor(fillColor); fSVGGfx.FillRect(x, y, width, height); } if (pen != null) { fSVGGfx.SetColor(pen.Color); fSVGGfx.DrawRect(x, y, width, height, pen.Width); } } }
public void Test_SvgGraphics() { using (MemoryStream stm = new MemoryStream()) { var svg = new SvgGraphics(stm, ExtRectF.CreateBounds(0, 0, 100, 100)); svg.BeginDrawing(); svg.Clear(UIHelper.ConvertColor(Color.Yellow)); svg.BeginEntity(null); svg.DrawLine(10, 10, 50, 10, 1); svg.DrawArc(60, 60, 20, 15, 25, 1); svg.DrawEllipse(10, 10, 30, 30, null, null); svg.DrawRect(50, 50, 20, 20, 2); svg.DrawRoundedRect(80, 80, 10, 10, 3, 1); svg.EndEntity(); svg.FillArc(60, 60, 20, 15, 25); svg.DrawEllipse(10, 10, 30, 30, null, null); svg.FillRect(50, 50, 20, 20); svg.SetColor(UIHelper.ConvertColor(Color.Red)); svg.FillRoundedRect(80, 80, 10, 10, 3); svg.DrawCircleSegment(0, 0, 10, 20, 0, 17, null, null); svg.DrawImage(null, 0, 0, 100, 100); svg.DrawPolygon(new ExtPointF[] {}, null, null); svg.DrawString("x", 10, 10); svg.ResetState(); svg.SaveState(); svg.RestoreState(); svg.Rotate(75); svg.Translate(10, 10); svg.Scale(0.5f, 0.5f); svg.SetClippingRect(0.0f, 0.0f, 10f, 10f); svg.SetFont(null); Assert.Throws(typeof(ArgumentNullException), () => { svg.SetColor(null); }); svg.BeginLines(false); svg.EndLines(); svg.EndDrawing(); } }