TextItemSetting.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  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. }
  484. if (_itemStyle == ItemStyle.QRCode)
  485. {
  486. ddlQRCodeLevel.Visible = true;
  487. if (ddlQRCodeLevel.SelectedIndex == -1)
  488. {
  489. ddlQRCodeLevel.SelectedIndex = 0;
  490. }
  491. }
  492. if (_textAlign == TextAlignment.Evenness)
  493. {
  494. numCharSpace.Enabled = false;
  495. numCharSpace.Value = 0;
  496. numCharCount.Enabled = false;
  497. numCharCount.Value = 0;
  498. }
  499. else
  500. {
  501. if (0 < numCharCount.Value)
  502. {
  503. rbtnLeft.Checked = true;
  504. grbTextAlignment.Enabled = false;
  505. numCharSpace.Enabled = false;
  506. decimal characterSpace = LayoutCommon.EqualityChars(numWidth.Value,
  507. numCharCount.Value,
  508. txtPreview.Font);
  509. if (characterSpace < numCharSpace.Minimum)
  510. {
  511. characterSpace = numCharSpace.Minimum;
  512. }
  513. else if (numCharSpace.Maximum < characterSpace)
  514. {
  515. characterSpace = numCharSpace.Maximum;
  516. }
  517. numCharSpace.Value = LayoutCommon.Truncate(characterSpace,
  518. numCharSpace.DecimalPlaces);
  519. }
  520. }
  521. if (_sysFormat != null)
  522. {
  523. if (_itemStyle == ItemStyle.Date)
  524. {
  525. _sysFormat.DefaultView.RowFilter = "SignDispNo = 0";
  526. }
  527. else if (_itemStyle == ItemStyle.Sign)
  528. {
  529. _sysFormat.DefaultView.RowFilter = "DateDispNo = 0";
  530. }
  531. else
  532. {
  533. _sysFormat.DefaultView.RowFilter = string.Empty;
  534. }
  535. }
  536. if (grbTextAlignment.Enabled)
  537. {
  538. switch (_textAlign)
  539. {
  540. case TextAlignment.LeftOrTop:
  541. rbtnLeft.Checked = true;
  542. txtPreview.TextAlign = HorizontalAlignment.Left;
  543. break;
  544. case TextAlignment.RightOrBottom:
  545. rbtnRight.Checked = true;
  546. txtPreview.TextAlign = HorizontalAlignment.Right;
  547. break;
  548. case TextAlignment.Center:
  549. rbtnCenter.Checked = true;
  550. txtPreview.TextAlign = HorizontalAlignment.Center;
  551. break;
  552. case TextAlignment.Evenness:
  553. rbtnEvenness.Checked = true;
  554. txtPreview.TextAlign = HorizontalAlignment.Left;
  555. break;
  556. }
  557. }
  558. if (grbTextAlignmentV.Enabled)
  559. {
  560. switch (_textAlignVertical)
  561. {
  562. case TextAlignment.LeftOrTop:
  563. rbtnTop.Checked = true;
  564. break;
  565. case TextAlignment.RightOrBottom:
  566. rbtnBottom.Checked = true;
  567. break;
  568. case TextAlignment.Center:
  569. rbtnCenterV.Checked = true;
  570. break;
  571. default:
  572. rbtnTop.Checked = true;
  573. break;
  574. }
  575. }
  576. if (_isNew || !_isDataBinding)
  577. {
  578. if (_sysFormat != null)
  579. {
  580. ddlTextFormat.SelectedIndex = 0;
  581. }
  582. if (_sysDefaultValue != null)
  583. {
  584. ddlDefaultValue.SelectedIndex = 0;
  585. }
  586. }
  587. else
  588. {
  589. if (_sysFormat != null)
  590. {
  591. if (_itemStyle == ItemStyle.Date)
  592. {
  593. // 日期
  594. DataRow[] drs = _sysFormat.Select
  595. (string.Format("Format = '{0}' AND ('{1}' = '' OR Culture = '{1}') AND DateDispNo <> 0",
  596. _textFormat,
  597. _culture));
  598. if (drs != null && 0 < drs.Length)
  599. {
  600. ddlTextFormat.SelectedValue = drs[0]["FormatID"];
  601. }
  602. else
  603. {
  604. ddlTextFormat.Text = _textFormat;
  605. }
  606. }
  607. else if (_itemStyle == ItemStyle.Sign)
  608. {
  609. // 符号
  610. ddlTextFormat.ValueMember = "FormatName";
  611. ddlTextFormat.SelectedValue = _textFormat;
  612. if (ddlTextFormat.SelectedIndex < 0)
  613. {
  614. ddlTextFormat.Text = _textFormat;
  615. }
  616. }
  617. else if (_itemStyle == InvoiceLayout.ItemStyle.Barcode ||
  618. _itemStyle == InvoiceLayout.ItemStyle.QRCode ||
  619. _itemStyle == InvoiceLayout.ItemStyle.LinearGraph
  620. )
  621. {
  622. }
  623. else
  624. {
  625. ddlTextFormat.ValueMember = "Format";
  626. ddlTextFormat.SelectedValue = _textFormat;
  627. if (ddlTextFormat.SelectedIndex < 0)
  628. {
  629. ddlTextFormat.Text = _textFormat;
  630. }
  631. }
  632. }
  633. ddlDefaultValue.Text = _defaultValue;
  634. }
  635. }
  636. finally
  637. {
  638. _isInit = false;
  639. }
  640. }
  641. /// <summary>
  642. /// 设置文本颜色
  643. /// </summary>
  644. /// <param name="sender">指定的对象</param>
  645. /// <param name="e">提供的事件数据</param>
  646. private void btnSelectColor_Click(object sender, System.EventArgs e)
  647. {
  648. colorDialog.Color = txtPreview.ForeColor;
  649. if (colorDialog.ShowDialog() == DialogResult.OK)
  650. {
  651. txtPreview.ForeColor = colorDialog.Color;
  652. }
  653. }
  654. /// <summary>
  655. /// 设置文本格式
  656. /// </summary>
  657. /// <param name="sender">指定的对象</param>
  658. /// <param name="e">提供的事件数据</param>
  659. private void ddlTextFormat_SelectedIndexChanged(object sender, System.EventArgs e)
  660. {
  661. _culture = string.Empty;
  662. DataRowView dataRow = ddlTextFormat.SelectedItem as DataRowView;
  663. if (dataRow != null)
  664. {
  665. if (0 != System.Convert.ToInt32(dataRow["DateDispNo"]))
  666. {
  667. _itemStyle = ItemStyle.Date;
  668. _textFormat = dataRow["Format"].ToString();
  669. _culture = dataRow["Culture"].ToString();
  670. }
  671. else if (0 != System.Convert.ToInt32(dataRow["SignDispNo"]))
  672. {
  673. _itemStyle = ItemStyle.Sign;
  674. _textFormat = dataRow["FormatName"].ToString();
  675. }
  676. else
  677. {
  678. _itemStyle = ItemStyle.Text;
  679. _textFormat = dataRow["Format"].ToString();
  680. }
  681. }
  682. else
  683. {
  684. //if (_itemStyle != ItemStyle.Barcode)
  685. //{
  686. // _itemStyle = ItemStyle.Other;
  687. //}
  688. _textFormat = ddlTextFormat.Text;
  689. _culture = null;
  690. }
  691. }
  692. /// <summary>
  693. /// 设置文本对齐方式
  694. /// </summary>
  695. /// <param name="sender">指定的对象</param>
  696. /// <param name="e">提供的事件数据</param>
  697. private void rbtnTextAlignment_CheckedChanged(object sender, System.EventArgs e)
  698. {
  699. if (_isInit)
  700. {
  701. return;
  702. }
  703. if (rbtnLeft.Checked)
  704. {
  705. txtPreview.TextAlign = HorizontalAlignment.Left;
  706. _textAlign = TextAlignment.LeftOrTop;
  707. }
  708. else if (rbtnRight.Checked)
  709. {
  710. txtPreview.TextAlign = HorizontalAlignment.Right;
  711. _textAlign = TextAlignment.RightOrBottom;
  712. }
  713. else if (rbtnCenter.Checked)
  714. {
  715. txtPreview.TextAlign = HorizontalAlignment.Center;
  716. _textAlign = TextAlignment.Center;
  717. }
  718. else
  719. {
  720. txtPreview.TextAlign = HorizontalAlignment.Left;
  721. _textAlign = TextAlignment.Evenness;
  722. }
  723. if (rbtnTop.Checked)
  724. {
  725. _textAlignVertical = TextAlignment.LeftOrTop;
  726. }
  727. else if (rbtnBottom.Checked)
  728. {
  729. _textAlignVertical = TextAlignment.RightOrBottom;
  730. }
  731. else if (rbtnCenterV.Checked)
  732. {
  733. _textAlignVertical = TextAlignment.Center;
  734. }
  735. else
  736. {
  737. _textAlignVertical = TextAlignment.LeftOrTop;
  738. }
  739. if (rbtnEvenness.Checked)
  740. {
  741. numCharSpace.Enabled = false;
  742. numCharSpace.Value = 0;
  743. numCharCount.Enabled = false;
  744. numCharCount.Value = 0;
  745. }
  746. else
  747. {
  748. numCharSpace.Enabled = true;
  749. numCharCount.Enabled = true;
  750. }
  751. }
  752. /// <summary>
  753. /// 设置单行文字数
  754. /// </summary>
  755. /// <param name="sender">指定的对象</param>
  756. /// <param name="e">提供的事件数据</param>
  757. private void numCharCount_ValueChanged(object sender, System.EventArgs e)
  758. {
  759. if (_isInit)
  760. {
  761. return;
  762. }
  763. if (0 < numCharCount.Value)
  764. {
  765. rbtnLeft.Checked = true;
  766. grbTextAlignment.Enabled = false;
  767. numCharSpace.Enabled = false;
  768. decimal characterSpace = LayoutCommon.EqualityChars(
  769. numWidth.Value,
  770. numCharCount.Value,
  771. txtPreview.Font);
  772. if (characterSpace < numCharSpace.Minimum)
  773. {
  774. characterSpace = numCharSpace.Minimum;
  775. }
  776. else if (numCharSpace.Maximum < characterSpace)
  777. {
  778. characterSpace = numCharSpace.Maximum;
  779. }
  780. numCharSpace.Value = LayoutCommon.Truncate(characterSpace, numCharSpace.DecimalPlaces);
  781. }
  782. else
  783. {
  784. grbTextAlignment.Enabled = true;
  785. if (!rbtnEvenness.Checked)
  786. {
  787. numCharSpace.Enabled = true;
  788. }
  789. }
  790. }
  791. /// <summary>
  792. /// 设置文本字体。
  793. /// </summary>
  794. /// <param name="sender">指定的对象</param>
  795. /// <param name="e">提供的事件数据</param>
  796. private void txtPreview_FontChanged(object sender, System.EventArgs e)
  797. {
  798. if (_isInit)
  799. {
  800. return;
  801. }
  802. if (0 < numCharCount.Value)
  803. {
  804. decimal characterSpace = LayoutCommon.EqualityChars(
  805. numWidth.Value,
  806. numCharCount.Value,
  807. txtPreview.Font);
  808. if (characterSpace < numCharSpace.Minimum)
  809. {
  810. characterSpace = numCharSpace.Minimum;
  811. }
  812. else if (numCharSpace.Maximum < characterSpace)
  813. {
  814. characterSpace = numCharSpace.Maximum;
  815. }
  816. numCharSpace.Value = LayoutCommon.Truncate(characterSpace,
  817. numCharSpace.DecimalPlaces);
  818. }
  819. }
  820. /// <summary>
  821. /// 设置文本字体。
  822. /// </summary>
  823. /// <param name="sender">指定的对象</param>
  824. /// <param name="e">提供的事件数据</param>
  825. private void btnFont_Click(object sender, System.EventArgs e)
  826. {
  827. fontDialog.Font = TextFont;
  828. if (fontDialog.ShowDialog() == DialogResult.OK)
  829. {
  830. TextFont = fontDialog.Font;
  831. }
  832. }
  833. private void chkPic_CheckedChanged(object sender, System.EventArgs e)
  834. {
  835. chkM.Enabled = chkPic.Checked;
  836. chkFixedRatio.Enabled = chkPic.Checked;
  837. }
  838. #endregion 事件处理
  839. private void btnOK_Click(object sender, System.EventArgs e)
  840. {
  841. }
  842. }
  843. }