using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using System.Windows.Shapes; namespace Tango.Graphics2D.VisualBinders { public class RectangleBinder : IVisualBinder { public void DrawVisual(FrameworkElement element, Drawing2DHost host, DrawingContext context) { Rectangle rectangle = element as Rectangle; var location = host.GetElementLocation(rectangle); var size = host.GetElementSize(rectangle); Pen pen = null; if (rectangle.Stroke != null) { pen = new Pen(rectangle.Stroke, rectangle.StrokeThickness); pen.DashCap = rectangle.StrokeDashCap; //TODO: add some stroke features... } context.DrawRectangle(rectangle.Fill, pen, new Rect(location.X, location.Y, size.Width, size.Height)); } public List GetRenderProperties() { return new List() { Rectangle.OpacityProperty, Rectangle.VisibilityProperty, Rectangle.FillProperty, }; } } }