HatchBrush.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // System.Drawing.Drawing2D.HatchBrush.cs
  3. //
  4. // Authors:
  5. // Dennis Hayes ([email protected])
  6. // Ravindra ([email protected])
  7. //
  8. // (C) 2002/3 Ximian, Inc
  9. // (C) 2004 Novell, Inc.
  10. //
  11. //
  12. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  13. //
  14. // Permission is hereby granted, free of charge, to any person obtaining
  15. // a copy of this software and associated documentation files (the
  16. // "Software"), to deal in the Software without restriction, including
  17. // without limitation the rights to use, copy, modify, merge, publish,
  18. // distribute, sublicense, and/or sell copies of the Software, and to
  19. // permit persons to whom the Software is furnished to do so, subject to
  20. // the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be
  23. // included in all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  26. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  27. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  28. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  29. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  30. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  31. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  32. //
  33. using System;
  34. namespace System.Drawing.Drawing2D
  35. {
  36. /// <summary>
  37. /// Summary description for HatchBrush.
  38. /// </summary>
  39. public sealed class HatchBrush : Brush
  40. {
  41. internal HatchBrush (IntPtr ptr) : base (ptr)
  42. {
  43. }
  44. public HatchBrush (HatchStyle hatchStyle, Color foreColor)
  45. : this (hatchStyle, foreColor, Color.Black)
  46. {
  47. }
  48. public HatchBrush(HatchStyle hatchStyle, Color foreColor, Color backColor)
  49. {
  50. Status status = GDIPlus.GdipCreateHatchBrush (hatchStyle, foreColor.ToArgb (), backColor.ToArgb (), out nativeObject);
  51. GDIPlus.CheckStatus (status);
  52. }
  53. public Color BackgroundColor {
  54. get {
  55. int argb;
  56. Status status = GDIPlus.GdipGetHatchBackgroundColor (nativeObject, out argb);
  57. GDIPlus.CheckStatus (status);
  58. return Color.FromArgb (argb);
  59. }
  60. }
  61. public Color ForegroundColor {
  62. get {
  63. int argb;
  64. Status status = GDIPlus.GdipGetHatchForegroundColor (nativeObject, out argb);
  65. GDIPlus.CheckStatus (status);
  66. return Color.FromArgb (argb);
  67. }
  68. }
  69. public HatchStyle HatchStyle {
  70. get {
  71. HatchStyle hatchStyle;
  72. Status status = GDIPlus.GdipGetHatchStyle (nativeObject, out hatchStyle);
  73. GDIPlus.CheckStatus (status);
  74. return hatchStyle;
  75. }
  76. }
  77. public override object Clone ()
  78. {
  79. IntPtr clonePtr;
  80. Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
  81. GDIPlus.CheckStatus (status);
  82. HatchBrush clone = new HatchBrush (clonePtr);
  83. return clone;
  84. }
  85. }
  86. }