GraphicsItem.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*******************************************************************************
  2. * Copyright(c) 2012 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:LayoutItem.cs
  5. * 2.功能描述:全部LayoutItem的基类(定义为abstract)
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 欧阳涛 2012/09/14 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Drawing;
  12. namespace Dongke.WinForm.Controls.InvoiceLayout
  13. {
  14. [Serializable]
  15. public abstract class GraphicsItem : LayoutItem
  16. {
  17. #region 成员变量
  18. protected Color _fillColor = Color.Black; // 背景填充色
  19. protected bool _isTransparent = true; // 背景透明
  20. protected Color _lineColor = Color.Black; // 边框色
  21. protected float _lineWidth = 0.1f; // 边框宽 (mm単位)
  22. protected float _lineWidthDraw = 0.1f; // 边框宽 - 绘制用 (mm単位)
  23. #endregion 成员变量
  24. #region 属性
  25. /// <summary>
  26. /// 获取或设置Item的边框颜色。
  27. /// </summary>
  28. public Color LineColor
  29. {
  30. get
  31. {
  32. return _lineColor;
  33. }
  34. set
  35. {
  36. if (!value.Equals(_lineColor))
  37. {
  38. _lineColor = value;
  39. //SetShapeProperty(GetZoom());
  40. //if (Owner != null)
  41. //{
  42. // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  43. //}
  44. }
  45. }
  46. }
  47. /// <summary>
  48. /// 获取或设置Item的边框宽度。
  49. /// </summary>
  50. /// <remarks>
  51. /// 设置小于0时,不显示边框。
  52. /// </remarks>
  53. public float LineWidth
  54. {
  55. get
  56. {
  57. return _lineWidth;
  58. }
  59. set
  60. {
  61. if (value < 0)
  62. {
  63. return;
  64. }
  65. if (value != _lineWidth)
  66. {
  67. _lineWidth = value;
  68. //float zoom = GetZoom();
  69. //_lineWidthDraw = _lineWidth * zoom;
  70. //SetShapeProperty(zoom);
  71. //if (Owner != null)
  72. //{
  73. // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  74. //}
  75. }
  76. }
  77. }
  78. /// <summary>
  79. /// 获取或设置Item的背景填充色。
  80. /// </summary>
  81. public Color FillColor
  82. {
  83. get
  84. {
  85. return _fillColor;
  86. }
  87. set
  88. {
  89. if (!value.Equals(_fillColor))
  90. {
  91. _fillColor = value;
  92. //SetShapeProperty(GetZoom());
  93. //if (Owner != null)
  94. //{
  95. // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  96. //}
  97. }
  98. }
  99. }
  100. /// <summary>
  101. /// 获取或设置Item的背景是否透明。
  102. /// </summary>
  103. public bool Transparent
  104. {
  105. get
  106. {
  107. return _isTransparent;
  108. }
  109. set
  110. {
  111. if (value != _isTransparent)
  112. {
  113. _isTransparent = value;
  114. //SetShapeProperty(GetZoom());
  115. //if (Owner != null)
  116. //{
  117. // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  118. //}
  119. }
  120. }
  121. }
  122. #endregion 属性
  123. #region 构造函数
  124. /// <summary>
  125. /// 构造函数
  126. /// </summary>
  127. /// <param name="box">Layoutbox</param>
  128. /// <param name="itemType">item类别</param>
  129. internal GraphicsItem(/*LayoutBox box, */ItemType itemType)
  130. : base(/*box, */itemType)
  131. {
  132. //_width = LayoutConsts.SHAPE_ITEM_SIZE_DEFAULT_WIDTH;
  133. //_height = LayoutConsts.SHAPE_ITEM_SIZE_DEFAULT_HEIGHT;
  134. }
  135. #endregion 构造函数
  136. #region 函数
  137. ///// <summary>
  138. ///// 显示Item属性设置画面
  139. ///// </summary>
  140. ///// <returns>
  141. ///// DialogResult.OK:选中的Item有效,设置成功<br/>
  142. ///// DialogResult.Cancel:选中的Item有效,取消设置<br/>
  143. ///// DialogResult.None:LayoutBox不是编辑模式,或选中的Item不是一个
  144. ///// </returns>
  145. //protected override DialogResult ShowItemPropertyDialogInner()
  146. //{
  147. // using (GraphicsItemSetting itemPropertySetting = new GraphicsItemSetting())
  148. // {
  149. // itemPropertySetting.ShapeLocationX = Left;
  150. // itemPropertySetting.ShapeLocationY = Top;
  151. // itemPropertySetting.ShapeWidth = Width;
  152. // itemPropertySetting.ShapeHeight = Height;
  153. // itemPropertySetting.LineColor = LineColor;
  154. // itemPropertySetting.FillColor = FillColor;
  155. // itemPropertySetting.LineWidth = LineWidth;
  156. // itemPropertySetting.Transparent = Transparent;
  157. // DialogResult result = itemPropertySetting.ShowDialog();
  158. // if (result == DialogResult.OK)
  159. // {
  160. // Left = itemPropertySetting.ShapeLocationX;
  161. // Top = itemPropertySetting.ShapeLocationY;
  162. // Width = itemPropertySetting.ShapeWidth;
  163. // Height = itemPropertySetting.ShapeHeight;
  164. // LineColor = itemPropertySetting.LineColor;
  165. // FillColor = itemPropertySetting.FillColor;
  166. // LineWidth = itemPropertySetting.LineWidth;
  167. // Transparent = itemPropertySetting.Transparent;
  168. // ResetItemFrame();
  169. // SetDrawProperty();
  170. // Owner.Dirty = true;
  171. // }
  172. // return result;
  173. // }
  174. //}
  175. ///// <summary>
  176. ///// 初始化Item图形属性
  177. ///// </summary>
  178. //internal override void SetShapeProperty(float zoom)
  179. //{
  180. // if (_shape != null)
  181. // {
  182. // if (_lineWidthDraw > 0)
  183. // {
  184. // _shape.BorderStyle = System.Drawing.Drawing2D.DashStyle.Solid;
  185. // _shape.BorderColor = _lineColor;
  186. // _shape.BorderWidth = LayoutCommon.MillimeterToPixel(_lineWidthDraw);
  187. // }
  188. // else
  189. // {
  190. // _shape.BorderStyle = System.Drawing.Drawing2D.DashStyle.Custom;
  191. // _shape.BorderWidth = 1;
  192. // }
  193. // if (_simpleShape != null)
  194. // {
  195. // _simpleShape.FillStyle = (_isTransparent) ? FillStyle.Transparent : FillStyle.Solid;
  196. // _simpleShape.FillColor = _fillColor;
  197. // }
  198. // }
  199. //}
  200. ///// <summary>
  201. ///// 初始化Item绘制用属性
  202. ///// </summary>
  203. //internal override float SetDrawProperty()
  204. //{
  205. // float zoom = base.SetDrawProperty();
  206. // _lineWidthDraw = _lineWidth * zoom;
  207. // SetShapeProperty(zoom);
  208. // return zoom;
  209. //}
  210. #endregion 函数
  211. }
  212. }