| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125 |
-
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- namespace Dongke.WinForm.Controls.InvoiceLayout
- {
- internal partial class GridItemColumnSetting : Setting
- {
- #region 成员变量
- // 表头属性
- private TextAlignment _textAlignHead = TextAlignment.LeftOrTop; // 文本对齐方式
- private TextAlignment _textAlignVerticalHead = TextAlignment.LeftOrTop; // 文本垂直对齐
- // 文本属性
- private TextAlignment _textAlign = TextAlignment.LeftOrTop; // 文本对齐方式
- private TextAlignment _textAlignVertical = TextAlignment.LeftOrTop; // 文本垂直对齐
- private ItemStyle _itemStyle = ItemStyle.Text; // 项目类别
- private string _defaultValue = string.Empty; // 默认值
- private string _textFormat = string.Empty; // 文本格式
- private string _culture = string.Empty; // culture
- private bool _isInit = true;
- private bool _isNew = false;
- private DataTable _sysFormat;
- private DataTable _sysDefaultValue;
- #endregion
- #region 属性
- /// <summary>
- /// 是否自动表头文本换行
- /// </summary>
- public bool WrapHead
- {
- get
- {
- return this.ckbWrapHead.Checked;
- }
- set
- {
- this.ckbWrapHead.Checked = value;
- }
- }
- /// <summary>
- /// 表头文本字体
- /// </summary>
- public Font TextFontHead
- {
- get
- {
- return txtHeaderText.Font;
- }
- set
- {
- txtHeaderText.Font = value;
- }
- }
- /// <summary>
- /// 表头文本颜色
- /// </summary>
- public Color TextColorHead
- {
- get
- {
- return txtHeaderText.ForeColor;
- }
- set
- {
- txtHeaderText.ForeColor = value;
- }
- }
- /// <summary>
- /// 表头文本对齐方式
- /// </summary>
- public TextAlignment TextAlignHead
- {
- get
- {
- return _textAlignHead;
- }
- set
- {
- _textAlignHead = value;
- }
- }
- /// <summary>
- /// 表头文本垂直对齐方式
- /// </summary>
- public TextAlignment TextAlignVerticalHead
- {
- get
- {
- return _textAlignVerticalHead;
- }
- set
- {
- if (_textAlignVerticalHead != value)
- {
- _textAlignVerticalHead = value;
- }
- }
- }
- /// <summary>
- /// 表头行距
- /// </summary>
- public float LineSpaceHead
- {
- get
- {
- return System.Convert.ToSingle(numLineSpaceHead.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numLineSpaceHead.Minimum)
- {
- d = numLineSpaceHead.Minimum;
- }
- else if (numLineSpaceHead.Maximum < d)
- {
- d = numLineSpaceHead.Maximum;
- }
- numLineSpaceHead.Value = d;
- }
- }
- /// <summary>
- /// 表头字间距
- /// </summary>
- public float CharacterSpaceHead
- {
- get
- {
- return System.Convert.ToSingle(numCharSpaceHead.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numCharSpaceHead.Minimum)
- {
- d = numCharSpaceHead.Minimum;
- }
- else if (numCharSpaceHead.Maximum < d)
- {
- d = numCharSpaceHead.Maximum;
- }
- numCharSpaceHead.Value = d;
- }
- }
- /// <summary>
- /// 表头单行文字数
- /// </summary>
- public int CharacterCountHead
- {
- get
- {
- return System.Convert.ToInt32(numCharCount.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numCharCountHead.Minimum)
- {
- d = numCharCountHead.Minimum;
- }
- else if (numCharCountHead.Maximum < d)
- {
- d = numCharCountHead.Maximum;
- }
- numCharCountHead.Value = d;
- }
- }
- /// <summary>
- /// 是否自动文本换行
- /// </summary>
- public bool Wrap
- {
- get
- {
- return this.ckbWrap.Checked;
- }
- set
- {
- this.ckbWrap.Checked = value;
- }
- }
- /// <summary>
- /// 文本字体
- /// </summary>
- public Font TextFont
- {
- get
- {
- return txtPreview.Font;
- }
- set
- {
- txtPreview.Font = value;
- }
- }
- /// <summary>
- /// 文本颜色
- /// </summary>
- public Color TextColor
- {
- get
- {
- return txtPreview.ForeColor;
- }
- set
- {
- txtPreview.ForeColor = value;
- }
- }
- /// <summary>
- /// 文本内容
- /// </summary>
- public string TextPreview
- {
- get
- {
- return txtPreview.Text;
- }
- set
- {
- txtPreview.Text = value;
- }
- }
- /// <summary>
- /// 文本对齐方式
- /// </summary>
- public TextAlignment TextAlign
- {
- get
- {
- return _textAlign;
- }
- set
- {
- _textAlign = value;
- }
- }
- /// <summary>
- /// 文本垂直对齐方式
- /// </summary>
- public TextAlignment TextAlignVertical
- {
- get
- {
- return _textAlignVertical;
- }
- set
- {
- if (_textAlignVertical != value)
- {
- _textAlignVertical = value;
- }
- }
- }
- /// <summary>
- /// 行距
- /// </summary>
- public float LineSpace
- {
- get
- {
- return System.Convert.ToSingle(numLineSpace.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numLineSpace.Minimum)
- {
- d = numLineSpace.Minimum;
- }
- else if (numLineSpace.Maximum < d)
- {
- d = numLineSpace.Maximum;
- }
- numLineSpace.Value = d;
- }
- }
- /// <summary>
- /// 字间距
- /// </summary>
- public float CharacterSpace
- {
- get
- {
- return System.Convert.ToSingle(numCharSpace.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numCharSpace.Minimum)
- {
- d = numCharSpace.Minimum;
- }
- else if (numCharSpace.Maximum < d)
- {
- d = numCharSpace.Maximum;
- }
- numCharSpace.Value = d;
- }
- }
- /// <summary>
- /// 宽
- /// </summary>
- public float TextWidth
- {
- 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>
- /// 单行文字数
- /// </summary>
- public int CharacterCount
- {
- get
- {
- return System.Convert.ToInt32(numCharCount.Value);
- }
- set
- {
- decimal d = System.Convert.ToDecimal(value);
- if (d < numCharCount.Minimum)
- {
- d = numCharCount.Minimum;
- }
- else if (numCharCount.Maximum < d)
- {
- d = numCharCount.Maximum;
- }
- numCharCount.Value = d;
- }
- }
- /// <summary>
- /// 文本默认值
- /// </summary>
- public string DefaultValue
- {
- get
- {
- return ddlDefaultValue.Text;
- }
- set
- {
- _defaultValue = value;
- }
- }
- /// <summary>
- /// 文本格式
- /// </summary>
- public string TextFormat
- {
- get
- {
- return this.ddlTextFormat.Text;
- }
- set
- {
- if (!string.IsNullOrEmpty(value))
- {
- _textFormat = value;
- }
- }
- }
-
- /// <summary>
- /// Culture
- /// </summary>
- public string Culture
- {
- get
- {
- return _culture;
- }
- set
- {
- _culture = value;
- }
- }
- /// <summary>
- /// 项目类别
- /// </summary>
- public ItemStyle ItemStyle
- {
- get
- {
- return _itemStyle;
- }
- set
- {
- _itemStyle = value;
- }
- }
- /// <summary>
- /// 新建
- /// </summary>
- public bool IsNew
- {
- get
- {
- return _isNew;
- }
- set
- {
- _isNew = value;
- }
- }
- /// <summary>
- /// 列名
- /// </summary>
- public string ColName
- {
- get
- {
- return txtColName.Text;
- }
- set
- {
- txtColName.Text = value;
- }
- }
- /// <summary>
- /// 标题文本
- /// </summary>
- public string HeaderText
- {
- get
- {
- return txtHeaderText.Text;
- }
- set
- {
- txtHeaderText.Text = value;
- }
- }
- /// <summary>
- /// 来源绑定
- /// </summary>
- public bool IsDataBinding
- {
- get
- {
- return this.ddlDefaultValue.Enabled;
- }
- set
- {
- this.ddlDefaultValue.Enabled = value;
- this.ddlTextFormat.Enabled = value;
- }
- }
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public GridItemColumnSetting()
- {
- InitializeComponent();
- InitializeDDL();
- TextWidth = LayoutCommon.DefaultTextItemSizeWidth;
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 文本设置
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void TextItemSetting_Shown(object sender, System.EventArgs e)
- {
- try
- {
- // 条码文本时,才显示条码属性
- if (_itemStyle == ItemStyle.Barcode)
- {
- this.chkPic.Checked = true;
- this.chkM.Visible = true;
- this.chkFixedRatio.Visible = true;
- }
- else
- {
- this.chkPic.Checked = false;
- this.chkM.Visible = false;
- this.chkFixedRatio.Visible = false;
- }
- if (_textAlignHead == TextAlignment.Evenness)
- {
- numCharSpaceHead.Enabled = false;
- numCharSpaceHead.Value = 0;
- numCharCountHead.Enabled = false;
- numCharCountHead.Value = 0;
- }
- else
- {
- if (0 < numCharCountHead.Value)
- {
- rbtnLeftHead.Checked = true;
- grbTextAlignmentHead.Enabled = false;
- numCharSpaceHead.Enabled = false;
- decimal characterSpace = LayoutCommon.EqualityChars(numWidth.Value,
- numCharCountHead.Value,
- txtHeaderText.Font);
- if (characterSpace < numCharSpaceHead.Minimum)
- {
- characterSpace = numCharSpaceHead.Minimum;
- }
- else if (numCharSpaceHead.Maximum < characterSpace)
- {
- characterSpace = numCharSpaceHead.Maximum;
- }
- numCharSpaceHead.Value = LayoutCommon.Truncate(characterSpace,
- numCharSpaceHead.DecimalPlaces);
- }
- }
- if (_textAlign == TextAlignment.Evenness)
- {
- numCharSpace.Enabled = false;
- numCharSpace.Value = 0;
- numCharCount.Enabled = false;
- numCharCount.Value = 0;
- }
- else
- {
- if (0 < numCharCount.Value)
- {
- rbtnLeft.Checked = true;
- grbTextAlignment.Enabled = false;
- numCharSpace.Enabled = false;
- decimal characterSpace = LayoutCommon.EqualityChars(numWidth.Value,
- numCharCount.Value,
- txtPreview.Font);
- if (characterSpace < numCharSpace.Minimum)
- {
- characterSpace = numCharSpace.Minimum;
- }
- else if (numCharSpace.Maximum < characterSpace)
- {
- characterSpace = numCharSpace.Maximum;
- }
- numCharSpace.Value = LayoutCommon.Truncate(characterSpace,
- numCharSpace.DecimalPlaces);
- }
- }
- if (_sysFormat != null)
- {
- if (_itemStyle == ItemStyle.Date)
- {
- _sysFormat.DefaultView.RowFilter = "SignDispNo = 0";
- }
- else if (_itemStyle == ItemStyle.Sign)
- {
- _sysFormat.DefaultView.RowFilter = "DateDispNo = 0";
- }
- else
- {
- _sysFormat.DefaultView.RowFilter = string.Empty;
- }
- }
- if (grbTextAlignmentHead.Enabled)
- {
- switch (_textAlignHead)
- {
- case TextAlignment.LeftOrTop:
- rbtnLeftHead.Checked = true;
- txtHeaderText.TextAlign = HorizontalAlignment.Left;
- break;
- case TextAlignment.RightOrBottom:
- rbtnRightHead.Checked = true;
- txtHeaderText.TextAlign = HorizontalAlignment.Right;
- break;
- case TextAlignment.Center:
- rbtnCenterHead.Checked = true;
- txtHeaderText.TextAlign = HorizontalAlignment.Center;
- break;
- case TextAlignment.Evenness:
- rbtnEvennessHead.Checked = true;
- txtHeaderText.TextAlign = HorizontalAlignment.Left;
- break;
- }
- }
- if (grbTextAlignment.Enabled)
- {
- switch (_textAlign)
- {
- case TextAlignment.LeftOrTop:
- rbtnLeft.Checked = true;
- txtPreview.TextAlign = HorizontalAlignment.Left;
- break;
- case TextAlignment.RightOrBottom:
- rbtnRight.Checked = true;
- txtPreview.TextAlign = HorizontalAlignment.Right;
- break;
- case TextAlignment.Center:
- rbtnCenter.Checked = true;
- txtPreview.TextAlign = HorizontalAlignment.Center;
- break;
- case TextAlignment.Evenness:
- rbtnEvenness.Checked = true;
- txtPreview.TextAlign = HorizontalAlignment.Left;
- break;
- }
- }
- if (grbTextAlignmentVHead.Enabled)
- {
- switch (_textAlignVerticalHead)
- {
- case TextAlignment.LeftOrTop:
- rbtnTopHead.Checked = true;
- break;
- case TextAlignment.RightOrBottom:
- rbtnBottomHead.Checked = true;
- break;
- case TextAlignment.Center:
- rbtnCenterVHead.Checked = true;
- break;
- default:
- rbtnTopHead.Checked = true;
- break;
- }
- }
- if (grbTextAlignmentV.Enabled)
- {
- switch (_textAlignVertical)
- {
- case TextAlignment.LeftOrTop:
- rbtnTop.Checked = true;
- break;
- case TextAlignment.RightOrBottom:
- rbtnBottom.Checked = true;
- break;
- case TextAlignment.Center:
- rbtnCenterV.Checked = true;
- break;
- default:
- rbtnTop.Checked = true;
- break;
- }
- }
- if (IsNew || !IsDataBinding)
- {
- if (_sysFormat != null)
- {
- ddlTextFormat.SelectedIndex = 0;
- }
- if (_sysDefaultValue != null)
- {
- ddlDefaultValue.SelectedIndex = 0;
- }
- }
- else
- {
- if (_sysFormat != null)
- {
- if (_itemStyle == ItemStyle.Date)
- {
- // 日期
- DataRow[] drs = _sysFormat.Select
- (string.Format("Format = '{0}' AND ('{1}' = '' OR Culture = '{1}') AND DateDispNo <> 0",
- _textFormat,
- _culture));
- if (drs != null && 0 < drs.Length)
- {
- ddlTextFormat.SelectedValue = drs[0]["FormatID"];
- }
- else
- {
- ddlTextFormat.Text = _textFormat;
- }
- }
- else if (_itemStyle == ItemStyle.Sign)
- {
- // 符号
- ddlTextFormat.ValueMember = "FormatName";
- ddlTextFormat.SelectedValue = _textFormat;
- if (ddlTextFormat.SelectedIndex < 0)
- {
- ddlTextFormat.Text = _textFormat;
- }
- }
- else
- {
- ddlTextFormat.ValueMember = "Format";
- ddlTextFormat.SelectedValue = _textFormat;
- if (ddlTextFormat.SelectedIndex < 0)
- {
- ddlTextFormat.Text = _textFormat;
- }
- }
- }
- ddlDefaultValue.Text = _defaultValue;
- }
- }
- finally
- {
- _isInit = false;
- }
- }
- /// <summary>
- /// 设置文本颜色
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void btnSelectColor_Click(object sender, System.EventArgs e)
- {
- colorDialog.Color = txtPreview.ForeColor;
- if (colorDialog.ShowDialog() == DialogResult.OK)
- {
- txtPreview.ForeColor = colorDialog.Color;
- }
- }
- /// <summary>
- /// 设置表头文本颜色
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void btnSelectColorHead_Click(object sender, System.EventArgs e)
- {
- colorDialog.Color = txtHeaderText.ForeColor;
- if (colorDialog.ShowDialog() == DialogResult.OK)
- {
- txtHeaderText.ForeColor = colorDialog.Color;
- }
- }
- /// <summary>
- /// 设置文本格式
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void ddlTextFormat_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- _culture = string.Empty;
- DataRowView dataRow = ddlTextFormat.SelectedItem as DataRowView;
- if (dataRow != null)
- {
- if (0 != System.Convert.ToInt32(dataRow["DateDispNo"]))
- {
- _itemStyle = ItemStyle.Date;
- _textFormat = dataRow["Format"].ToString();
- _culture = dataRow["Culture"].ToString();
- }
- else if (0 != System.Convert.ToInt32(dataRow["SignDispNo"]))
- {
- _itemStyle = ItemStyle.Sign;
- _textFormat = dataRow["FormatName"].ToString();
- }
- else
- {
- _itemStyle = ItemStyle.Text;
- _textFormat = dataRow["Format"].ToString();
- }
- }
- else
- {
- //if (_itemStyle != ItemStyle.Barcode)
- //{
- // _itemStyle = ItemStyle.Other;
- //}
- _textFormat = ddlTextFormat.Text;
- _culture = null;
- }
- }
- /// <summary>
- /// 设置文本对齐方式
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void rbtnTextAlignment_CheckedChanged(object sender, System.EventArgs e)
- {
- if (_isInit)
- {
- return;
- }
- if (rbtnLeft.Checked)
- {
- txtPreview.TextAlign = HorizontalAlignment.Left;
- _textAlign = TextAlignment.LeftOrTop;
- }
- else if (rbtnRight.Checked)
- {
- txtPreview.TextAlign = HorizontalAlignment.Right;
- _textAlign = TextAlignment.RightOrBottom;
- }
- else if (rbtnCenter.Checked)
- {
- txtPreview.TextAlign = HorizontalAlignment.Center;
- _textAlign = TextAlignment.Center;
- }
- else
- {
- txtPreview.TextAlign = HorizontalAlignment.Left;
- _textAlign = TextAlignment.Evenness;
- }
- if (rbtnTop.Checked)
- {
- _textAlignVertical = TextAlignment.LeftOrTop;
- }
- else if (rbtnBottom.Checked)
- {
- _textAlignVertical = TextAlignment.RightOrBottom;
- }
- else if (rbtnCenterV.Checked)
- {
- _textAlignVertical = TextAlignment.Center;
- }
- else
- {
- _textAlignVertical = TextAlignment.LeftOrTop;
- }
- if (rbtnEvenness.Checked)
- {
- numCharSpace.Enabled = false;
- numCharSpace.Value = 0;
- numCharCount.Enabled = false;
- numCharCount.Value = 0;
- }
- else
- {
- numCharSpace.Enabled = true;
- numCharCount.Enabled = true;
- }
- }
- /// <summary>
- /// 设置表头文本对齐方式
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void rbtnTextAlignmentHead_CheckedChanged(object sender, System.EventArgs e)
- {
- if (_isInit)
- {
- return;
- }
- if (rbtnLeftHead.Checked)
- {
- txtHeaderText.TextAlign = HorizontalAlignment.Left;
- _textAlignHead = TextAlignment.LeftOrTop;
- }
- else if (rbtnRightHead.Checked)
- {
- txtHeaderText.TextAlign = HorizontalAlignment.Right;
- _textAlignHead = TextAlignment.RightOrBottom;
- }
- else if (rbtnCenterHead.Checked)
- {
- txtHeaderText.TextAlign = HorizontalAlignment.Center;
- _textAlignHead = TextAlignment.Center;
- }
- else
- {
- txtHeaderText.TextAlign = HorizontalAlignment.Left;
- _textAlignHead = TextAlignment.Evenness;
- }
- if (rbtnTopHead.Checked)
- {
- _textAlignVerticalHead = TextAlignment.LeftOrTop;
- }
- else if (rbtnBottomHead.Checked)
- {
- _textAlignVerticalHead = TextAlignment.RightOrBottom;
- }
- else if (rbtnCenterVHead.Checked)
- {
- _textAlignVerticalHead = TextAlignment.Center;
- }
- else
- {
- _textAlignVerticalHead = TextAlignment.LeftOrTop;
- }
- if (rbtnEvennessHead.Checked)
- {
- numCharSpaceHead.Enabled = false;
- numCharSpaceHead.Value = 0;
- numCharCountHead.Enabled = false;
- numCharCountHead.Value = 0;
- }
- else
- {
- numCharSpaceHead.Enabled = true;
- numCharCountHead.Enabled = true;
- }
- }
- /// <summary>
- /// 设置单行文字数
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void numCharCount_ValueChanged(object sender, System.EventArgs e)
- {
- if (_isInit)
- {
- return;
- }
- if (0 < numCharCount.Value)
- {
- rbtnLeft.Checked = true;
- grbTextAlignment.Enabled = false;
- numCharSpace.Enabled = false;
- decimal characterSpace = LayoutCommon.EqualityChars(
- numWidth.Value,
- numCharCount.Value,
- txtPreview.Font);
- if (characterSpace < numCharSpace.Minimum)
- {
- characterSpace = numCharSpace.Minimum;
- }
- else if (numCharSpace.Maximum < characterSpace)
- {
- characterSpace = numCharSpace.Maximum;
- }
- numCharSpace.Value = LayoutCommon.Truncate(characterSpace, numCharSpace.DecimalPlaces);
- }
- else
- {
- grbTextAlignment.Enabled = true;
- if (!rbtnEvenness.Checked)
- {
- numCharSpace.Enabled = true;
- }
- }
- if (0 < numCharCountHead.Value)
- {
- rbtnLeftHead.Checked = true;
- grbTextAlignmentHead.Enabled = false;
- numCharSpaceHead.Enabled = false;
- decimal characterSpace = LayoutCommon.EqualityChars(
- numWidth.Value,
- numCharCountHead.Value,
- txtHeaderText.Font);
- if (characterSpace < numCharSpaceHead.Minimum)
- {
- characterSpace = numCharSpaceHead.Minimum;
- }
- else if (numCharSpaceHead.Maximum < characterSpace)
- {
- characterSpace = numCharSpaceHead.Maximum;
- }
- numCharSpaceHead.Value = LayoutCommon.Truncate(characterSpace, numCharSpaceHead.DecimalPlaces);
- }
- else
- {
- grbTextAlignmentHead.Enabled = true;
- if (!rbtnEvennessHead.Checked)
- {
- numCharSpaceHead.Enabled = true;
- }
- }
- }
- /// <summary>
- /// 设置文本字体。
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void txtPreview_FontChanged(object sender, System.EventArgs e)
- {
- if (_isInit)
- {
- return;
- }
- if (0 < numCharCount.Value)
- {
- decimal characterSpace = LayoutCommon.EqualityChars(
- numWidth.Value,
- numCharCount.Value,
- txtPreview.Font);
- if (characterSpace < numCharSpace.Minimum)
- {
- characterSpace = numCharSpace.Minimum;
- }
- else if (numCharSpace.Maximum < characterSpace)
- {
- characterSpace = numCharSpace.Maximum;
- }
- numCharSpace.Value = LayoutCommon.Truncate(characterSpace,
- numCharSpace.DecimalPlaces);
- }
- }
- /// <summary>
- /// 设置表头字体。
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void txtHeaderText_FontChanged(object sender, System.EventArgs e)
- {
- if (_isInit)
- {
- return;
- }
- if (0 < numCharCountHead.Value)
- {
- decimal characterSpace = LayoutCommon.EqualityChars(
- numWidth.Value,
- numCharCountHead.Value,
- txtHeaderText.Font);
- if (characterSpace < numCharSpaceHead.Minimum)
- {
- characterSpace = numCharSpaceHead.Minimum;
- }
- else if (numCharSpaceHead.Maximum < characterSpace)
- {
- characterSpace = numCharSpaceHead.Maximum;
- }
- numCharSpaceHead.Value = LayoutCommon.Truncate(characterSpace,
- numCharSpaceHead.DecimalPlaces);
- }
- }
- /// <summary>
- /// 设置文本字体。
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void btnFont_Click(object sender, System.EventArgs e)
- {
- fontDialog.Font = TextFont;
- if (fontDialog.ShowDialog() == DialogResult.OK)
- {
- TextFont = fontDialog.Font;
- }
- }
- /// <summary>
- /// 设置表头文本字体。
- /// </summary>
- /// <param name="sender">指定的对象</param>
- /// <param name="e">提供的事件数据</param>
- private void btnFontHead_Click(object sender, System.EventArgs e)
- {
- fontDialog.Font = TextFontHead;
- if (fontDialog.ShowDialog() == DialogResult.OK)
- {
- TextFontHead = fontDialog.Font;
- }
- }
- #endregion 事件处理
- #region 私有函数/方法
- /// <summary>
- /// 获取系统字体
- /// </summary>
- private void InitializeDDL()
- {
- _sysFormat = LayoutCommon.SYSFormat.Copy();
- _sysDefaultValue = LayoutCommon.SYSDefaultValue.Copy();
- ddlDefaultValue.DisplayMember = "InitialValueName";
- ddlDefaultValue.ValueMember = "InitialValueName";
- ddlDefaultValue.DataSource = _sysDefaultValue;
- ddlTextFormat.DisplayMember = "FormatName";
- ddlTextFormat.ValueMember = "FormatID";
- ddlTextFormat.DataSource = _sysFormat;
- }
- /// <summary>
- /// 图片列的时候,余白和固定比例可用
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void chkPic_CheckedChanged(object sender, System.EventArgs e)
- {
- chkM.Enabled = chkPic.Checked;
- chkFixedRatio.Enabled = chkPic.Checked;
- }
- #endregion 函数
- private void ckbWrapHead_CheckedChanged(object sender, System.EventArgs e)
- {
- }
- }
- }
|