using System;
using System.Globalization;
namespace Dongke.WinForm.Controls.InvoiceLayout.DrawBarcode
{
///
/// 条码图片显示方式
///
public enum BarcodeShowType
{
///
/// 原图
///
Original = 0,
///
/// 居中显示
///
Show,
///
/// 缩放
///
Zoom,
}
///
/// 条码打印余白
///
[Serializable]
public struct BarcodeMargin
{
private bool _all;
private int _top;
private int _left;
private int _right;
private int _bottom;
///
/// 空
///
public static readonly BarcodeMargin Empty = new BarcodeMargin(0);
///
/// 相同值
///
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;
}
}
}
///
/// 底边余白
///
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();
}
}
}
///
/// 左侧余白
///
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();
}
}
}
///
/// 右余白
///
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();
}
}
}
///
/// 顶边余白
///
public int Top
{
get
{
return this._top;
}
set
{
if (value < 0)
{
return;
}
if (this._top != value)
{
this._top = value;
this.SetAll();
}
}
}
///
/// 横向
///
public int Horizontal
{
get
{
return this.Left + this.Right;
}
}
///
/// 纵向
///
public int Vertical
{
get
{
return this.Top + this.Bottom;
}
}
///
/// 条码打印余白
///
///
public BarcodeMargin(int all)
{
//if (all < 0)
//{
// all = 0;
//}
this._all = true;
this._bottom = all;
this._right = all;
this._left = all;
this._top = all;
}
///
/// 条码打印余白
///
///
///
///
///
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);
}
///
/// ToString
///
///
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),
"}"
});
}
}
}