GridItemColumnSetting.cs 35 KB

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