blob: fefd6a12c40224d6f519935cb436a2ee96673901 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
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<DependencyProperty> GetRenderProperties()
{
return new List<DependencyProperty>()
{
Rectangle.OpacityProperty,
Rectangle.VisibilityProperty,
Rectangle.FillProperty,
};
}
}
}
|