U_Express.cs 28 KB

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