public void FillRoundedRectangle(Rectangle rect, float radX, float radY, UBrush brush) { var rr = new RoundedRectangle() { Rect = D2DTr.tr(rect), RadiusX = radX, RadiusY = radY }; realRenderer.renderTarget.FillRoundedRectangle(rr, CreateBrush(brush)); }
public void DrawRoundedRectangle(Rectangle rect, float radX, float radY, UBrush brush, UStroke stroke) { var rr = new RoundedRectangle() { Rect = D2DTr.tr(rect), RadiusX = radX, RadiusY = radY }; realRenderer.renderTarget.DrawRoundedRectangle(rr, CreateBrush(brush), stroke.strokeWidth, CreateStroke(stroke)); }
public override SharpDXLib.Result DrawGlyphRun(object clientDrawingContext, float baselineOriginX, float baselineOriginY, MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, SharpDXLib.ComObject clientDrawingEffect) { var cce = (ClientTextEffect)clientDrawingEffect; var args = (Object[])clientDrawingContext; var ofs = (Point)args[0]; var ut = (UText)args[1]; Point origin = new Point(baselineOriginX, baselineOriginY); var fgb = cce == null ? defaultEffect.fgBrush : cce.fgBrush; rt.DrawGlyphRun(D2DTr.tr(origin), glyphRun, fgb, MeasuringMode.Natural); return(SharpDXLib.Result.Ok); }
Geometry CreateNewGeometry(UPath p) { var pg = new PathGeometry(realRenderer.renderTarget.Factory); var gs = pg.Open(); foreach (var f in p.figures) { gs.BeginFigure(D2DTr.tr(f.startPoint), f.filled ? FigureBegin.Filled : FigureBegin.Hollow); foreach (var gb in f.geoElements) { AppendGeometry(gs, gb); } gs.EndFigure(f.open ? FigureEnd.Open : FigureEnd.Closed); } gs.Close(); return(pg); }
Brush CreateNewBrush(UBrush b) { Brush ret; if (b is USolidBrush) { // FIXME support brushProperties USolidBrush sb = b as USolidBrush; ret = new SolidColorBrush(realRenderer.renderTarget, D2DTr.tr(sb.color)); } else if (b is ULinearGradientBrush) { // FIXME advanced features not used var lb = b as ULinearGradientBrush; LinearGradientBrush lgb = new LinearGradientBrush(realRenderer.renderTarget, new LinearGradientBrushProperties() { StartPoint = D2DTr.tr(lb.point1), EndPoint = D2DTr.tr(lb.point2) }, new GradientStopCollection(realRenderer.renderTarget, new GradientStop[] { new GradientStop() { Color = D2DTr.tr(lb.color1), Position = 0f }, new GradientStop() { Color = D2DTr.tr(lb.color2), Position = 1f } }, Gamma.StandardRgb, ExtendMode.Clamp) ); ret = lgb; } else { throw new NotImplementedException(); } // Extra invalidation condition besides colors changeing etc as handled by the ObjStore descendants: renderTarget disposed (eg resize). realRenderer.renderTarget.Disposed += new EventHandler <EventArgs>((o, e) => b.Invalidate()); return(ret); }
public void DrawEllipse(Point center, float radiusX, float radiusY, UBrush brush, UStroke stroke) { realRenderer.renderTarget.DrawEllipse(new Ellipse(D2DTr.tr(center), radiusX, radiusY), CreateBrush(brush), stroke.strokeWidth, CreateStroke(stroke)); }
public void FillEllipse(Point center, float radiusX, float radiusY, UBrush brush) { realRenderer.renderTarget.FillEllipse(new Ellipse(D2DTr.tr(center), radiusX, radiusY), CreateBrush(brush)); }
public void DrawBitmap(UBitmap bitmap, float opacity, UInterp interp, Rectangle source, Rectangle destination) { realRenderer.renderTarget.DrawBitmap(CreateBitmap(bitmap), D2DTr.tr(destination), opacity, Translate(interp), D2DTr.tr(source)); }
// FIXME another example of type switching. Cant put d2d code on other side of bridge in eg UGeometryBase abstraction // and also, using a factory to create the UGeometryBase will make d2d specific versions. // IDEA This is possible: Use factory (DI?) and check the Uxxx instances when passed to this type of class, and recreate // a portion of the Uxxx if it doesnt match D2D? Factory could be configured for d2d/ogl etc. This links in with cacheing // code too? Not sure if this will static compile :/ thats kinda the point... we'd need the Uxxx.ICreateStuff to be a specific // D2D interface...could subclass... would check if(ICreateStuff is D2DCreator) as d2dcreator else Icreatestuff=new d2dcreator... void AppendGeometry(GeometrySink sink, UGeometryBase geo) { if (geo is UArc) { UArc arc = geo as UArc; sink.AddArc(new ArcSegment() { SweepDirection = arc.sweepClockwise ? SweepDirection.Clockwise : SweepDirection.CounterClockwise, RotationAngle = -arc.rotation, ArcSize = arc.reflex ? ArcSize.Large : ArcSize.Small, Point = D2DTr.tr(arc.endPoint), Size = D2DTr.tr(arc.arcSize) }); } //else if (geo is UEasyArc) //{ // UEasyArc arc = geo as UEasyArc; // var eco = geo.Retreive<D2DDraw>(() => // { // var cp = gcpt(); // return EllipseLib.EasyEllipse.ConvertEndPoint(new EllipseLib.EasyEllipse.EasyEllipseInput() // { // resolution = arc.resolution, // t1 = arc.startAngle, // t2 = arc.endAngle, // rx = arc.arcSize.width, // ry = arc.arcSize.height, // rotation = arc.rotation, // start_x = cp.X, // start_y = cp.Y // }); // }) as EllipseLib.EasyEllipse.EECOut; // sink.AddArc(new ArcSegment() // { // SweepDirection = eco.clockwise ? SweepDirection.Clockwise : SweepDirection.CounterClockwise, // RotationAngle = -arc.rotation, // ArcSize = eco.reflex ? ArcSize.Large : ArcSize.Small, // Point = new SharpDXLib.DrawingPointF(eco.x, eco.y), // Size = D2DTr.tr(arc.arcSize) // }); //} else if (geo is ULine) { ULine line = geo as ULine; sink.AddLine(D2DTr.tr(line.endPoint)); } else if (geo is UBeizer) { UBeizer beizer = geo as UBeizer; sink.AddBezier(new BezierSegment() { Point1 = D2DTr.tr(beizer.controlPoint1), Point2 = D2DTr.tr(beizer.controlPoint2), Point3 = D2DTr.tr(beizer.endPoint) }); } else { throw new NotImplementedException(); } }
public void FillRectangle(Rectangle rect, UBrush brush) { realRenderer.renderTarget.FillRectangle(D2DTr.tr(rect), CreateBrush(brush)); }
public void DrawRectangle(Rectangle rect, UBrush brush, UStroke stroke) { realRenderer.renderTarget.DrawRectangle(D2DTr.tr(rect), CreateBrush(brush), stroke.strokeWidth, CreateStroke(stroke)); }
public void DrawLine(Point start, Point end, UBrush brush, UStroke stroke) { realRenderer.renderTarget.DrawLine(D2DTr.tr(start), D2DTr.tr(end), CreateBrush(brush), stroke.strokeWidth, CreateStroke(stroke)); }