SvgTransform.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Drawing;
  5. using System.Drawing.Drawing2D;
  6. #pragma warning disable
  7. namespace Svg.Transforms
  8. {
  9. public abstract class SvgTransform : ICloneable
  10. {
  11. public abstract Matrix Matrix { get; }
  12. public abstract string WriteToString();
  13. public abstract object Clone();
  14. #region Equals implementation
  15. public override bool Equals(object obj)
  16. {
  17. SvgTransform other = obj as SvgTransform;
  18. if (other == null)
  19. return false;
  20. var thisMatrix = this.Matrix.Elements;
  21. var otherMatrix = other.Matrix.Elements;
  22. for (int i = 0; i < 6; i++)
  23. {
  24. if (thisMatrix[i] != otherMatrix[i])
  25. return false;
  26. }
  27. return true;
  28. }
  29. public override int GetHashCode()
  30. {
  31. int hashCode = this.Matrix.GetHashCode();
  32. return hashCode;
  33. }
  34. public static bool operator ==(SvgTransform lhs, SvgTransform rhs)
  35. {
  36. if (ReferenceEquals(lhs, rhs))
  37. return true;
  38. if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
  39. return false;
  40. return lhs.Equals(rhs);
  41. }
  42. public static bool operator !=(SvgTransform lhs, SvgTransform rhs)
  43. {
  44. return !(lhs == rhs);
  45. }
  46. #endregion
  47. public override string ToString()
  48. {
  49. return WriteToString();
  50. }
  51. }
  52. }
  53. #pragma warning restore