aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TEMP/Tango.Graphics2D/Drawing2DCanvas.cs
blob: 38b3b2acbcb97219a0008164c88d4fd66ce09bfb (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;

namespace Tango.Graphics2D
{
    public class Drawing2DCanvas : Drawing2DHost
    {
        public override Point GetElementLocation(FrameworkElement element)
        {
            return GetElementCanvasLocation(element);
        }

        private Point GetElementCanvasLocation(UIElement element)
        {
            var location = new Point(Canvas.GetLeft(element), Canvas.GetTop(element));

            if (double.IsNaN(location.X))
            {
                location.X = 0;
            }

            if (double.IsNaN(location.Y))
            {
                location.Y = 0;
            }

            return location;
        }

        public override Size GetElementSize(FrameworkElement element)
        {
            return new Size(element.Width, element.Height);
        }
    }
}