| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- /*******************************************************************************
- * Copyright(c) 2012 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:LayoutItem.cs
- * 2.功能描述:全部LayoutItem的基类(定义为abstract)
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 欧阳涛 2012/09/14 1.00 新建
- *******************************************************************************/
- using System;
- using System.Drawing;
- namespace Dongke.WinForm.Controls.InvoiceLayout
- {
- [Serializable]
- public abstract class GraphicsItem : LayoutItem
- {
- #region 成员变量
- protected Color _fillColor = Color.Black; // 背景填充色
- protected bool _isTransparent = true; // 背景透明
- protected Color _lineColor = Color.Black; // 边框色
- protected float _lineWidth = 0.1f; // 边框宽 (mm単位)
- protected float _lineWidthDraw = 0.1f; // 边框宽 - 绘制用 (mm単位)
- #endregion 成员变量
- #region 属性
- /// <summary>
- /// 获取或设置Item的边框颜色。
- /// </summary>
- public Color LineColor
- {
- get
- {
- return _lineColor;
- }
- set
- {
- if (!value.Equals(_lineColor))
- {
- _lineColor = value;
- //SetShapeProperty(GetZoom());
- //if (Owner != null)
- //{
- // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
- //}
- }
- }
- }
- /// <summary>
- /// 获取或设置Item的边框宽度。
- /// </summary>
- /// <remarks>
- /// 设置小于0时,不显示边框。
- /// </remarks>
- public float LineWidth
- {
- get
- {
- return _lineWidth;
- }
- set
- {
- if (value < 0)
- {
- return;
- }
- if (value != _lineWidth)
- {
- _lineWidth = value;
- //float zoom = GetZoom();
- //_lineWidthDraw = _lineWidth * zoom;
- //SetShapeProperty(zoom);
- //if (Owner != null)
- //{
- // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
- //}
- }
- }
- }
- /// <summary>
- /// 获取或设置Item的背景填充色。
- /// </summary>
- public Color FillColor
- {
- get
- {
- return _fillColor;
- }
- set
- {
- if (!value.Equals(_fillColor))
- {
- _fillColor = value;
- //SetShapeProperty(GetZoom());
- //if (Owner != null)
- //{
- // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
- //}
- }
- }
- }
- /// <summary>
- /// 获取或设置Item的背景是否透明。
- /// </summary>
- public bool Transparent
- {
- get
- {
- return _isTransparent;
- }
- set
- {
- if (value != _isTransparent)
- {
- _isTransparent = value;
- //SetShapeProperty(GetZoom());
- //if (Owner != null)
- //{
- // Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
- //}
- }
- }
- }
- #endregion 属性
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="box">Layoutbox</param>
- /// <param name="itemType">item类别</param>
- internal GraphicsItem(/*LayoutBox box, */ItemType itemType)
- : base(/*box, */itemType)
- {
- //_width = LayoutConsts.SHAPE_ITEM_SIZE_DEFAULT_WIDTH;
- //_height = LayoutConsts.SHAPE_ITEM_SIZE_DEFAULT_HEIGHT;
- }
- #endregion 构造函数
- #region 函数
- ///// <summary>
- ///// 显示Item属性设置画面
- ///// </summary>
- ///// <returns>
- ///// DialogResult.OK:选中的Item有效,设置成功<br/>
- ///// DialogResult.Cancel:选中的Item有效,取消设置<br/>
- ///// DialogResult.None:LayoutBox不是编辑模式,或选中的Item不是一个
- ///// </returns>
- //protected override DialogResult ShowItemPropertyDialogInner()
- //{
- // using (GraphicsItemSetting itemPropertySetting = new GraphicsItemSetting())
- // {
- // itemPropertySetting.ShapeLocationX = Left;
- // itemPropertySetting.ShapeLocationY = Top;
- // itemPropertySetting.ShapeWidth = Width;
- // itemPropertySetting.ShapeHeight = Height;
- // itemPropertySetting.LineColor = LineColor;
- // itemPropertySetting.FillColor = FillColor;
- // itemPropertySetting.LineWidth = LineWidth;
- // itemPropertySetting.Transparent = Transparent;
- // DialogResult result = itemPropertySetting.ShowDialog();
- // if (result == DialogResult.OK)
- // {
- // Left = itemPropertySetting.ShapeLocationX;
- // Top = itemPropertySetting.ShapeLocationY;
- // Width = itemPropertySetting.ShapeWidth;
- // Height = itemPropertySetting.ShapeHeight;
- // LineColor = itemPropertySetting.LineColor;
- // FillColor = itemPropertySetting.FillColor;
- // LineWidth = itemPropertySetting.LineWidth;
- // Transparent = itemPropertySetting.Transparent;
- // ResetItemFrame();
- // SetDrawProperty();
- // Owner.Dirty = true;
- // }
- // return result;
- // }
- //}
- ///// <summary>
- ///// 初始化Item图形属性
- ///// </summary>
- //internal override void SetShapeProperty(float zoom)
- //{
- // if (_shape != null)
- // {
- // if (_lineWidthDraw > 0)
- // {
- // _shape.BorderStyle = System.Drawing.Drawing2D.DashStyle.Solid;
- // _shape.BorderColor = _lineColor;
- // _shape.BorderWidth = LayoutCommon.MillimeterToPixel(_lineWidthDraw);
- // }
- // else
- // {
- // _shape.BorderStyle = System.Drawing.Drawing2D.DashStyle.Custom;
- // _shape.BorderWidth = 1;
- // }
- // if (_simpleShape != null)
- // {
- // _simpleShape.FillStyle = (_isTransparent) ? FillStyle.Transparent : FillStyle.Solid;
- // _simpleShape.FillColor = _fillColor;
- // }
- // }
- //}
- ///// <summary>
- ///// 初始化Item绘制用属性
- ///// </summary>
- //internal override float SetDrawProperty()
- //{
- // float zoom = base.SetDrawProperty();
- // _lineWidthDraw = _lineWidth * zoom;
- // SetShapeProperty(zoom);
- // return zoom;
- //}
- #endregion 函数
- }
- }
|