GraphicsPathIterator.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // System.Drawing.Drawing2D.GraphicsPathIterator.cs
  3. //
  4. // Author:
  5. // Dennis Hayes ([email protected])
  6. // Duncan Mak ([email protected])
  7. //
  8. // (C) 2002/3 Ximian, Inc
  9. //
  10. //
  11. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  12. //
  13. // Permission is hereby granted, free of charge, to any person obtaining
  14. // a copy of this software and associated documentation files (the
  15. // "Software"), to deal in the Software without restriction, including
  16. // without limitation the rights to use, copy, modify, merge, publish,
  17. // distribute, sublicense, and/or sell copies of the Software, and to
  18. // permit persons to whom the Software is furnished to do so, subject to
  19. // the following conditions:
  20. //
  21. // The above copyright notice and this permission notice shall be
  22. // included in all copies or substantial portions of the Software.
  23. //
  24. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. //
  32. using System;
  33. using System.Drawing;
  34. namespace System.Drawing.Drawing2D
  35. {
  36. public sealed class GraphicsPathIterator : MarshalByRefObject, IDisposable
  37. {
  38. PointF [] _points;
  39. byte [] _types;
  40. int _count;
  41. int _current;
  42. // Constructors
  43. public GraphicsPathIterator (GraphicsPath path)
  44. {
  45. this._points = path.PathPoints;
  46. this._types = path.PathTypes;
  47. this._count = path.PointCount;
  48. this._current = 0;
  49. }
  50. // Public Properites
  51. public int Count {
  52. get {
  53. return _count;
  54. }
  55. }
  56. public int SubpathCount {
  57. get {
  58. int count = 0;
  59. foreach (byte b in _types)
  60. if (b == (byte) PathPointType.Start)
  61. count++;
  62. return count;
  63. }
  64. }
  65. // Public Methods.
  66. public int CopyData (ref PointF [] points, ref byte [] types, int startIndex, int endIndex)
  67. {
  68. for (int i = 0, j = startIndex; j < endIndex; i++, j++) {
  69. points [i] = _points [j];
  70. types [i] = _types [j];
  71. }
  72. return endIndex - startIndex;
  73. }
  74. public void Dispose ()
  75. {
  76. }
  77. ~GraphicsPathIterator ()
  78. {
  79. }
  80. public int Enumerate (ref PointF [] points, ref byte [] types)
  81. {
  82. points = _points;
  83. types = _types;
  84. return _count;
  85. }
  86. public bool HasCurve ()
  87. {
  88. foreach (byte b in _types)
  89. if (b == (byte) PathPointType.Bezier)
  90. return true;
  91. return false;
  92. }
  93. [MonoTODO]
  94. public int NextMarker (GraphicsPath path)
  95. {
  96. throw new NotImplementedException ();
  97. }
  98. [MonoTODO]
  99. public int NextMarker (out int startIndex, out int endIndex)
  100. {
  101. throw new NotImplementedException ();
  102. }
  103. [MonoTODO]
  104. public int NextPathType (out byte pathType, out int startIndex, out int endIndex)
  105. {
  106. throw new NotImplementedException ();
  107. }
  108. [MonoTODO]
  109. public int NextSubpath (GraphicsPath path, out bool isClosed)
  110. {
  111. throw new NotImplementedException ();
  112. }
  113. [MonoTODO]
  114. public int NextSubpath (out int startIndex, out int endIndex, out bool isClosed)
  115. {
  116. throw new NotImplementedException ();
  117. }
  118. public void Rewind ()
  119. {
  120. _current = 0;
  121. }
  122. }
  123. }