aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TEMP/Tango.Graphics2D/VisualBinders/EllipseBinder.cs
blob: 53bfde59afbc474c960a448dbf04421f5c744417 (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 EllipseBinder : IVisualBinder
    {
        public void DrawVisual(FrameworkElement element, Drawing2DHost host, DrawingContext context)
        {
            Ellipse ellipse = element as Ellipse;

            var location = host.GetElementLocation(ellipse);
            var size = host.GetElementSize(ellipse);

            Pen pen = null;

            if (ellipse.Stroke != null)
            {
                pen = new Pen(ellipse.Stroke, ellipse.StrokeThickness);
                pen.DashCap = ellipse.StrokeDashCap;
                //TODO: add some stroke features...
            }

            context.DrawEllipse(ellipse.Fill, pen, new Point(location.X + size.Width / 2, location.Y + size.Height / 2), size.Width / 2, size.Height / 2);
        }

        public List<DependencyProperty> GetRenderProperties()
        {
            return new List<DependencyProperty>()
            {
                Ellipse.OpacityProperty,
                Ellipse.VisibilityProperty,
                Ellipse.FillProperty,
            };
        }
    }
}