BrushExt.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*******************************************************************************************
  2. ** **************************************************************** **
  3. ** **********File Name: BrushExt.cs Version 1.0, 8 November 2004** **
  4. ** ****************Author: Kanti Surapaneni************************ **
  5. **
  6. **
  7. ** This class represents the functionality of a brush object. This class extends the **
  8. ** SolidBrush class from the System.Drawing. The BrushExt class includes methods for **
  9. ** getting and setting the properties of the brush object. **
  10. ** It encapsulates functionality for defining the color of the brush object. **
  11. ** **
  12. ********************************************************************************************/
  13. ///
  14. using System;
  15. using System.Drawing;
  16. using System.Drawing.Drawing2D;
  17. using System.ComponentModel;
  18. using System.Drawing.Design;
  19. using System.Collections;
  20. // Namespace BaseDef, include BrushExt, PenExt, FontData
  21. namespace GraEditor.BaseDef
  22. {
  23. /// <summary>
  24. /// Define our own Brush class, use it to store the color
  25. /// </summary>
  26. public class BrushExt
  27. {
  28. static BrushExt()
  29. {
  30. solidBrush = new SolidBrush(Color.Transparent);//construct a new brush
  31. }
  32. public BrushExt()
  33. {
  34. this.Color = Color.DarkBlue;
  35. }
  36. public BrushExt(Color color)//set color
  37. : this()
  38. {
  39. this.Color = color;
  40. }
  41. private static SolidBrush solidBrush;// static SolidBrush variable
  42. public Brush Brush //send the color of BrushExt to Solidbrush variable
  43. {
  44. get
  45. {
  46. solidBrush.Color = this.Color;//send color to brush variable
  47. return solidBrush;
  48. }
  49. set // set the color of BrushExt with Brush's color
  50. {
  51. SolidBrush b = value as SolidBrush; //Income value will change to SolidBrush type
  52. if(b == null)
  53. return;
  54. this.Color = b.Color;
  55. }
  56. }
  57. protected Color color;//color property of BrushExt
  58. public Color Color
  59. {
  60. get { return color; }
  61. set
  62. {
  63. //if( value == this.color)
  64. // return;
  65. this.color = value;
  66. //solidBrush.Color = this.color;
  67. }
  68. }
  69. }
  70. }