| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
-
- using System;
- using System.Globalization;
- namespace Dongke.WinForm.Controls.InvoiceLayout.DrawBarcode
- {
- /// <summary>
- /// 条码图片显示方式
- /// </summary>
- public enum BarcodeShowType
- {
- /// <summary>
- /// 原图
- /// </summary>
- Original = 0,
- /// <summary>
- /// 居中显示
- /// </summary>
- Show,
- /// <summary>
- /// 缩放
- /// </summary>
- Zoom,
- }
- /// <summary>
- /// 条码打印余白
- /// </summary>
- [Serializable]
- public struct BarcodeMargin
- {
- private bool _all;
- private int _top;
- private int _left;
- private int _right;
- private int _bottom;
- /// <summary>
- /// 空
- /// </summary>
- public static readonly BarcodeMargin Empty = new BarcodeMargin(0);
- /// <summary>
- /// 相同值
- /// </summary>
- public int All
- {
- get
- {
- return (this._all ? this._top : -1);
- }
- set
- {
- if (value < 0)
- {
- return;
- }
- if (!this._all || this._top != value)
- {
- this._all = true;
- this._bottom = value;
- this._right = value;
- this._left = value;
- this._top = value;
- }
- }
- }
- /// <summary>
- /// 底边余白
- /// </summary>
- public int Bottom
- {
- get
- {
- //if (this._all)
- //{
- // return this._top;
- //}
- return this._bottom;
- }
- set
- {
- if (value < 0)
- {
- return;
- }
- if (this._bottom != value)
- {
- this._bottom = value;
- this.SetAll();
- }
- }
- }
- /// <summary>
- /// 左侧余白
- /// </summary>
- public int Left
- {
- get
- {
- //if (this._all)
- //{
- // return this._top;
- //}
- return this._left;
- }
- set
- {
- if (value < 0)
- {
- return;
- }
- if (this._left != value)
- {
- this._left = value;
- this.SetAll();
- }
- }
- }
- /// <summary>
- /// 右余白
- /// </summary>
- public int Right
- {
- get
- {
- //if (this._all)
- //{
- // return this._top;
- //}
- return this._right;
- }
- set
- {
- if (value < 0)
- {
- return;
- }
- if (this._right != value)
- {
- this._right = value;
- this.SetAll();
- }
- }
- }
- /// <summary>
- /// 顶边余白
- /// </summary>
- public int Top
- {
- get
- {
- return this._top;
- }
- set
- {
- if (value < 0)
- {
- return;
- }
- if (this._top != value)
- {
- this._top = value;
- this.SetAll();
- }
- }
- }
- /// <summary>
- /// 横向
- /// </summary>
- public int Horizontal
- {
- get
- {
- return this.Left + this.Right;
- }
- }
- /// <summary>
- /// 纵向
- /// </summary>
- public int Vertical
- {
- get
- {
- return this.Top + this.Bottom;
- }
- }
- /// <summary>
- /// 条码打印余白
- /// </summary>
- /// <param name="all"></param>
- public BarcodeMargin(int all)
- {
- //if (all < 0)
- //{
- // all = 0;
- //}
- this._all = true;
- this._bottom = all;
- this._right = all;
- this._left = all;
- this._top = all;
- }
- /// <summary>
- /// 条码打印余白
- /// </summary>
- /// <param name="left"></param>
- /// <param name="top"></param>
- /// <param name="right"></param>
- /// <param name="bottom"></param>
- public BarcodeMargin(int left, int top, int right, int bottom)
- {
- //if (left < 0)
- //{
- // left = 0;
- //}
- //if (top < 0)
- //{
- // top = 0;
- //}
- //if (right < 0)
- //{
- // right = 0;
- //}
- //if (bottom < 0)
- //{
- // bottom = 0;
- //}
- this._top = top;
- this._left = left;
- this._right = right;
- this._bottom = bottom;
- this._all = (this._top == this._left && this._top == this._right && this._top == this._bottom);
- }
- private void SetAll()
- {
- this._all = (this._top == this._left && this._top == this._right && this._top == this._bottom);
- }
- /// <summary>
- /// ToString
- /// </summary>
- /// <returns></returns>
- public override string ToString()
- {
- return string.Concat(new string[]
- {
- "Margin={Left=",
- this.Left.ToString(CultureInfo.CurrentCulture),
- ",Top=",
- this.Top.ToString(CultureInfo.CurrentCulture),
- ",Right=",
- this.Right.ToString(CultureInfo.CurrentCulture),
- ",Bottom=",
- this.Bottom.ToString(CultureInfo.CurrentCulture),
- "}"
- });
- }
- }
- }
|