ImageItem.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*******************************************************************************
  2. * Copyright(c) 2012 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:ImageItem.cs
  5. * 2.功能描述:图片Item
  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 class ImageItem : LayoutItem
  16. {
  17. #region 成员变量
  18. private string _fileName = string.Empty; // 图片文件的路径(全名)
  19. private Image _image; // 图片
  20. #endregion 成员变量
  21. #region 属性
  22. /// <summary>
  23. /// 获取或设置图片文件的路径(全名)
  24. /// </summary>
  25. public string FileName
  26. {
  27. get
  28. {
  29. return _fileName;
  30. }
  31. set
  32. {
  33. if (string.IsNullOrEmpty(value))
  34. {
  35. value = string.Empty;
  36. }
  37. if (!value.Equals(_fileName))
  38. {
  39. _fileName = value;
  40. //if (Owner != null)
  41. //{
  42. // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  43. //}
  44. }
  45. }
  46. }
  47. /// <summary>
  48. /// 获取或设置图片
  49. /// </summary>
  50. public Image Image
  51. {
  52. get
  53. {
  54. return _image;
  55. }
  56. set
  57. {
  58. _image = value;
  59. //if (SimpleShape != null)
  60. //{
  61. // SimpleShape.BackgroundImageLayout = ImageLayout.Stretch;
  62. // SimpleShape.BackgroundImage = _image;
  63. //}
  64. //if (Owner != null)
  65. //{
  66. // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
  67. //}
  68. }
  69. }
  70. #endregion 属性
  71. #region 构造函数
  72. ///// <summary>
  73. ///// 构造函数
  74. ///// </summary>
  75. //internal ImageItem()
  76. // : this(null)
  77. //{
  78. //}
  79. /// <summary>
  80. /// 构造函数
  81. /// </summary>
  82. /// <param name="box">Layoutbox</param>
  83. /// <param name="itemType">item类别</param>
  84. internal ImageItem(/*LayoutBox box*/)
  85. : base(/*box, */ItemType.Image)
  86. {
  87. //_width = LayoutConsts.SHAPE_ITEM_SIZE_DEFAULT_WIDTH;
  88. //_height = LayoutConsts.SHAPE_ITEM_SIZE_DEFAULT_HEIGHT;
  89. //if (box != null)
  90. //{
  91. // if (_simpleShape != null)
  92. // {
  93. // _simpleShape.BackgroundImageLayout = ImageLayout.Stretch;
  94. // _simpleShape.BackgroundImage = _image;
  95. // }
  96. //}
  97. }
  98. #endregion 构造函数
  99. #region 函数
  100. ///// <summary>
  101. ///// 显示Item属性设置画面
  102. ///// </summary>
  103. ///// <returns>
  104. ///// DialogResult.OK:选中的Item有效,设置成功<br/>
  105. ///// DialogResult.Cancel:选中的Item有效,取消设置<br/>
  106. ///// DialogResult.None:LayoutBox不是编辑模式,或选中的Item不是一个
  107. ///// </returns>
  108. //protected override DialogResult ShowItemPropertyDialogInner()
  109. //{
  110. // using (ImageItemSetting itemPropertySetting = new ImageItemSetting())
  111. // {
  112. // itemPropertySetting.ImageLocationX = Left;
  113. // itemPropertySetting.ImageLocationY = Top;
  114. // itemPropertySetting.ImageWidth = Width;
  115. // itemPropertySetting.ImageHeight = Height;
  116. // itemPropertySetting.SideRatioFixed = SideRatioFixed;
  117. // itemPropertySetting.FileName = FileName;
  118. // itemPropertySetting.Image = Image;
  119. // DialogResult result = itemPropertySetting.ShowDialog();
  120. // if (result == DialogResult.OK)
  121. // {
  122. // Left = itemPropertySetting.ImageLocationX;
  123. // Top = itemPropertySetting.ImageLocationY;
  124. // Width = itemPropertySetting.ImageWidth;
  125. // Height = itemPropertySetting.ImageHeight;
  126. // SideRatioFixed = itemPropertySetting.SideRatioFixed;
  127. // ResetItemFrame();
  128. // SetDrawProperty();
  129. // Owner.Dirty = true;
  130. // }
  131. // return result;
  132. // }
  133. //}
  134. ///// <summary>
  135. ///// Item初始化
  136. ///// </summary>
  137. ///// <param name="box">LayoutBox</param>
  138. ///// <param name="isNewID">是否生成新ID</param>
  139. ///// <returns>是否成功</returns>
  140. //internal override bool Init(LayoutBox box, bool isNewID)
  141. //{
  142. // bool isInit = base.Init(box, isNewID);
  143. // if (isInit)
  144. // {
  145. // if (_simpleShape != null)
  146. // {
  147. // _simpleShape.BackgroundImageLayout = ImageLayout.Stretch;
  148. // _simpleShape.BackgroundImage = _image;
  149. // }
  150. // }
  151. // return isInit;
  152. //}
  153. #endregion 函数
  154. }
  155. }