SvgPoint.cs 1.52 KB
Newer Older
davescriven's avatar
davescriven committed
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;

namespace Svg
{
    public struct SvgPoint
    {
        private SvgUnit x;
        private SvgUnit y;

        public SvgUnit X
        {
            get { return this.x; }
            set { this.x = value; }
        }

        public SvgUnit Y
        {
            get { return this.y; }
            set { this.y = value; }
        }

        public PointF ToDeviceValue()
        {
            return new PointF(this.X.ToDeviceValue(), this.Y.ToDeviceValue());
        }

        public bool IsEmpty()
        {
            return (this.X.Value == 0.0f && this.Y.Value == 0.0f);
        }

        public override bool Equals(object obj)
        {
38
            if (obj == null) return false;
davescriven's avatar
davescriven committed
39

40
            if (!(obj.GetType() == typeof(SvgPoint))) return false;
davescriven's avatar
davescriven committed
41

42
            var point = (SvgPoint)obj;
davescriven's avatar
davescriven committed
43
44
45
            return (point.X.Equals(this.X) && point.Y.Equals(this.Y));
        }

46
47
48
49
50
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

davescriven's avatar
davescriven committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
        public SvgPoint(string x, string y)
        {
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(SvgUnit));

            this.x = (SvgUnit)converter.ConvertFrom(x);
            this.y = (SvgUnit)converter.ConvertFrom(y);
        }

        public SvgPoint(SvgUnit x, SvgUnit y)
        {
            this.x = x;
            this.y = y;
        }
    }
}