/*******************************************************************************
* 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 属性
///
/// 获取或设置Item的边框颜色。
///
public Color LineColor
{
get
{
return _lineColor;
}
set
{
if (!value.Equals(_lineColor))
{
_lineColor = value;
//SetShapeProperty(GetZoom());
//if (Owner != null)
//{
// Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
//}
}
}
}
///
/// 获取或设置Item的边框宽度。
///
///
/// 设置小于0时,不显示边框。
///
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);
//}
}
}
}
///
/// 获取或设置Item的背景填充色。
///
public Color FillColor
{
get
{
return _fillColor;
}
set
{
if (!value.Equals(_fillColor))
{
_fillColor = value;
//SetShapeProperty(GetZoom());
//if (Owner != null)
//{
// Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
//}
}
}
}
///
/// 获取或设置Item的背景是否透明。
///
public bool Transparent
{
get
{
return _isTransparent;
}
set
{
if (value != _isTransparent)
{
_isTransparent = value;
//SetShapeProperty(GetZoom());
//if (Owner != null)
//{
// Owner.SetItemChangedArgs(this, ItemChangeType.Modified);
//}
}
}
}
#endregion 属性
#region 构造函数
///
/// 构造函数
///
/// Layoutbox
/// item类别
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 函数
/////
///// 显示Item属性设置画面
/////
/////
///// DialogResult.OK:选中的Item有效,设置成功
///// DialogResult.Cancel:选中的Item有效,取消设置
///// DialogResult.None:LayoutBox不是编辑模式,或选中的Item不是一个
/////
//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;
// }
//}
/////
///// 初始化Item图形属性
/////
//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;
// }
// }
//}
/////
///// 初始化Item绘制用属性
/////
//internal override float SetDrawProperty()
//{
// float zoom = base.SetDrawProperty();
// _lineWidthDraw = _lineWidth * zoom;
// SetShapeProperty(zoom);
// return zoom;
//}
#endregion 函数
}
}