SvgTransform.cs 1.36 KB
Newer Older
davescriven's avatar
davescriven committed
1
2
3
4
5
6
7
8
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Svg.Transforms
{
9
    public abstract class SvgTransform : ICloneable
davescriven's avatar
davescriven committed
10
11
    {
        public abstract Matrix Matrix { get; }
12
        public abstract string WriteToString();
13
14

    	public abstract object Clone();
15
16
17
18
19
20
21
    	
    	#region Equals implementation
    	public override bool Equals(object obj)
		{
			SvgTransform other = obj as SvgTransform;
			if (other == null)
				return false;
22
23
24
25
26
27
28
29
30
31
32
			
			var thisMatrix = this.Matrix.Elements;
			var otherMatrix = other.Matrix.Elements;
			
			for (int i = 0; i < 6; i++) 
			{
				if(thisMatrix[i] != otherMatrix[i])
					return false;
			}
			
			return true;
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
		}
    	
    	public override int GetHashCode()
		{
    		int hashCode = this.Matrix.GetHashCode();
			return hashCode;
		}

    	
		public static bool operator ==(SvgTransform lhs, SvgTransform rhs)
		{
			if (ReferenceEquals(lhs, rhs))
				return true;
			if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
				return false;
			return lhs.Equals(rhs);
		}
    	
		public static bool operator !=(SvgTransform lhs, SvgTransform rhs)
		{
			return !(lhs == rhs);
		}
    	#endregion

Eric Domke's avatar
Eric Domke committed
57
58
59
60
        public override string ToString()
        {
            return WriteToString();
        }
davescriven's avatar
davescriven committed
61
62
    }
}