TextItemSetting.cs 27 KB

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