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
44
45
46
47
48
|
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 LineBinder : IVisualBinder
{
public void DrawVisual(FrameworkElement element, Drawing2DHost host, DrawingContext context)
{
Line line = element as Line;
var location = host.GetElementLocation(line);
var size = host.GetElementSize(line);
Pen pen = null;
if (line.Stroke != null)
{
pen = new Pen(line.Stroke, line.StrokeThickness);
pen.DashCap = line.StrokeDashCap;
//TODO: add some stroke features...
}
context.DrawLine(pen, new Point(line.X1, line.Y1), new Point(line.X2, line.Y2));
}
public List<DependencyProperty> GetRenderProperties()
{
return new List<DependencyProperty>()
{
Line.OpacityProperty,
Line.VisibilityProperty,
Line.StrokeProperty,
Line.X1Property,
Line.Y1Property,
Line.X2Property,
Line.Y2Property,
Line.StrokeThicknessProperty
};
}
}
}
|