U_Text.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. using System;
  2. using System.ComponentModel;
  3. using System.Diagnostics;
  4. using System.Drawing;
  5. using System.Drawing.Design;
  6. using System.Drawing.Printing;
  7. using System.Reflection;
  8. using System.Windows.Forms;
  9. using Microsoft.VisualBasic;
  10. using Microsoft.VisualBasic.CompilerServices;
  11. namespace Dongke.IBOSS.PRD.Framework.Controls
  12. {
  13. [DesignerGenerated]
  14. [EditorBrowsable(EditorBrowsableState.Never)]
  15. [ToolboxItem(false)]
  16. [Browsable(false)]
  17. public class U_Text : UserControl, ICustomTypeDescriptor, IControl
  18. {
  19. private class XpropDescriptor : PropertyDescriptor
  20. {
  21. private string theProp;
  22. private U_Text mycc;
  23. public override Type ComponentType => GetType();
  24. public override bool IsReadOnly => false;
  25. public override Type PropertyType
  26. {
  27. get
  28. {
  29. switch (theProp.ToLower())
  30. {
  31. case "isprint":
  32. return mycc.IsPrint.GetType();
  33. case "x":
  34. return mycc.X.GetType();
  35. case "y":
  36. return mycc.Y.GetType();
  37. case "ewidth":
  38. return mycc.EWidth.GetType();
  39. case "eheight":
  40. return mycc.EHeight.GetType();
  41. case "linewidth":
  42. return mycc.LineWidth.GetType();
  43. case "linecolor":
  44. return mycc.LineColor.GetType();
  45. case "filledcolor":
  46. return mycc.FilledColor.GetType();
  47. case "textalign":
  48. return mycc.TextAlign.GetType();
  49. case "textvalue":
  50. return mycc.TextValue.GetType();
  51. case "textfont":
  52. return mycc.TextFont.GetType();
  53. case "textcolor":
  54. return mycc.TextColor.GetType();
  55. case "cols":
  56. return mycc.Cols.GetType();
  57. case "mulline":
  58. return mycc.Mulline.GetType();
  59. case "leftborder":
  60. return mycc.LeftBorder.GetType();
  61. case "rightborder":
  62. return mycc.RightBorder.GetType();
  63. case "topborder":
  64. return mycc.TopBorder.GetType();
  65. case "bottomborder":
  66. return mycc.BottomBorder.GetType();
  67. case "margins":
  68. return mycc.Margins.GetType();
  69. case "direction":
  70. return mycc.Direction.GetType();
  71. case "istdborder":
  72. return mycc.IsTdBorder.GetType();
  73. case "istdbackcolor":
  74. return mycc.IsTdBackColor.GetType();
  75. default:
  76. Interaction.MsgBox("Property过程编程错误,属性名称[" + theProp + "]未找到");
  77. return null;
  78. }
  79. }
  80. }
  81. public XpropDescriptor(U_Text cc, string prop, Attribute[] attrs)
  82. : base(prop, attrs)
  83. {
  84. theProp = cc.GetPropertyEnglishName(prop);
  85. mycc = cc;
  86. }
  87. public override bool CanResetValue(object component)
  88. {
  89. return false;
  90. }
  91. public override object GetValue(object component)
  92. {
  93. switch (theProp.ToLower())
  94. {
  95. case "isprint":
  96. return mycc.IsPrint;
  97. case "x":
  98. return mycc.X;
  99. case "y":
  100. return mycc.Y;
  101. case "ewidth":
  102. return mycc.EWidth;
  103. case "eheight":
  104. return mycc.EHeight;
  105. case "linewidth":
  106. return mycc.LineWidth;
  107. case "linecolor":
  108. return mycc.LineColor;
  109. case "filledcolor":
  110. return mycc.FilledColor;
  111. case "textalign":
  112. return mycc.TextAlign;
  113. case "textvalue":
  114. return mycc.TextValue;
  115. case "textfont":
  116. return mycc.TextFont;
  117. case "textcolor":
  118. return mycc.TextColor;
  119. case "cols":
  120. return mycc.Cols;
  121. case "mulline":
  122. return mycc.Mulline;
  123. case "leftborder":
  124. return mycc.LeftBorder;
  125. case "rightborder":
  126. return mycc.RightBorder;
  127. case "topborder":
  128. return mycc.TopBorder;
  129. case "bottomborder":
  130. return mycc.BottomBorder;
  131. case "margins":
  132. return mycc.Margins;
  133. case "direction":
  134. return mycc.Direction;
  135. case "istdborder":
  136. return mycc.IsTdBorder;
  137. case "istdbackcolor":
  138. return mycc.IsTdBackColor;
  139. default:
  140. Interaction.MsgBox("GetValue过程编程错误,属性名称[" + theProp + "]未找到");
  141. return null;
  142. }
  143. }
  144. public override void ResetValue(object component)
  145. {
  146. }
  147. public override void SetValue(object component, object value)
  148. {
  149. switch (theProp.ToLower())
  150. {
  151. case "isprint":
  152. mycc.IsPrint = Conversions.ToBoolean(value);
  153. break;
  154. case "x":
  155. mycc.X = Conversions.ToSingle(value);
  156. break;
  157. case "y":
  158. mycc.Y = Conversions.ToSingle(value);
  159. break;
  160. case "ewidth":
  161. mycc.EWidth = Conversions.ToSingle(value);
  162. break;
  163. case "eheight":
  164. mycc.EHeight = Conversions.ToSingle(value);
  165. break;
  166. case "linewidth":
  167. mycc.LineWidth = Conversions.ToSingle(value);
  168. break;
  169. case "linecolor":
  170. {
  171. Color black3 = Color.Black;
  172. mycc.LineColor = ((value != null) ? ((Color)value) : black3);
  173. break;
  174. }
  175. case "filledcolor":
  176. {
  177. Color black2 = Color.Black;
  178. mycc.FilledColor = ((value != null) ? ((Color)value) : black2);
  179. break;
  180. }
  181. case "textalign":
  182. mycc.TextAlign = (ContentAlignment)Conversions.ToInteger(value);
  183. break;
  184. case "textvalue":
  185. mycc.TextValue = Conversions.ToString(value);
  186. break;
  187. case "textfont":
  188. mycc.TextFont = (Font)value;
  189. break;
  190. case "textcolor":
  191. {
  192. Color black = Color.Black;
  193. mycc.TextColor = ((value != null) ? ((Color)value) : black);
  194. break;
  195. }
  196. case "cols":
  197. mycc.Cols = Conversions.ToInteger(value);
  198. break;
  199. case "mulline":
  200. mycc.Mulline = Conversions.ToBoolean(value);
  201. break;
  202. case "leftborder":
  203. mycc.LeftBorder = Conversions.ToBoolean(value);
  204. break;
  205. case "rightborder":
  206. mycc.RightBorder = Conversions.ToBoolean(value);
  207. break;
  208. case "topborder":
  209. mycc.TopBorder = Conversions.ToBoolean(value);
  210. break;
  211. case "bottomborder":
  212. mycc.BottomBorder = Conversions.ToBoolean(value);
  213. break;
  214. case "margins":
  215. mycc.Margins = (Margins)value;
  216. break;
  217. case "direction":
  218. mycc.Direction = Conversions.ToBoolean(value);
  219. break;
  220. case "istdborder":
  221. mycc.IsTdBorder = Conversions.ToBoolean(value);
  222. break;
  223. case "istdbackcolor":
  224. mycc.IsTdBackColor = Conversions.ToBoolean(value);
  225. break;
  226. default:
  227. Interaction.MsgBox("SetValue过程编程错误,属性名称[" + theProp + "]未找到");
  228. break;
  229. }
  230. }
  231. public override bool ShouldSerializeValue(object component)
  232. {
  233. return false;
  234. }
  235. }
  236. private IContainer components;
  237. private float MYX;
  238. private float MYY;
  239. private bool theisprint;
  240. private float thelinewidth;
  241. private Color thelinecolor;
  242. private Color thefilledcolor;
  243. private ContentAlignment thetextalign;
  244. private string thetext;
  245. private Font thetextfont;
  246. private Color thetextcolor;
  247. private int thecols;
  248. private bool themulline;
  249. private bool theleftborder;
  250. private bool thetopborder;
  251. private bool therightborder;
  252. private bool thebottomborder;
  253. private Margins themargins;
  254. private bool thedirection;
  255. private bool theistdborder;
  256. private bool theistdbackcolor;
  257. public string[,] DefineProperty;
  258. [Description("以套打模式打印或预览时,是否打印该控件的背景颜色(填充颜色)")]
  259. [Category("行为")]
  260. public bool IsTdBackColor
  261. {
  262. get
  263. {
  264. return theistdbackcolor;
  265. }
  266. set
  267. {
  268. theistdbackcolor = value;
  269. }
  270. }
  271. [Description("以套打模式打印或预览时,是否打印该控件的边框(如果设置为显示边框的话)")]
  272. [Category("行为")]
  273. public bool IsTdBorder
  274. {
  275. get
  276. {
  277. return theistdborder;
  278. }
  279. set
  280. {
  281. theistdborder = value;
  282. }
  283. }
  284. [Description("以套打模式打印或预览时,是否打印该控件的内容")]
  285. [Category("行为")]
  286. public bool IsPrint
  287. {
  288. get
  289. {
  290. return theisprint;
  291. }
  292. set
  293. {
  294. theisprint = value;
  295. }
  296. }
  297. [Description("控件所处的X位置,以毫米为计量单位")]
  298. [Category("布局")]
  299. public float X
  300. {
  301. get
  302. {
  303. return ConvertToMM(base.Left, isX: true);
  304. }
  305. set
  306. {
  307. base.Left = checked((int)Math.Round(ConvertFromMM(value, isx: true)));
  308. }
  309. }
  310. [Category("布局")]
  311. [Description("控件所处的Y位置,以毫米为计量单位")]
  312. public float Y
  313. {
  314. get
  315. {
  316. return ConvertToMM(base.Top, isX: false);
  317. }
  318. set
  319. {
  320. base.Top = checked((int)Math.Round(ConvertFromMM(value, isx: false)));
  321. }
  322. }
  323. [Description("控件的宽度,以毫米为计量单位")]
  324. [Category("布局")]
  325. public float EWidth
  326. {
  327. get
  328. {
  329. return ConvertToMM(base.Width, isX: true);
  330. }
  331. set
  332. {
  333. base.Width = checked((int)Math.Round(ConvertFromMM(value, isx: true)));
  334. }
  335. }
  336. [Category("布局")]
  337. [Description("控件的高度,以毫米为计量单位")]
  338. public float EHeight
  339. {
  340. get
  341. {
  342. return ConvertToMM(base.Height, isX: false);
  343. }
  344. set
  345. {
  346. base.Height = checked((int)Math.Round(ConvertFromMM(value, isx: false)));
  347. }
  348. }
  349. [Category("外观")]
  350. [Description("边线宽度,不是直线的长度,以毫米为计量单位, 必须大于等于0")]
  351. public float LineWidth
  352. {
  353. get
  354. {
  355. return thelinewidth;
  356. }
  357. set
  358. {
  359. if (value < 0f)
  360. {
  361. value = 0f;
  362. }
  363. thelinewidth = value;
  364. Invalidate();
  365. }
  366. }
  367. [Description("线条颜色")]
  368. [Category("外观")]
  369. public Color LineColor
  370. {
  371. get
  372. {
  373. return thelinecolor;
  374. }
  375. set
  376. {
  377. thelinecolor = value;
  378. Invalidate();
  379. }
  380. }
  381. [Category("外观")]
  382. [Description("文本背景颜色")]
  383. public Color FilledColor
  384. {
  385. get
  386. {
  387. return thefilledcolor;
  388. }
  389. set
  390. {
  391. thefilledcolor = value;
  392. Invalidate();
  393. }
  394. }
  395. [Description("文本对齐方式")]
  396. [Category("外观")]
  397. public ContentAlignment TextAlign
  398. {
  399. get
  400. {
  401. return thetextalign;
  402. }
  403. set
  404. {
  405. thetextalign = value;
  406. Invalidate();
  407. }
  408. }
  409. [Category("外观")]
  410. [Description("要打印的文本内容,可以包含纯文本、系统变量、自定义变量和字段变量的组合")]
  411. [Editor(typeof(U_Editor), typeof(UITypeEditor))]
  412. public string TextValue
  413. {
  414. get
  415. {
  416. return thetext;
  417. }
  418. set
  419. {
  420. thetext = value;
  421. Invalidate();
  422. }
  423. }
  424. [Description("文本字体")]
  425. [Category("外观")]
  426. public Font TextFont
  427. {
  428. get
  429. {
  430. return thetextfont;
  431. }
  432. set
  433. {
  434. if (value != null)
  435. {
  436. thetextfont = (Font)value.Clone();
  437. Invalidate();
  438. }
  439. }
  440. }
  441. [Description("文本前景颜色")]
  442. [Category("外观")]
  443. public Color TextColor
  444. {
  445. get
  446. {
  447. return thetextcolor;
  448. }
  449. set
  450. {
  451. thetextcolor = value;
  452. Invalidate();
  453. }
  454. }
  455. [Description("分散打印的列数(为1表示普通打印)")]
  456. [Category("外观")]
  457. public int Cols
  458. {
  459. get
  460. {
  461. return thecols;
  462. }
  463. set
  464. {
  465. if (value <= 0)
  466. {
  467. value = 1;
  468. }
  469. thecols = value;
  470. Invalidate();
  471. }
  472. }
  473. [Category("外观")]
  474. [Description("文本是否允许自动换行打印)")]
  475. public bool Mulline
  476. {
  477. get
  478. {
  479. return themulline;
  480. }
  481. set
  482. {
  483. themulline = value;
  484. Invalidate();
  485. }
  486. }
  487. [Description("是否显示左边框")]
  488. [Category("边框")]
  489. public bool LeftBorder
  490. {
  491. get
  492. {
  493. return theleftborder;
  494. }
  495. set
  496. {
  497. theleftborder = value;
  498. Invalidate();
  499. }
  500. }
  501. [Description("是否显示右边框")]
  502. [Category("边框")]
  503. public bool RightBorder
  504. {
  505. get
  506. {
  507. return therightborder;
  508. }
  509. set
  510. {
  511. therightborder = value;
  512. Invalidate();
  513. }
  514. }
  515. [Category("边框")]
  516. [Description("是否显示上边框")]
  517. public bool TopBorder
  518. {
  519. get
  520. {
  521. return thetopborder;
  522. }
  523. set
  524. {
  525. thetopborder = value;
  526. Invalidate();
  527. }
  528. }
  529. [Description("是否显示下边框")]
  530. [Category("边框")]
  531. public bool BottomBorder
  532. {
  533. get
  534. {
  535. return thebottomborder;
  536. }
  537. set
  538. {
  539. thebottomborder = value;
  540. Invalidate();
  541. }
  542. }
  543. [Description("单元格文本与边框的间距,计量单位为毫米,且必须是整数")]
  544. [Category("外观")]
  545. public Margins Margins
  546. {
  547. get
  548. {
  549. return themargins;
  550. }
  551. set
  552. {
  553. themargins = value;
  554. Invalidate();
  555. }
  556. }
  557. [Description("文本的打印方向,为False表示是从左至右的方向,为True表示从上至下的打印方向")]
  558. [Category("外观")]
  559. public bool Direction
  560. {
  561. get
  562. {
  563. return thedirection;
  564. }
  565. set
  566. {
  567. thedirection = value;
  568. Invalidate();
  569. }
  570. }
  571. [DebuggerNonUserCode]
  572. protected override void Dispose(bool disposing)
  573. {
  574. try
  575. {
  576. if (disposing && components != null)
  577. {
  578. components.Dispose();
  579. if (thetextfont != null)
  580. {
  581. thetextfont.Dispose();
  582. }
  583. }
  584. }
  585. finally
  586. {
  587. base.Dispose(disposing);
  588. }
  589. }
  590. [System.Diagnostics.DebuggerStepThrough]
  591. private void InitializeComponent()
  592. {
  593. base.SuspendLayout();
  594. System.Drawing.SizeF sizeF = new System.Drawing.SizeF(6f, 12f);
  595. base.AutoScaleDimensions = sizeF;
  596. base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  597. this.BackColor = System.Drawing.Color.Transparent;
  598. System.Windows.Forms.Padding margin = new System.Windows.Forms.Padding(0);
  599. base.Margin = margin;
  600. base.Name = "U_Text";
  601. System.Drawing.Size size = new System.Drawing.Size(169, 37);
  602. base.Size = size;
  603. base.ResumeLayout(false);
  604. }
  605. public float ConvertToMM(float tt, bool isX)
  606. {
  607. if (isX)
  608. {
  609. return (float)Math.Round((double)(tt / MYX) * 2.54 * 10.0, 2);
  610. }
  611. return (float)Math.Round((double)(tt / MYY) * 2.54 * 10.0, 2);
  612. }
  613. public float ConvertFromMM(float tt, bool isx)
  614. {
  615. if (isx)
  616. {
  617. return (float)((double)(tt * MYX) / 2.54 / 10.0);
  618. }
  619. return (float)((double)(tt * MYY) / 2.54 / 10.0);
  620. }
  621. public string GetPropertyEnglishName(string cname)
  622. {
  623. bool flag = false;
  624. int num = 0;
  625. checked
  626. {
  627. int num2 = DefineProperty.GetLength(0) - 1;
  628. int i;
  629. for (i = num; i <= num2; i++)
  630. {
  631. if (Operators.CompareString(DefineProperty[i, 1].ToUpper(), cname.ToUpper(), TextCompare: false) == 0)
  632. {
  633. flag = true;
  634. break;
  635. }
  636. }
  637. if (flag)
  638. {
  639. return DefineProperty[i, 0];
  640. }
  641. return cname;
  642. }
  643. }
  644. public string GetPropertyChineseName(string ename)
  645. {
  646. bool flag = false;
  647. int num = 0;
  648. checked
  649. {
  650. int num2 = DefineProperty.GetLength(0) - 1;
  651. int i;
  652. for (i = num; i <= num2; i++)
  653. {
  654. if (Operators.CompareString(DefineProperty[i, 0].ToUpper(), ename.ToUpper(), TextCompare: false) == 0)
  655. {
  656. flag = true;
  657. break;
  658. }
  659. }
  660. if (flag)
  661. {
  662. return DefineProperty[i, 1];
  663. }
  664. return ename;
  665. }
  666. }
  667. protected override void OnPaint(PaintEventArgs e)
  668. {
  669. base.OnPaint(e);
  670. float num = ConvertFromMM(LineWidth, isx: true);
  671. Pen pen = new Pen(LineColor, num);
  672. e.Graphics.FillRectangle(new SolidBrush(FilledColor), 0, 0, base.Width, base.Height);
  673. if (LeftBorder)
  674. {
  675. e.Graphics.DrawLine(pen, num / 2f, num / 2f, num / 2f, (float)base.Height - num);
  676. }
  677. if (RightBorder)
  678. {
  679. e.Graphics.DrawLine(pen, (float)base.Width - num, num / 2f, (float)base.Width - num, (float)base.Height - num / 2f);
  680. }
  681. if (TopBorder)
  682. {
  683. e.Graphics.DrawLine(pen, num / 2f, num / 2f, (float)base.Width - num, num / 2f);
  684. }
  685. if (BottomBorder)
  686. {
  687. e.Graphics.DrawLine(pen, num / 2f, (float)base.Height - num, (float)base.Width - num, (float)base.Height - num);
  688. }
  689. StringFormat stringFormat = new StringFormat(StringFormat.GenericTypographic);
  690. StringFormatFlags formatFlags = stringFormat.FormatFlags;
  691. formatFlags = (Mulline ? (formatFlags & ~StringFormatFlags.NoWrap) : (formatFlags | StringFormatFlags.NoWrap));
  692. formatFlags |= StringFormatFlags.NoClip;
  693. formatFlags = ((!Direction) ? (formatFlags & ~StringFormatFlags.DirectionVertical) : (formatFlags | StringFormatFlags.DirectionVertical));
  694. stringFormat.FormatFlags = formatFlags;
  695. stringFormat.Alignment = mbsjmodule.GetHalign(TextAlign);
  696. stringFormat.LineAlignment = mbsjmodule.GetValign(TextAlign);
  697. Graphics graphics = e.Graphics;
  698. string textValue = TextValue;
  699. Font textFont = TextFont;
  700. Brush brush = new SolidBrush(TextColor);
  701. checked
  702. {
  703. RectangleF layoutRectangle = new RectangleF(ConvertFromMM(Margins.Left, isx: true), ConvertFromMM(Margins.Top, isx: false), (float)base.Width - ConvertFromMM(Margins.Left + Margins.Right, isx: true), (float)base.Height - ConvertFromMM(Margins.Top + Margins.Bottom, isx: false));
  704. graphics.DrawString(textValue, textFont, brush, layoutRectangle, stringFormat);
  705. float num2 = (float)((double)base.Width / (double)Cols);
  706. float num3 = (float)((double)base.Height / (double)Cols);
  707. if (Direction)
  708. {
  709. int num4 = 1;
  710. int num5 = Cols - 1;
  711. for (int i = num4; i <= num5; i++)
  712. {
  713. float num6 = num3 * (float)i;
  714. e.Graphics.DrawLine(pen, num / 2f, num6 + num / 2f, base.Width, num6 + num / 2f);
  715. }
  716. }
  717. else
  718. {
  719. int num7 = 1;
  720. int num8 = Cols - 1;
  721. for (int j = num7; j <= num8; j++)
  722. {
  723. float num9 = num2 * (float)j;
  724. e.Graphics.DrawLine(pen, num9 + num / 2f, 0f, num9 + num / 2f, base.Height);
  725. }
  726. }
  727. }
  728. }
  729. protected override void OnResize(EventArgs e)
  730. {
  731. base.OnResize(e);
  732. Invalidate();
  733. }
  734. public U_Text()
  735. {
  736. base.Disposed += U_Text_Disposed;
  737. theisprint = true;
  738. thelinewidth = 0.2f;
  739. thelinecolor = Color.Black;
  740. thefilledcolor = Color.Transparent;
  741. thetextalign = ContentAlignment.MiddleLeft;
  742. thetext = "文本控件";
  743. thetextfont = new Font("宋体", 9f);
  744. thetextcolor = Color.Black;
  745. thecols = 1;
  746. themulline = true;
  747. theleftborder = false;
  748. thetopborder = false;
  749. therightborder = false;
  750. thebottomborder = false;
  751. themargins = new Margins(1, 1, 0, 0);
  752. thedirection = false;
  753. theistdborder = false;
  754. theistdbackcolor = false;
  755. DefineProperty = new string[3, 2];
  756. InitializeComponent();
  757. MYX = CreateGraphics().DpiX;
  758. MYY = CreateGraphics().DpiY;
  759. DefineProperty = new string[22, 2];
  760. DefineProperty[0, 0] = "IsPrint";
  761. DefineProperty[0, 1] = "是否套打";
  762. DefineProperty[1, 0] = "X";
  763. DefineProperty[1, 1] = "X位置";
  764. DefineProperty[2, 0] = "Y";
  765. DefineProperty[2, 1] = "Y位置";
  766. DefineProperty[3, 0] = "EWidth";
  767. DefineProperty[3, 1] = "宽度";
  768. DefineProperty[4, 0] = "LineWidth";
  769. DefineProperty[4, 1] = "线宽";
  770. DefineProperty[5, 0] = "LineColor";
  771. DefineProperty[5, 1] = "线条颜色";
  772. DefineProperty[6, 0] = "EHeight";
  773. DefineProperty[6, 1] = "高度";
  774. DefineProperty[7, 0] = "FilledColor";
  775. DefineProperty[7, 1] = "填充颜色";
  776. DefineProperty[8, 0] = "TextAlign";
  777. DefineProperty[8, 1] = "文本对齐方式";
  778. DefineProperty[9, 0] = "TextValue";
  779. DefineProperty[9, 1] = "文本";
  780. DefineProperty[10, 0] = "TextFont";
  781. DefineProperty[10, 1] = "字体";
  782. DefineProperty[11, 0] = "TextColor";
  783. DefineProperty[11, 1] = "文本颜色";
  784. DefineProperty[12, 0] = "Cols";
  785. DefineProperty[12, 1] = "分列打印";
  786. DefineProperty[13, 0] = "Mulline";
  787. DefineProperty[13, 1] = "自动换行";
  788. DefineProperty[14, 0] = "LeftBorder";
  789. DefineProperty[14, 1] = "左边框";
  790. DefineProperty[15, 0] = "RightBorder";
  791. DefineProperty[15, 1] = "右边框";
  792. DefineProperty[16, 0] = "TopBorder";
  793. DefineProperty[16, 1] = "上边框";
  794. DefineProperty[17, 0] = "BottomBorder";
  795. DefineProperty[17, 1] = "下边框";
  796. DefineProperty[18, 0] = "Margins";
  797. DefineProperty[18, 1] = "边距";
  798. DefineProperty[19, 0] = "Direction";
  799. DefineProperty[19, 1] = "文本方向";
  800. DefineProperty[20, 0] = "IsTdBorder";
  801. DefineProperty[20, 1] = "套打边框";
  802. DefineProperty[21, 0] = "IsTdBackColor";
  803. DefineProperty[21, 1] = "套打背景颜色";
  804. }
  805. public AttributeCollection GetAttributes()
  806. {
  807. return TypeDescriptor.GetAttributes(this, noCustomTypeDesc: true);
  808. }
  809. public string GetClassName()
  810. {
  811. return TypeDescriptor.GetClassName(this, noCustomTypeDesc: true);
  812. }
  813. public string GetComponentName()
  814. {
  815. return TypeDescriptor.GetClassName(this, noCustomTypeDesc: true);
  816. }
  817. public TypeConverter GetConverter()
  818. {
  819. return TypeDescriptor.GetConverter(this, noCustomTypeDesc: true);
  820. }
  821. public EventDescriptor GetDefaultEvent()
  822. {
  823. return TypeDescriptor.GetDefaultEvent(this, noCustomTypeDesc: true);
  824. }
  825. public PropertyDescriptor GetDefaultProperty()
  826. {
  827. return TypeDescriptor.GetDefaultProperty(this, noCustomTypeDesc: true);
  828. }
  829. public object GetEditor(Type editorBaseType)
  830. {
  831. return TypeDescriptor.GetEditor(this, editorBaseType, noCustomTypeDesc: true);
  832. }
  833. public EventDescriptorCollection GetEvents()
  834. {
  835. return TypeDescriptor.GetEvents(this, noCustomTypeDesc: true);
  836. }
  837. public EventDescriptorCollection GetEvents(Attribute[] attributes)
  838. {
  839. return TypeDescriptor.GetEvents(this, attributes, noCustomTypeDesc: true);
  840. }
  841. public PropertyDescriptorCollection GetProperties()
  842. {
  843. return TypeDescriptor.GetProperties(this, noCustomTypeDesc: true);
  844. }
  845. public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
  846. {
  847. checked
  848. {
  849. PropertyDescriptor[] array = new PropertyDescriptor[DefineProperty.GetLength(0) - 1 + 1];
  850. int num = 0;
  851. int num2 = array.Length - 1;
  852. for (int i = num; i <= num2; i++)
  853. {
  854. Type type = GetType();
  855. PropertyInfo[] properties = type.GetProperties();
  856. PropertyInfo[] array2 = properties;
  857. foreach (PropertyInfo propertyInfo in array2)
  858. {
  859. if (Operators.CompareString(propertyInfo.Name.ToUpper(), DefineProperty[i, 0].ToUpper(), TextCompare: false) == 0)
  860. {
  861. attributes = Attribute.GetCustomAttributes(propertyInfo);
  862. break;
  863. }
  864. }
  865. array[i] = new XpropDescriptor(this, DefineProperty[i, 1], attributes);
  866. }
  867. return new PropertyDescriptorCollection(array);
  868. }
  869. }
  870. public object GetPropertyOwner(PropertyDescriptor pd)
  871. {
  872. return this;
  873. }
  874. private void U_Text_Disposed(object sender, EventArgs e)
  875. {
  876. try
  877. {
  878. DefineProperty = null;
  879. thetextfont = null;
  880. }
  881. catch (Exception projectError)
  882. {
  883. ProjectData.SetProjectError(projectError);
  884. ProjectData.ClearProjectError();
  885. }
  886. }
  887. public void RestoreFromString(string ss)
  888. {
  889. string[] array = Strings.Split(ss, mbsjmodule.G_MB_Spetator_Proper);
  890. if (Operators.CompareString(array[0], "1", TextCompare: false) == 0)
  891. {
  892. IsPrint = true;
  893. }
  894. else
  895. {
  896. IsPrint = false;
  897. }
  898. X = Conversions.ToSingle(array[1]);
  899. Y = Conversions.ToSingle(array[2]);
  900. EWidth = Conversions.ToSingle(array[3]);
  901. LineWidth = Conversions.ToSingle(array[4]);
  902. LineColor = Module1.ConvertStringToColor(array[5]);
  903. EHeight = Conversions.ToSingle(array[6]);
  904. LeftBorder = Conversions.ToBoolean(array[7]);
  905. RightBorder = Conversions.ToBoolean(array[8]);
  906. TopBorder = Conversions.ToBoolean(array[9]);
  907. BottomBorder = Conversions.ToBoolean(array[10]);
  908. FilledColor = Module1.ConvertStringToColor(array[11]);
  909. TextAlign = (ContentAlignment)Conversions.ToInteger(array[12]);
  910. TextFont = Module1.ConvertStringToFont(array[13]);
  911. TextColor = Module1.ConvertStringToColor(array[14]);
  912. Cols = Conversions.ToInteger(array[15]);
  913. Mulline = Conversions.ToBoolean(array[16]);
  914. Margins = new Margins(Conversions.ToInteger(array[17]), Conversions.ToInteger(array[18]), Conversions.ToInteger(array[19]), Conversions.ToInteger(array[20]));
  915. TextValue = array[21];
  916. Direction = Conversions.ToBoolean(array[22]);
  917. IsTdBorder = Conversions.ToBoolean(array[23]);
  918. IsTdBackColor = Conversions.ToBoolean(array[24]);
  919. }
  920. public string SaveAsString()
  921. {
  922. string text = ((!IsPrint) ? "0" : "1");
  923. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(X);
  924. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Y);
  925. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(EWidth);
  926. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(LineWidth);
  927. text = text + mbsjmodule.G_MB_Spetator_Proper + Module1.ConvertColorToString(LineColor);
  928. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(EHeight);
  929. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(LeftBorder, "1", "0"));
  930. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(RightBorder, "1", "0"));
  931. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(TopBorder, "1", "0"));
  932. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(BottomBorder, "1", "0"));
  933. text = text + mbsjmodule.G_MB_Spetator_Proper + Module1.ConvertColorToString(FilledColor);
  934. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString((int)TextAlign);
  935. text = text + mbsjmodule.G_MB_Spetator_Proper + Module1.ConvertFontToString(TextFont);
  936. text = text + mbsjmodule.G_MB_Spetator_Proper + Module1.ConvertColorToString(TextColor);
  937. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Cols);
  938. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(Mulline, "1", "0"));
  939. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Margins.Left);
  940. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Margins.Right);
  941. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Margins.Top);
  942. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Margins.Bottom);
  943. text = text + mbsjmodule.G_MB_Spetator_Proper + TextValue;
  944. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(Direction, "1", "0"));
  945. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(IsTdBorder, "1", "0"));
  946. return text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(IsTdBackColor, "1", "0"));
  947. }
  948. }
  949. }