U_Comput.cs 28 KB

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