TotalTextItemSetting.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  1. 
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. namespace Dongke.WinForm.Controls.InvoiceLayout
  6. {
  7. internal partial class TotalTextItemSetting : Setting
  8. {
  9. #region 成员变量
  10. private TextAlignment _textAlign = TextAlignment.LeftOrTop; // 文本对齐方式
  11. private TextAlignment _textAlignVertical = TextAlignment.LeftOrTop; // 文本垂直对齐
  12. private ItemStyle _itemStyle = ItemStyle.Text; // 项目类别
  13. private string _defaultValue = string.Empty; // 默认值
  14. private string _textFormat = string.Empty; // 文本格式
  15. private string _culture = string.Empty; // culture
  16. private bool _isInit = true;
  17. private bool _isNew = false;
  18. private bool _isDataBinding = false;
  19. private DataTable _sysFormat;
  20. private DataTable _sysDefaultValue;
  21. private TextAlignment _notTotalAlign = TextAlignment.LeftOrTop; // 文本对齐方式
  22. private TextAlignment _notTotalAlignVertical = TextAlignment.LeftOrTop; // 文本垂直对齐
  23. #endregion
  24. #region 属性
  25. #region 非合计
  26. /// <summary>
  27. /// 非合计文本字体
  28. /// </summary>
  29. public Font NotTotalFont
  30. {
  31. get
  32. {
  33. return txtNotTotalValue.Font;
  34. }
  35. set
  36. {
  37. txtNotTotalValue.Font = value;
  38. }
  39. }
  40. /// <summary>
  41. /// 非合计文本颜色
  42. /// </summary>
  43. public Color NotTotalColor
  44. {
  45. get
  46. {
  47. return txtNotTotalValue.ForeColor;
  48. }
  49. set
  50. {
  51. txtNotTotalValue.ForeColor = value;
  52. }
  53. }
  54. /// <summary>
  55. /// 非合计文本内容
  56. /// </summary>
  57. public string NotTotalValue
  58. {
  59. get
  60. {
  61. return txtNotTotalValue.Text;
  62. }
  63. set
  64. {
  65. txtNotTotalValue.Text = value;
  66. }
  67. }
  68. /// <summary>
  69. /// 文本对齐方式
  70. /// </summary>
  71. public TextAlignment NotTotalAlign
  72. {
  73. get
  74. {
  75. return _notTotalAlign;
  76. }
  77. set
  78. {
  79. if (_notTotalAlign != value)
  80. {
  81. _notTotalAlign = value;
  82. }
  83. }
  84. }
  85. /// <summary>
  86. /// 文本垂直对齐方式
  87. /// </summary>
  88. public TextAlignment NotTotalAlignVertical
  89. {
  90. get
  91. {
  92. return _notTotalAlignVertical;
  93. }
  94. set
  95. {
  96. if (_notTotalAlignVertical != value)
  97. {
  98. _notTotalAlignVertical = value;
  99. }
  100. }
  101. }
  102. #endregion 非合计
  103. /// <summary>
  104. /// 是否自动文本换行
  105. /// </summary>
  106. public bool Wrap
  107. {
  108. get
  109. {
  110. return this.ckbWrap.Checked;
  111. }
  112. set
  113. {
  114. this.ckbWrap.Checked = value;
  115. }
  116. }
  117. /// <summary>
  118. /// 文本字体
  119. /// </summary>
  120. public Font TextFont
  121. {
  122. get
  123. {
  124. return txtPreview.Font;
  125. }
  126. set
  127. {
  128. txtPreview.Font = value;
  129. }
  130. }
  131. /// <summary>
  132. /// 文本颜色
  133. /// </summary>
  134. public Color TextColor
  135. {
  136. get
  137. {
  138. return txtPreview.ForeColor;
  139. }
  140. set
  141. {
  142. txtPreview.ForeColor = value;
  143. }
  144. }
  145. /// <summary>
  146. /// 文本内容
  147. /// </summary>
  148. public string TextPreview
  149. {
  150. get
  151. {
  152. return txtPreview.Text;
  153. }
  154. set
  155. {
  156. txtPreview.Text = value;
  157. }
  158. }
  159. /// <summary>
  160. /// 文本对齐方式
  161. /// </summary>
  162. public TextAlignment TextAlign
  163. {
  164. get
  165. {
  166. return _textAlign;
  167. }
  168. set
  169. {
  170. if (_textAlign != value)
  171. {
  172. _textAlign = value;
  173. }
  174. }
  175. }
  176. /// <summary>
  177. /// 文本垂直对齐方式
  178. /// </summary>
  179. public TextAlignment TextAlignVertical
  180. {
  181. get
  182. {
  183. return _textAlignVertical;
  184. }
  185. set
  186. {
  187. if (_textAlignVertical != value)
  188. {
  189. _textAlignVertical = value;
  190. }
  191. }
  192. }
  193. /// <summary>
  194. /// 行距
  195. /// </summary>
  196. public float LineSpace
  197. {
  198. get
  199. {
  200. return System.Convert.ToSingle(numLineSpace.Value);
  201. }
  202. set
  203. {
  204. decimal d = System.Convert.ToDecimal(value);
  205. if (d < numLineSpace.Minimum)
  206. {
  207. d = numLineSpace.Minimum;
  208. }
  209. else if (numLineSpace.Maximum < d)
  210. {
  211. d = numLineSpace.Maximum;
  212. }
  213. numLineSpace.Value = d;
  214. }
  215. }
  216. /// <summary>
  217. /// 字间距
  218. /// </summary>
  219. public float CharacterSpace
  220. {
  221. get
  222. {
  223. return System.Convert.ToSingle(numCharSpace.Value);
  224. }
  225. set
  226. {
  227. decimal d = System.Convert.ToDecimal(value);
  228. if (d < numCharSpace.Minimum)
  229. {
  230. d = numCharSpace.Minimum;
  231. }
  232. else if (numCharSpace.Maximum < d)
  233. {
  234. d = numCharSpace.Maximum;
  235. }
  236. numCharSpace.Value = d;
  237. }
  238. }
  239. /// <summary>
  240. /// X
  241. /// </summary>
  242. public float TextLocationY
  243. {
  244. get
  245. {
  246. return System.Convert.ToSingle(numLoctionY.Value);
  247. }
  248. set
  249. {
  250. decimal d = System.Convert.ToDecimal(value);
  251. if (d < numLoctionY.Minimum)
  252. {
  253. d = numLoctionY.Minimum;
  254. }
  255. else if (numLoctionY.Maximum < d)
  256. {
  257. d = numLoctionY.Maximum;
  258. }
  259. numLoctionY.Value = d;
  260. }
  261. }
  262. /// <summary>
  263. /// Y
  264. /// </summary>
  265. public float TextLocationX
  266. {
  267. get
  268. {
  269. return System.Convert.ToSingle(numLoctionX.Value);
  270. }
  271. set
  272. {
  273. decimal d = System.Convert.ToDecimal(value);
  274. if (d < numLoctionX.Minimum)
  275. {
  276. d = numLoctionX.Minimum;
  277. }
  278. else if (numLoctionX.Maximum < d)
  279. {
  280. d = numLoctionX.Maximum;
  281. }
  282. numLoctionX.Value = d;
  283. }
  284. }
  285. /// <summary>
  286. /// 宽
  287. /// </summary>
  288. public float TextWidth
  289. {
  290. get
  291. {
  292. return System.Convert.ToSingle(numWidth.Value);
  293. }
  294. set
  295. {
  296. decimal d = System.Convert.ToDecimal(value);
  297. if (d < numWidth.Minimum)
  298. {
  299. d = numWidth.Minimum;
  300. }
  301. else if (numWidth.Maximum < d)
  302. {
  303. d = numWidth.Maximum;
  304. }
  305. numWidth.Value = d;
  306. }
  307. }
  308. /// <summary>
  309. /// 高
  310. /// </summary>
  311. public float TextHeight
  312. {
  313. get
  314. {
  315. return System.Convert.ToSingle(numHeight.Value);
  316. }
  317. set
  318. {
  319. decimal d = System.Convert.ToDecimal(value);
  320. if (d < numHeight.Minimum)
  321. {
  322. d = numHeight.Minimum;
  323. }
  324. else if (numHeight.Maximum < d)
  325. {
  326. d = numHeight.Maximum;
  327. }
  328. numHeight.Value = d;
  329. }
  330. }
  331. /// <summary>
  332. /// 单行文字数
  333. /// </summary>
  334. public int CharacterCount
  335. {
  336. get
  337. {
  338. return System.Convert.ToInt32(numCharCount.Value);
  339. }
  340. set
  341. {
  342. decimal d = System.Convert.ToDecimal(value);
  343. if (d < numCharCount.Minimum)
  344. {
  345. d = numCharCount.Minimum;
  346. }
  347. else if (numCharCount.Maximum < d)
  348. {
  349. d = numCharCount.Maximum;
  350. }
  351. numCharCount.Value = d;
  352. }
  353. }
  354. /// <summary>
  355. /// 文本默认值
  356. /// </summary>
  357. public string DefaultValue
  358. {
  359. get
  360. {
  361. return ddlDefaultValue.Text;
  362. }
  363. set
  364. {
  365. _defaultValue = value;
  366. }
  367. }
  368. /// <summary>
  369. /// 文本格式
  370. /// </summary>
  371. public string TextFormat
  372. {
  373. get
  374. {
  375. return this.ddlTextFormat.Text;
  376. }
  377. set
  378. {
  379. _textFormat = value;
  380. }
  381. }
  382. /// <summary>
  383. /// Culture
  384. /// </summary>
  385. public string Culture
  386. {
  387. get
  388. {
  389. return _culture;
  390. }
  391. set
  392. {
  393. _culture = value;
  394. }
  395. }
  396. /// <summary>
  397. /// 项目类别
  398. /// </summary>
  399. public ItemStyle ItemStyle
  400. {
  401. get
  402. {
  403. return _itemStyle;
  404. }
  405. set
  406. {
  407. _itemStyle = value;
  408. }
  409. }
  410. /// <summary>
  411. /// 新建
  412. /// </summary>
  413. public bool IsNew
  414. {
  415. get
  416. {
  417. return _isNew;
  418. }
  419. set
  420. {
  421. _isNew = value;
  422. }
  423. }
  424. /// <summary>
  425. /// 来源绑定
  426. /// </summary>
  427. public bool IsDataBinding
  428. {
  429. get
  430. {
  431. return this._isDataBinding;
  432. }
  433. set
  434. {
  435. this._isDataBinding = value;
  436. this.ddlDefaultValue.Enabled = value;
  437. this.ddlTextFormat.Enabled = value;
  438. //this.lblPreview.Text = value ? "预览" : "打印内容";
  439. }
  440. }
  441. /// <summary>
  442. /// 项目名
  443. /// </summary>
  444. public string ItemName
  445. {
  446. get
  447. {
  448. return txtItemName.Text;
  449. }
  450. set
  451. {
  452. txtItemName.Text = value;
  453. }
  454. }
  455. #endregion
  456. #region 构造函数
  457. /// <summary>
  458. /// 构造函数
  459. /// </summary>
  460. public TotalTextItemSetting()
  461. {
  462. InitializeComponent();
  463. InitializeDDL();
  464. TextWidth = LayoutCommon.DefaultTextItemSizeWidth;
  465. TextHeight = LayoutCommon.DefaultTextItemSizeHeight;
  466. }
  467. #endregion
  468. #region 函数
  469. /// <summary>
  470. /// 获取系统字体
  471. /// </summary>
  472. private void InitializeDDL()
  473. {
  474. //InstalledFontCollection fonts = new InstalledFontCollection();
  475. _sysFormat = LayoutCommon.SYSFormat.Copy();
  476. _sysDefaultValue = LayoutCommon.SYSDefaultValue.Copy();
  477. ddlDefaultValue.DisplayMember = "InitialValueName";
  478. ddlDefaultValue.ValueMember = "InitialValueName";
  479. ddlDefaultValue.DataSource = _sysDefaultValue;
  480. ddlTextFormat.DisplayMember = "FormatName";
  481. ddlTextFormat.ValueMember = "FormatID";
  482. ddlTextFormat.DataSource = _sysFormat;
  483. }
  484. #endregion 函数
  485. #region 事件处理
  486. /// <summary>
  487. /// 文本设置
  488. /// </summary>
  489. /// <param name="sender">指定的对象</param>
  490. /// <param name="e">提供的事件数据</param>
  491. private void TextItemSetting_Shown(object sender, System.EventArgs e)
  492. {
  493. try
  494. {
  495. if (_textAlign == TextAlignment.Evenness)
  496. {
  497. numCharSpace.Enabled = false;
  498. numCharSpace.Value = 0;
  499. numCharCount.Enabled = false;
  500. numCharCount.Value = 0;
  501. }
  502. else
  503. {
  504. if (0 < numCharCount.Value)
  505. {
  506. rbtnLeft.Checked = true;
  507. gbxTotalValueTextAlignment.Enabled = false;
  508. numCharSpace.Enabled = false;
  509. decimal characterSpace = LayoutCommon.EqualityChars(numWidth.Value,
  510. numCharCount.Value,
  511. txtPreview.Font);
  512. if (characterSpace < numCharSpace.Minimum)
  513. {
  514. characterSpace = numCharSpace.Minimum;
  515. }
  516. else if (numCharSpace.Maximum < characterSpace)
  517. {
  518. characterSpace = numCharSpace.Maximum;
  519. }
  520. numCharSpace.Value = LayoutCommon.Truncate(characterSpace,
  521. numCharSpace.DecimalPlaces);
  522. }
  523. }
  524. if (_sysFormat != null)
  525. {
  526. if (_itemStyle == ItemStyle.Date)
  527. {
  528. _sysFormat.DefaultView.RowFilter = "SignDispNo = 0";
  529. }
  530. else if (_itemStyle == ItemStyle.Sign)
  531. {
  532. _sysFormat.DefaultView.RowFilter = "DateDispNo = 0";
  533. }
  534. else
  535. {
  536. _sysFormat.DefaultView.RowFilter = string.Empty;
  537. }
  538. }
  539. if (gbxTotalValueTextAlignment.Enabled)
  540. {
  541. switch (_textAlign)
  542. {
  543. case TextAlignment.LeftOrTop:
  544. rbtnLeft.Checked = true;
  545. txtPreview.TextAlign = HorizontalAlignment.Left;
  546. break;
  547. case TextAlignment.RightOrBottom:
  548. rbtnRight.Checked = true;
  549. txtPreview.TextAlign = HorizontalAlignment.Right;
  550. break;
  551. case TextAlignment.Center:
  552. rbtnCenter.Checked = true;
  553. txtPreview.TextAlign = HorizontalAlignment.Center;
  554. break;
  555. case TextAlignment.Evenness:
  556. rbtnEvenness.Checked = true;
  557. txtPreview.TextAlign = HorizontalAlignment.Left;
  558. break;
  559. }
  560. }
  561. switch (_notTotalAlign)
  562. {
  563. case TextAlignment.LeftOrTop:
  564. rbtnNotLeft.Checked = true;
  565. txtNotTotalValue.TextAlign = HorizontalAlignment.Left;
  566. break;
  567. case TextAlignment.RightOrBottom:
  568. rbtnNotRight.Checked = true;
  569. txtNotTotalValue.TextAlign = HorizontalAlignment.Right;
  570. break;
  571. case TextAlignment.Center:
  572. rbtnNotCenter.Checked = true;
  573. txtNotTotalValue.TextAlign = HorizontalAlignment.Center;
  574. break;
  575. case TextAlignment.Evenness:
  576. rbtnNotEvenness.Checked = true;
  577. txtNotTotalValue.TextAlign = HorizontalAlignment.Left;
  578. break;
  579. }
  580. if (gbxTotalValueTextAlignmentV.Enabled)
  581. {
  582. switch (_textAlignVertical)
  583. {
  584. case TextAlignment.LeftOrTop:
  585. rbtnTop.Checked = true;
  586. break;
  587. case TextAlignment.RightOrBottom:
  588. rbtnBottom.Checked = true;
  589. break;
  590. case TextAlignment.Center:
  591. rbtnCenterV.Checked = true;
  592. break;
  593. default:
  594. rbtnTop.Checked = true;
  595. break;
  596. }
  597. }
  598. switch (_notTotalAlignVertical)
  599. {
  600. case TextAlignment.LeftOrTop:
  601. rbtnNotTop.Checked = true;
  602. break;
  603. case TextAlignment.RightOrBottom:
  604. rbtnNotBottom.Checked = true;
  605. break;
  606. case TextAlignment.Center:
  607. rbtnNotCenterV.Checked = true;
  608. break;
  609. default:
  610. rbtnNotTop.Checked = true;
  611. break;
  612. }
  613. if (_isNew || !_isDataBinding)
  614. {
  615. if (_sysFormat != null)
  616. {
  617. ddlTextFormat.SelectedIndex = 0;
  618. }
  619. if (_sysDefaultValue != null)
  620. {
  621. ddlDefaultValue.SelectedIndex = 0;
  622. }
  623. }
  624. else
  625. {
  626. if (_sysFormat != null)
  627. {
  628. if (_itemStyle == ItemStyle.Date)
  629. {
  630. // 日期
  631. DataRow[] drs = _sysFormat.Select
  632. (string.Format("Format = '{0}' AND ('{1}' = '' OR Culture = '{1}') AND DateDispNo <> 0",
  633. _textFormat,
  634. _culture));
  635. if (drs != null && 0 < drs.Length)
  636. {
  637. ddlTextFormat.SelectedValue = drs[0]["FormatID"];
  638. }
  639. else
  640. {
  641. ddlTextFormat.Text = _textFormat;
  642. }
  643. }
  644. else if (_itemStyle == ItemStyle.Sign)
  645. {
  646. // 符号
  647. ddlTextFormat.ValueMember = "FormatName";
  648. ddlTextFormat.SelectedValue = _textFormat;
  649. if (ddlTextFormat.SelectedIndex < 0)
  650. {
  651. ddlTextFormat.Text = _textFormat;
  652. }
  653. }
  654. else
  655. {
  656. ddlTextFormat.ValueMember = "Format";
  657. ddlTextFormat.SelectedValue = _textFormat;
  658. if (ddlTextFormat.SelectedIndex < 0)
  659. {
  660. ddlTextFormat.Text = _textFormat;
  661. }
  662. }
  663. }
  664. ddlDefaultValue.Text = _defaultValue;
  665. }
  666. }
  667. finally
  668. {
  669. _isInit = false;
  670. }
  671. }
  672. /// <summary>
  673. /// 设置文本格式
  674. /// </summary>
  675. /// <param name="sender">指定的对象</param>
  676. /// <param name="e">提供的事件数据</param>
  677. private void ddlTextFormat_SelectedIndexChanged(object sender, System.EventArgs e)
  678. {
  679. _culture = string.Empty;
  680. DataRowView dataRow = ddlTextFormat.SelectedItem as DataRowView;
  681. if (dataRow != null)
  682. {
  683. if (0 != System.Convert.ToInt32(dataRow["DateDispNo"]))
  684. {
  685. _itemStyle = ItemStyle.Date;
  686. _textFormat = dataRow["Format"].ToString();
  687. _culture = dataRow["Culture"].ToString();
  688. }
  689. else if (0 != System.Convert.ToInt32(dataRow["SignDispNo"]))
  690. {
  691. _itemStyle = ItemStyle.Sign;
  692. _textFormat = dataRow["FormatName"].ToString();
  693. }
  694. else
  695. {
  696. _itemStyle = ItemStyle.Text;
  697. _textFormat = dataRow["Format"].ToString();
  698. }
  699. }
  700. else
  701. {
  702. //_itemStyle = ItemStyle.Other;
  703. _textFormat = ddlTextFormat.Text;
  704. _culture = null;
  705. }
  706. }
  707. /// <summary>
  708. /// 设置文本对齐方式
  709. /// </summary>
  710. /// <param name="sender">指定的对象</param>
  711. /// <param name="e">提供的事件数据</param>
  712. private void rbtnTextAlignment_CheckedChanged(object sender, System.EventArgs e)
  713. {
  714. if (_isInit)
  715. {
  716. return;
  717. }
  718. if (rbtnLeft.Checked)
  719. {
  720. txtPreview.TextAlign = HorizontalAlignment.Left;
  721. _textAlign = TextAlignment.LeftOrTop;
  722. }
  723. else if (rbtnRight.Checked)
  724. {
  725. txtPreview.TextAlign = HorizontalAlignment.Right;
  726. _textAlign = TextAlignment.RightOrBottom;
  727. }
  728. else if (rbtnCenter.Checked)
  729. {
  730. txtPreview.TextAlign = HorizontalAlignment.Center;
  731. _textAlign = TextAlignment.Center;
  732. }
  733. else
  734. {
  735. txtPreview.TextAlign = HorizontalAlignment.Left;
  736. _textAlign = TextAlignment.Evenness;
  737. }
  738. if (rbtnTop.Checked)
  739. {
  740. _textAlignVertical = TextAlignment.LeftOrTop;
  741. }
  742. else if (rbtnBottom.Checked)
  743. {
  744. _textAlignVertical = TextAlignment.RightOrBottom;
  745. }
  746. else if (rbtnCenterV.Checked)
  747. {
  748. _textAlignVertical = TextAlignment.Center;
  749. }
  750. else
  751. {
  752. _textAlignVertical = TextAlignment.LeftOrTop;
  753. }
  754. if (rbtnEvenness.Checked)
  755. {
  756. numCharSpace.Enabled = false;
  757. numCharSpace.Value = 0;
  758. numCharCount.Enabled = false;
  759. numCharCount.Value = 0;
  760. }
  761. else
  762. {
  763. numCharSpace.Enabled = true;
  764. numCharCount.Enabled = true;
  765. }
  766. }
  767. /// <summary>
  768. /// 设置单行文字数
  769. /// </summary>
  770. /// <param name="sender">指定的对象</param>
  771. /// <param name="e">提供的事件数据</param>
  772. private void numCharCount_ValueChanged(object sender, System.EventArgs e)
  773. {
  774. if (_isInit)
  775. {
  776. return;
  777. }
  778. if (0 < numCharCount.Value)
  779. {
  780. rbtnLeft.Checked = true;
  781. gbxTotalValueTextAlignment.Enabled = false;
  782. numCharSpace.Enabled = false;
  783. decimal characterSpace = LayoutCommon.EqualityChars(
  784. numWidth.Value,
  785. numCharCount.Value,
  786. txtPreview.Font);
  787. if (characterSpace < numCharSpace.Minimum)
  788. {
  789. characterSpace = numCharSpace.Minimum;
  790. }
  791. else if (numCharSpace.Maximum < characterSpace)
  792. {
  793. characterSpace = numCharSpace.Maximum;
  794. }
  795. numCharSpace.Value = LayoutCommon.Truncate(characterSpace, numCharSpace.DecimalPlaces);
  796. }
  797. else
  798. {
  799. gbxTotalValueTextAlignment.Enabled = true;
  800. if (!rbtnEvenness.Checked)
  801. {
  802. numCharSpace.Enabled = true;
  803. }
  804. }
  805. }
  806. /// <summary>
  807. /// 设置文本字体。
  808. /// </summary>
  809. /// <param name="sender">指定的对象</param>
  810. /// <param name="e">提供的事件数据</param>
  811. private void txtPreview_FontChanged(object sender, System.EventArgs e)
  812. {
  813. if (_isInit)
  814. {
  815. return;
  816. }
  817. if (0 < numCharCount.Value)
  818. {
  819. decimal characterSpace = LayoutCommon.EqualityChars(
  820. numWidth.Value,
  821. numCharCount.Value,
  822. txtPreview.Font);
  823. if (characterSpace < numCharSpace.Minimum)
  824. {
  825. characterSpace = numCharSpace.Minimum;
  826. }
  827. else if (numCharSpace.Maximum < characterSpace)
  828. {
  829. characterSpace = numCharSpace.Maximum;
  830. }
  831. numCharSpace.Value = LayoutCommon.Truncate(characterSpace,
  832. numCharSpace.DecimalPlaces);
  833. }
  834. }
  835. /// <summary>
  836. /// 设置文本字体。
  837. /// </summary>
  838. /// <param name="sender">指定的对象</param>
  839. /// <param name="e">提供的事件数据</param>
  840. private void btnFont_Click(object sender, System.EventArgs e)
  841. {
  842. fontDialog.Font = TextFont;
  843. if (fontDialog.ShowDialog() == DialogResult.OK)
  844. {
  845. TextFont = fontDialog.Font;
  846. }
  847. }
  848. /// <summary>
  849. /// 设置合计文本颜色
  850. /// </summary>
  851. /// <param name="sender">指定的对象</param>
  852. /// <param name="e">提供的事件数据</param>
  853. private void btnSelectColor_Click(object sender, System.EventArgs e)
  854. {
  855. colorDialog.Color = TextColor;
  856. if (colorDialog.ShowDialog() == DialogResult.OK)
  857. {
  858. TextColor = colorDialog.Color;
  859. }
  860. }
  861. #region 非合计文本
  862. /// <summary>
  863. /// 设置文本对齐方式
  864. /// </summary>
  865. /// <param name="sender">指定的对象</param>
  866. /// <param name="e">提供的事件数据</param>
  867. private void rbtnNotAlignment_CheckedChanged(object sender, System.EventArgs e)
  868. {
  869. if (_isInit)
  870. {
  871. return;
  872. }
  873. if (rbtnNotLeft.Checked)
  874. {
  875. txtNotTotalValue.TextAlign = HorizontalAlignment.Left;
  876. _notTotalAlign = TextAlignment.LeftOrTop;
  877. }
  878. else if (rbtnNotRight.Checked)
  879. {
  880. txtNotTotalValue.TextAlign = HorizontalAlignment.Right;
  881. _notTotalAlign = TextAlignment.RightOrBottom;
  882. }
  883. else if (rbtnNotCenter.Checked)
  884. {
  885. txtNotTotalValue.TextAlign = HorizontalAlignment.Center;
  886. _notTotalAlign = TextAlignment.Center;
  887. }
  888. else
  889. {
  890. txtNotTotalValue.TextAlign = HorizontalAlignment.Left;
  891. _notTotalAlign = TextAlignment.Evenness;
  892. }
  893. if (rbtnNotTop.Checked)
  894. {;
  895. _notTotalAlignVertical = TextAlignment.LeftOrTop;
  896. }
  897. else if (rbtnNotBottom.Checked)
  898. {
  899. _notTotalAlignVertical = TextAlignment.RightOrBottom;
  900. }
  901. else if (rbtnNotCenterV.Checked)
  902. {
  903. _notTotalAlignVertical = TextAlignment.Center;
  904. }
  905. else
  906. {
  907. _notTotalAlignVertical = TextAlignment.LeftOrTop;
  908. }
  909. }
  910. /// <summary>
  911. /// 设置非合计文本字体。
  912. /// </summary>
  913. /// <param name="sender">指定的对象</param>
  914. /// <param name="e">提供的事件数据</param>
  915. private void btnNotFont_Click(object sender, System.EventArgs e)
  916. {
  917. fontDialog.Font = txtNotTotalValue.Font;
  918. if (fontDialog.ShowDialog() == DialogResult.OK)
  919. {
  920. txtNotTotalValue.Font = fontDialog.Font;
  921. }
  922. }
  923. /// <summary>
  924. /// 设置非合计文本颜色
  925. /// </summary>
  926. /// <param name="sender">指定的对象</param>
  927. /// <param name="e">提供的事件数据</param>
  928. private void btnNotColor_Click(object sender, System.EventArgs e)
  929. {
  930. colorDialog.Color = txtNotTotalValue.ForeColor;
  931. if (colorDialog.ShowDialog() == DialogResult.OK)
  932. {
  933. txtNotTotalValue.ForeColor = colorDialog.Color;
  934. }
  935. }
  936. #endregion 非合计文本
  937. #endregion 事件处理
  938. }
  939. }