| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
-
- using System.Drawing;
- using System.Windows.Forms;
- namespace Dongke.WinForm.Controls.InvoiceLayout
- {
- internal partial class GraphicsItemSetting : Setting
- {
- #region 成员变量
- private bool _isTransparent = false; // 背景是否透明
- private Color _fillColor = Color.Black; // 背景颜色
- #endregion 成员变量
- #region 属性
- /// <summary>
- /// X(mm)
- /// </summary>
- public float ShapeLocationX
- {
- get
- {
- return System.Convert.ToSingle(numlocationX.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numlocationX.Minimum)
- {
- d = numlocationX.Minimum;
- }
- else if (numlocationX.Maximum < d)
- {
- d = numlocationX.Maximum;
- }
- numlocationX.Value = d;
- }
- }
- /// <summary>
- /// Y(mm)
- /// </summary>
- public float ShapeLocationY
- {
- get
- {
- return System.Convert.ToSingle(numlocationY.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numlocationY.Minimum)
- {
- d = numlocationY.Minimum;
- }
- else if (numlocationY.Maximum < d)
- {
- d = numlocationY.Maximum;
- }
- numlocationY.Value = d;
- }
- }
- /// <summary>
- /// 宽(mm)
- /// </summary>
- public float ShapeWidth
- {
- get
- {
- return System.Convert.ToSingle(numWidth.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numWidth.Minimum)
- {
- d = numWidth.Minimum;
- }
- else if (numWidth.Maximum < d)
- {
- d = numWidth.Maximum;
- }
- numWidth.Value = d;
- }
- }
- /// <summary>
- /// 高(mm)
- /// </summary>
- public float ShapeHeight
- {
- get
- {
- return System.Convert.ToSingle(numHeight.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numHeight.Minimum)
- {
- d = numHeight.Minimum;
- }
- else if (numHeight.Maximum < d)
- {
- d = numHeight.Maximum;
- }
- numHeight.Value = d;
- }
- }
- /// <summary>
- /// 线的颜色
- /// </summary>
- public Color LineColor
- {
- get
- {
- return lblLineColor.BackColor;
- }
- set
- {
- lblLineColor.BackColor = value;
- if (lblLineColor.BackColor != Color.White)
- {
- lblLineBColor.BackColor = lblLineColor.BackColor;
- }
- else
- {
- lblLineBColor.BackColor = Color.Black;
- }
- }
- }
- /// <summary>
- /// 背景颜色
- /// </summary>
- public Color FillColor
- {
- get
- {
- return _fillColor;
- }
- set
- {
- _fillColor = value;
- SetFillColor();
- }
- }
- /// <summary>
- /// 线宽
- /// </summary>
- public float LineWidth
- {
- get
- {
- return System.Convert.ToSingle(numLineWidth.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numLineWidth.Minimum)
- {
- d = numLineWidth.Minimum;
- }
- else if (numLineWidth.Maximum < d)
- {
- d = numLineWidth.Maximum;
- }
- numLineWidth.Value = d;
- }
- }
- /// <summary>
- /// 背景是否透明
- /// </summary>
- public bool Transparent
- {
- get
- {
- return _isTransparent;
- }
- set
- {
- _isTransparent = value;
- SetFillColor();
- }
- }
- /// <summary>
- /// 线型图形
- /// </summary>
- public bool Line
- {
- get
- {
- return txtFillColor.Enabled;
- }
- set
- {
- txtFillColor.Enabled = !value;
- lblFillColor.Enabled = !value;
- lblFillBColor.Enabled = !value;
- btnSelectFillColor.Enabled = !value;
- btnFillTransparent.Enabled = !value;
- numWidth.Minimum = -999.9m;
- numHeight.Minimum = -999.9m;
- numHeight.Validating += new System.ComponentModel.CancelEventHandler(this.numHeight_Validating);
- numWidth.Validating += new System.ComponentModel.CancelEventHandler(this.numWidth_Validating);
- }
- }
- #endregion 属性
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public GraphicsItemSetting()
- {
- InitializeComponent();
- }
- #endregion 构造函数
- #region 函数
- /// <summary>
- /// 设置背景颜色
- /// </summary>
- private void SetFillColor()
- {
- if (_isTransparent)
- {
- lblFillColor.BackColor = Color.Empty;
- lblFillBColor.BackColor = Color.Empty;
- }
- else
- {
- lblFillColor.BackColor = _fillColor;
- if (_fillColor != Color.White)
- {
- lblFillBColor.BackColor = _fillColor;
- }
- else
- {
- lblFillBColor.BackColor = Color.Black;
- }
- }
- }
- #endregion 函数
- #region 事件处理
- /// <summary>
- /// 设置线的颜色
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void btnSelectLineColor_Click(object sender, System.EventArgs e)
- {
- colorDialog.Color = (lblLineColor.BackColor == Color.Transparent) ? Color.Empty : lblLineColor.BackColor;
- if (colorDialog.ShowDialog() == DialogResult.OK)
- {
- LineColor = colorDialog.Color;
- }
- }
- /// <summary>
- /// 设置背景颜色
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void btnSelectFillColor_Click(object sender, System.EventArgs e)
- {
- colorDialog.Color = _isTransparent ? Color.Empty : _fillColor;
- if (colorDialog.ShowDialog() == DialogResult.OK)
- {
- _fillColor = colorDialog.Color;
- Transparent = false;
- }
- }
- /// <summary>
- /// 设置线段是否透明
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void btnSelectLineTransparent_Click(object sender, System.EventArgs e)
- {
- lblLineColor.BackColor = Color.Transparent;
- lblLineBColor.BackColor = Color.Transparent;
- }
- /// <summary>
- /// 设置背景是否透明
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void btnFillTransparent_Click(object sender, System.EventArgs e)
- {
- Transparent = true;
- }
- /// <summary>
- /// 图形的宽度验证
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numWidth_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (numHeight.Value == 0 && numWidth.Value == 0)
- {
- numWidth.Value = 0.1m;
- }
- }
- /// <summary>
- /// 图形的高度验证
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numHeight_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (numHeight.Value == 0 && numWidth.Value == 0)
- {
- numHeight.Value = 0.1m;
- }
- }
- #endregion 事件处理
- }
- }
|