DrawBase.cs
上传用户:jx_fiona
上传日期:2014-03-08
资源大小:1387k
文件大小:3k
源码类别:

打印编程

开发平台:

Others

  1. using System;
  2. using System.Drawing;
  3. using System.Drawing.Printing;
  4. namespace GoldPrinter
  5. {
  6. /// <summary>
  7. /// 绘制基本类,无法实例化。接口为IDraw(绘制接口,记法:在绘图表面Graphics绘制矩阵区域Rectangle用指定的画笔Brush、Pen绘制Draw())
  8. /// 
  9. /// 作 者:长江支流(周方勇)
  10. /// Email:flygoldfish@163.com  QQ:150439795
  11. /// 网 址:www.webmis.com.cn
  12. /// ★★★★★您可以免费使用此程序,但是请您完整保留此说明,以维护知识产权★★★★★
  13. /// 
  14. /// </summary>
  15. public abstract class DrawBase:IDraw,IDisposable
  16. {
  17. //************字    段************
  18. private Graphics _graphics; //绘图表面
  19. private Rectangle _rectangle; //绘制区
  20.         //绘笔
  21.         private Brush _brush;
  22.         private Pen _pen;
  23.         #region IDraw 成员
  24.         /// <summary>
  25.         /// 获取或设置绘图表面
  26.         /// </summary>
  27.         public Graphics Graphics
  28.         {
  29.             get
  30.             {
  31.                 return this._graphics;
  32.             }
  33.             set
  34.             {
  35.                 this._graphics = value;
  36.             }
  37.         }
  38.         /// <summary>
  39.         /// 获取或设置绘制区域
  40.         /// </summary>
  41.         public System.Drawing.Rectangle Rectangle
  42.         {
  43.             get
  44.             {
  45.                 return _rectangle;
  46.             }
  47.             set
  48.             {
  49.                 _rectangle = value;
  50.             }
  51.         }
  52. /// <summary>
  53. /// 画笔
  54. /// </summary>
  55.         public Pen Pen
  56.         {
  57.             get
  58.             {
  59.                 return _pen;
  60.             }
  61.             set
  62.             {
  63.                 if (value != null)
  64.                 {
  65.                     _pen = value;
  66.                 }
  67.             }
  68.         }
  69. /// <summary>
  70. /// 画刷
  71. /// </summary>
  72. public Brush Brush
  73. {
  74. get
  75. {
  76. return _brush;
  77. }
  78. set
  79. {
  80. if (value != null)
  81. {
  82. _brush = value;
  83. }
  84. }
  85. }
  86. /// <summary>
  87.         /// 绘制,抽象方法,必须由子类具体实现
  88.         /// </summary>
  89.         public abstract void Draw();
  90.         #endregion
  91. /// <summary>
  92. /// 绘制基本类,无法实例化
  93. /// </summary>
  94.         public DrawBase()
  95. {
  96. _rectangle = new Rectangle(0,0,0,0);
  97. _brush = Brushes.Black;
  98. _pen = new Pen(_brush);  
  99.             _pen = Pens.Black;            
  100. }
  101.         #region IDisposable 成员
  102. /// <summary>
  103. /// 释放对象使用的所有资源
  104. /// </summary>
  105.         public virtual void Dispose()
  106.         {
  107. //注意:只能释放自己创建的对象,而不要释放了属性对象(即由外部传过来的对象)
  108. /*
  109.             _graphics.Dispose();
  110. */
  111.             _brush.Dispose();
  112.             _pen.Dispose();
  113.         }
  114.         #endregion
  115. }//End Class
  116. }//End NameSpace