U_Bar.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  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_Bar : UserControl, ICustomTypeDescriptor, IControl
  18. {
  19. public enum BarCode
  20. {
  21. EAN13,
  22. ENA8,
  23. Code39,
  24. Code128,
  25. Code128A,
  26. Code128B,
  27. Code128C,
  28. Codabar,
  29. Code11,
  30. Code25,
  31. Code25_Stand,
  32. ISBN,
  33. CODE39Extended
  34. }
  35. private class XpropDescriptor : PropertyDescriptor
  36. {
  37. private string theProp;
  38. private U_Bar mycc;
  39. public override Type ComponentType => GetType();
  40. public override bool IsReadOnly => false;
  41. public override Type PropertyType
  42. {
  43. get
  44. {
  45. switch (theProp.ToLower())
  46. {
  47. case "isprint":
  48. return mycc.IsPrint.GetType();
  49. case "x":
  50. return mycc.X.GetType();
  51. case "y":
  52. return mycc.Y.GetType();
  53. case "ewidth":
  54. return mycc.EWidth.GetType();
  55. case "eheight":
  56. return mycc.EHeight.GetType();
  57. case "linewidth":
  58. return mycc.LineWidth.GetType();
  59. case "linecolor":
  60. return mycc.LineColor.GetType();
  61. case "filledcolor":
  62. return mycc.FilledColor.GetType();
  63. case "textvalue":
  64. return mycc.TextValue.GetType();
  65. case "bartype":
  66. return mycc.BarType.GetType();
  67. case "leftborder":
  68. return mycc.LeftBorder.GetType();
  69. case "rightborder":
  70. return mycc.RightBorder.GetType();
  71. case "topborder":
  72. return mycc.TopBorder.GetType();
  73. case "bottomborder":
  74. return mycc.BottomBorder.GetType();
  75. case "margins":
  76. return mycc.Margins.GetType();
  77. case "textfont":
  78. return mycc.TextFont.GetType();
  79. case "textcolor":
  80. return mycc.TextColor.GetType();
  81. case "isprintlabel":
  82. return mycc.IsPrintLabel.GetType();
  83. default:
  84. Interaction.MsgBox("Property过程编程错误,属性名称[" + theProp + "]未找到", MsgBoxStyle.OkOnly, "提示信息");
  85. return null;
  86. }
  87. }
  88. }
  89. public XpropDescriptor(U_Bar cc, string prop, Attribute[] attrs)
  90. : base(prop, attrs)
  91. {
  92. theProp = cc.GetPropertyEnglishName(prop);
  93. mycc = cc;
  94. }
  95. public override bool CanResetValue(object component)
  96. {
  97. return false;
  98. }
  99. public override object GetValue(object component)
  100. {
  101. switch (theProp.ToLower())
  102. {
  103. case "isprint":
  104. return mycc.IsPrint;
  105. case "x":
  106. return mycc.X;
  107. case "y":
  108. return mycc.Y;
  109. case "ewidth":
  110. return mycc.EWidth;
  111. case "eheight":
  112. return mycc.EHeight;
  113. case "linewidth":
  114. return mycc.LineWidth;
  115. case "linecolor":
  116. return mycc.LineColor;
  117. case "filledcolor":
  118. return mycc.FilledColor;
  119. case "textvalue":
  120. return mycc.TextValue;
  121. case "bartype":
  122. return mycc.BarType;
  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 "textfont":
  134. return mycc.TextFont;
  135. case "textcolor":
  136. return mycc.TextColor;
  137. case "isprintlabel":
  138. return mycc.IsPrintLabel;
  139. default:
  140. Interaction.MsgBox("GetValue过程编程错误,属性名称[" + theProp + "]未找到", MsgBoxStyle.OkOnly, "提示信息");
  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 "textvalue":
  182. mycc.TextValue = Conversions.ToString(value);
  183. break;
  184. case "bartype":
  185. mycc.BarType = (BarCode)Conversions.ToInteger(value);
  186. break;
  187. case "leftborder":
  188. mycc.LeftBorder = Conversions.ToBoolean(value);
  189. break;
  190. case "rightborder":
  191. mycc.RightBorder = Conversions.ToBoolean(value);
  192. break;
  193. case "topborder":
  194. mycc.TopBorder = Conversions.ToBoolean(value);
  195. break;
  196. case "bottomborder":
  197. mycc.BottomBorder = Conversions.ToBoolean(value);
  198. break;
  199. case "margins":
  200. mycc.Margins = (Margins)value;
  201. break;
  202. case "textfont":
  203. mycc.TextFont = (Font)value;
  204. break;
  205. case "textcolor":
  206. {
  207. Color black = Color.Black;
  208. mycc.TextColor = ((value != null) ? ((Color)value) : black);
  209. break;
  210. }
  211. case "isprintlabel":
  212. mycc.IsPrintLabel = Conversions.ToBoolean(value);
  213. break;
  214. default:
  215. Interaction.MsgBox("SetValue过程编程错误,属性名称[" + theProp + "]未找到", MsgBoxStyle.OkOnly, "提示信息");
  216. break;
  217. }
  218. }
  219. public override bool ShouldSerializeValue(object component)
  220. {
  221. return false;
  222. }
  223. }
  224. private IContainer components;
  225. private float MYX;
  226. private float MYY;
  227. private bool theisprint;
  228. private float thelinewidth;
  229. private Color thelinecolor;
  230. private Color thefilledcolor;
  231. private Font thetextfont;
  232. private Color thetextcolor;
  233. private string thetext;
  234. private bool theleftborder;
  235. private bool thetopborder;
  236. private bool therightborder;
  237. private bool thebottomborder;
  238. private Margins themargins;
  239. private BarCode mybartype;
  240. private bool myisprintlabel;
  241. private string[,] DefineProperty;
  242. [Category("行为")]
  243. [Description("指示是否在条形码的下方打印条形码内容的文本标签,为True表示要打印,为False表示不打印")]
  244. public bool IsPrintLabel
  245. {
  246. get
  247. {
  248. return myisprintlabel;
  249. }
  250. set
  251. {
  252. myisprintlabel = value;
  253. }
  254. }
  255. [Category("行为")]
  256. [Description("以套打模式打印或预览时,是否打印该控件的内容")]
  257. public bool IsPrint
  258. {
  259. get
  260. {
  261. return theisprint;
  262. }
  263. set
  264. {
  265. theisprint = value;
  266. }
  267. }
  268. [Category("布局")]
  269. [Description("控件所处的X位置,以毫米为计量单位")]
  270. public float X
  271. {
  272. get
  273. {
  274. return ConvertToMM(base.Left, isX: true);
  275. }
  276. set
  277. {
  278. base.Left = checked((int)Math.Round(ConvertFromMM(value, isx: true)));
  279. }
  280. }
  281. [Category("布局")]
  282. [Description("控件所处的Y位置,以毫米为计量单位")]
  283. public float Y
  284. {
  285. get
  286. {
  287. return ConvertToMM(base.Top, isX: false);
  288. }
  289. set
  290. {
  291. base.Top = checked((int)Math.Round(ConvertFromMM(value, isx: false)));
  292. }
  293. }
  294. [Category("布局")]
  295. [Description("控件的宽度,以毫米为计量单位")]
  296. public float EWidth
  297. {
  298. get
  299. {
  300. return ConvertToMM(base.Width, isX: true);
  301. }
  302. set
  303. {
  304. base.Width = checked((int)Math.Round(ConvertFromMM(value, isx: true)));
  305. }
  306. }
  307. [Category("布局")]
  308. [Description("控件的高度,以毫米为计量单位")]
  309. public float EHeight
  310. {
  311. get
  312. {
  313. return ConvertToMM(base.Height, isX: false);
  314. }
  315. set
  316. {
  317. base.Height = checked((int)Math.Round(ConvertFromMM(value, isx: false)));
  318. }
  319. }
  320. [Category("外观")]
  321. [Description("边线宽度,不是直线的长度,以毫米为计量单位, 必须大于等于0")]
  322. public float LineWidth
  323. {
  324. get
  325. {
  326. return thelinewidth;
  327. }
  328. set
  329. {
  330. if (value < 0f)
  331. {
  332. value = 0f;
  333. }
  334. thelinewidth = value;
  335. Invalidate();
  336. }
  337. }
  338. [Category("外观")]
  339. [Description("边框线条颜色")]
  340. public Color LineColor
  341. {
  342. get
  343. {
  344. return thelinecolor;
  345. }
  346. set
  347. {
  348. thelinecolor = value;
  349. Invalidate();
  350. }
  351. }
  352. [Category("外观")]
  353. [Description("条形码文字及线条颜色")]
  354. public Color TextColor
  355. {
  356. get
  357. {
  358. return thetextcolor;
  359. }
  360. set
  361. {
  362. thetextcolor = value;
  363. Invalidate();
  364. }
  365. }
  366. [Category("外观")]
  367. [Description("条码填充背景颜色")]
  368. public Color FilledColor
  369. {
  370. get
  371. {
  372. return thefilledcolor;
  373. }
  374. set
  375. {
  376. thefilledcolor = value;
  377. Invalidate();
  378. }
  379. }
  380. [Category("外观")]
  381. [Description("条码字体,指打印在条码下方的条码文本的字体")]
  382. public Font TextFont
  383. {
  384. get
  385. {
  386. return thetextfont;
  387. }
  388. set
  389. {
  390. if (value != null)
  391. {
  392. thetextfont = (Font)value.Clone();
  393. Invalidate();
  394. }
  395. }
  396. }
  397. [Category("外观")]
  398. [Editor(typeof(U_Editor), typeof(UITypeEditor))]
  399. [Description("要打印的条码内容,可以包含纯文本、系统变量、自定义变量和字段变量的组合。但是,不同的条码是有字符范围限制的,如果字符超出条码范围,则该条码不会被打印")]
  400. public string TextValue
  401. {
  402. get
  403. {
  404. return thetext;
  405. }
  406. set
  407. {
  408. thetext = value;
  409. Invalidate();
  410. }
  411. }
  412. [Description("要打印的条码类型)")]
  413. [Category("外观")]
  414. public BarCode BarType
  415. {
  416. get
  417. {
  418. return mybartype;
  419. }
  420. set
  421. {
  422. mybartype = value;
  423. }
  424. }
  425. [Category("边框")]
  426. [Description("是否显示左边框")]
  427. public bool LeftBorder
  428. {
  429. get
  430. {
  431. return theleftborder;
  432. }
  433. set
  434. {
  435. theleftborder = value;
  436. Invalidate();
  437. }
  438. }
  439. [Category("边框")]
  440. [Description("是否显示右边框")]
  441. public bool RightBorder
  442. {
  443. get
  444. {
  445. return therightborder;
  446. }
  447. set
  448. {
  449. therightborder = value;
  450. Invalidate();
  451. }
  452. }
  453. [Description("是否显示上边框")]
  454. [Category("边框")]
  455. public bool TopBorder
  456. {
  457. get
  458. {
  459. return thetopborder;
  460. }
  461. set
  462. {
  463. thetopborder = value;
  464. Invalidate();
  465. }
  466. }
  467. [Description("是否显示下边框")]
  468. [Category("边框")]
  469. public bool BottomBorder
  470. {
  471. get
  472. {
  473. return thebottomborder;
  474. }
  475. set
  476. {
  477. thebottomborder = value;
  478. Invalidate();
  479. }
  480. }
  481. [Category("外观")]
  482. [Description("单元格文本与边框的间距,计量单位为毫米,且必须是整数")]
  483. public Margins Margins
  484. {
  485. get
  486. {
  487. return themargins;
  488. }
  489. set
  490. {
  491. themargins = value;
  492. Invalidate();
  493. }
  494. }
  495. [DebuggerNonUserCode]
  496. protected override void Dispose(bool disposing)
  497. {
  498. try
  499. {
  500. if (disposing && components != null)
  501. {
  502. components.Dispose();
  503. if (thetextfont != null)
  504. {
  505. thetextfont.Dispose();
  506. }
  507. }
  508. }
  509. finally
  510. {
  511. base.Dispose(disposing);
  512. }
  513. }
  514. [System.Diagnostics.DebuggerStepThrough]
  515. private void InitializeComponent()
  516. {
  517. base.SuspendLayout();
  518. System.Drawing.SizeF sizeF = new System.Drawing.SizeF(6f, 12f);
  519. base.AutoScaleDimensions = sizeF;
  520. base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  521. this.BackColor = System.Drawing.Color.Transparent;
  522. this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
  523. System.Windows.Forms.Padding margin = new System.Windows.Forms.Padding(0);
  524. base.Margin = margin;
  525. base.Name = "U_bar";
  526. System.Drawing.Size size = new System.Drawing.Size(82, 49);
  527. base.Size = size;
  528. base.ResumeLayout(false);
  529. }
  530. public float ConvertToMM(float tt, bool isX)
  531. {
  532. if (isX)
  533. {
  534. return (float)Math.Round((double)(tt / MYX) * 2.54 * 10.0, 2);
  535. }
  536. return (float)Math.Round((double)(tt / MYY) * 2.54 * 10.0, 2);
  537. }
  538. public float ConvertFromMM(float tt, bool isx)
  539. {
  540. if (isx)
  541. {
  542. return (float)((double)(tt * MYX) / 2.54 / 10.0);
  543. }
  544. return (float)((double)(tt * MYY) / 2.54 / 10.0);
  545. }
  546. public string GetPropertyEnglishName(string cname)
  547. {
  548. bool flag = false;
  549. int num = 0;
  550. checked
  551. {
  552. int num2 = DefineProperty.GetLength(0) - 1;
  553. int i;
  554. for (i = num; i <= num2; i++)
  555. {
  556. if (Operators.CompareString(DefineProperty[i, 1].ToUpper(), cname.ToUpper(), TextCompare: false) == 0)
  557. {
  558. flag = true;
  559. break;
  560. }
  561. }
  562. if (flag)
  563. {
  564. return DefineProperty[i, 0];
  565. }
  566. return cname;
  567. }
  568. }
  569. public string GetPropertyChineseName(string ename)
  570. {
  571. bool flag = false;
  572. int num = 0;
  573. checked
  574. {
  575. int num2 = DefineProperty.GetLength(0) - 1;
  576. int i;
  577. for (i = num; i <= num2; i++)
  578. {
  579. if (Operators.CompareString(DefineProperty[i, 0].ToUpper(), ename.ToUpper(), TextCompare: false) == 0)
  580. {
  581. flag = true;
  582. break;
  583. }
  584. }
  585. if (flag)
  586. {
  587. return DefineProperty[i, 1];
  588. }
  589. return ename;
  590. }
  591. }
  592. protected override void OnPaint(PaintEventArgs e)
  593. {
  594. base.OnPaint(e);
  595. float num = ConvertFromMM(LineWidth, isx: true);
  596. Pen pen = new Pen(LineColor, num);
  597. BackColor = FilledColor;
  598. if (LeftBorder)
  599. {
  600. e.Graphics.DrawLine(pen, num / 2f, num / 2f, num / 2f, (float)base.Height - num - 1f);
  601. }
  602. if (RightBorder)
  603. {
  604. e.Graphics.DrawLine(pen, (float)base.Width - num - 1f, num / 2f, (float)base.Width - num - 1f, (float)base.Height - num - 1f);
  605. }
  606. if (TopBorder)
  607. {
  608. e.Graphics.DrawLine(pen, num / 2f, num / 2f, (float)base.Width - num - 1f, num / 2f);
  609. }
  610. if (BottomBorder)
  611. {
  612. e.Graphics.DrawLine(pen, num / 2f, (float)base.Height - num - 1f, (float)base.Width - num - 1f, (float)base.Height - num - 1f);
  613. }
  614. StringFormat stringFormat = new StringFormat(StringFormat.GenericTypographic);
  615. StringFormatFlags formatFlags = stringFormat.FormatFlags;
  616. formatFlags |= StringFormatFlags.NoWrap;
  617. formatFlags |= StringFormatFlags.NoClip;
  618. formatFlags &= ~StringFormatFlags.DirectionVertical;
  619. stringFormat.FormatFlags = formatFlags;
  620. stringFormat.Alignment = StringAlignment.Near;
  621. stringFormat.LineAlignment = StringAlignment.Near;
  622. Graphics graphics = e.Graphics;
  623. string textValue = TextValue;
  624. Font textFont = TextFont;
  625. Brush brush = new SolidBrush(TextColor);
  626. RectangleF layoutRectangle = checked(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)));
  627. graphics.DrawString(textValue, textFont, brush, layoutRectangle, stringFormat);
  628. }
  629. protected override void OnResize(EventArgs e)
  630. {
  631. base.OnResize(e);
  632. Invalidate();
  633. }
  634. public U_Bar()
  635. {
  636. base.Disposed += U_Bar_Disposed;
  637. theisprint = true;
  638. thelinewidth = 0f;
  639. thelinecolor = Color.Black;
  640. thefilledcolor = Color.Transparent;
  641. thetextfont = new Font("宋体", 9f);
  642. thetextcolor = Color.Black;
  643. thetext = "条码控件";
  644. theleftborder = false;
  645. thetopborder = false;
  646. therightborder = false;
  647. thebottomborder = false;
  648. themargins = new Margins(1, 0, 0, 0);
  649. mybartype = BarCode.Code39;
  650. myisprintlabel = true;
  651. DefineProperty = new string[3, 2];
  652. InitializeComponent();
  653. MYX = CreateGraphics().DpiX;
  654. MYY = CreateGraphics().DpiY;
  655. DefineProperty = new string[18, 2];
  656. DefineProperty[0, 0] = "IsPrint";
  657. DefineProperty[0, 1] = "是否套打";
  658. DefineProperty[1, 0] = "X";
  659. DefineProperty[1, 1] = "X位置";
  660. DefineProperty[2, 0] = "Y";
  661. DefineProperty[2, 1] = "Y位置";
  662. DefineProperty[3, 0] = "EWidth";
  663. DefineProperty[3, 1] = "宽度";
  664. DefineProperty[4, 0] = "LineWidth";
  665. DefineProperty[4, 1] = "线宽";
  666. DefineProperty[5, 0] = "LineColor";
  667. DefineProperty[5, 1] = "线条颜色";
  668. DefineProperty[6, 0] = "EHeight";
  669. DefineProperty[6, 1] = "高度";
  670. DefineProperty[7, 0] = "FilledColor";
  671. DefineProperty[7, 1] = "填充颜色";
  672. DefineProperty[8, 0] = "TextValue";
  673. DefineProperty[8, 1] = "条码文本";
  674. DefineProperty[9, 0] = "BarType";
  675. DefineProperty[9, 1] = "条码类型";
  676. DefineProperty[10, 0] = "LeftBorder";
  677. DefineProperty[10, 1] = "左边框";
  678. DefineProperty[11, 0] = "RightBorder";
  679. DefineProperty[11, 1] = "右边框";
  680. DefineProperty[12, 0] = "TopBorder";
  681. DefineProperty[12, 1] = "上边框";
  682. DefineProperty[13, 0] = "BottomBorder";
  683. DefineProperty[13, 1] = "下边框";
  684. DefineProperty[14, 0] = "Margins";
  685. DefineProperty[14, 1] = "边距";
  686. DefineProperty[15, 0] = "TextFont";
  687. DefineProperty[15, 1] = "字体";
  688. DefineProperty[16, 0] = "TextColor";
  689. DefineProperty[16, 1] = "前景颜色";
  690. DefineProperty[17, 0] = "IsPrintLabel";
  691. DefineProperty[17, 1] = "打印标签";
  692. }
  693. public AttributeCollection GetAttributes()
  694. {
  695. return TypeDescriptor.GetAttributes(this, noCustomTypeDesc: true);
  696. }
  697. public string GetClassName()
  698. {
  699. return TypeDescriptor.GetClassName(this, noCustomTypeDesc: true);
  700. }
  701. public string GetComponentName()
  702. {
  703. return TypeDescriptor.GetClassName(this, noCustomTypeDesc: true);
  704. }
  705. public TypeConverter GetConverter()
  706. {
  707. return TypeDescriptor.GetConverter(this, noCustomTypeDesc: true);
  708. }
  709. public EventDescriptor GetDefaultEvent()
  710. {
  711. return TypeDescriptor.GetDefaultEvent(this, noCustomTypeDesc: true);
  712. }
  713. public PropertyDescriptor GetDefaultProperty()
  714. {
  715. return TypeDescriptor.GetDefaultProperty(this, noCustomTypeDesc: true);
  716. }
  717. public object GetEditor(Type editorBaseType)
  718. {
  719. return TypeDescriptor.GetEditor(this, editorBaseType, noCustomTypeDesc: true);
  720. }
  721. public EventDescriptorCollection GetEvents()
  722. {
  723. return TypeDescriptor.GetEvents(this, noCustomTypeDesc: true);
  724. }
  725. public EventDescriptorCollection GetEvents(Attribute[] attributes)
  726. {
  727. return TypeDescriptor.GetEvents(this, attributes, noCustomTypeDesc: true);
  728. }
  729. public PropertyDescriptorCollection GetProperties()
  730. {
  731. return TypeDescriptor.GetProperties(this, noCustomTypeDesc: true);
  732. }
  733. public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
  734. {
  735. checked
  736. {
  737. PropertyDescriptor[] array = new PropertyDescriptor[DefineProperty.GetLength(0) - 1 + 1];
  738. int num = 0;
  739. int num2 = array.Length - 1;
  740. for (int i = num; i <= num2; i++)
  741. {
  742. Type type = GetType();
  743. PropertyInfo[] properties = type.GetProperties();
  744. PropertyInfo[] array2 = properties;
  745. foreach (PropertyInfo propertyInfo in array2)
  746. {
  747. if (Operators.CompareString(propertyInfo.Name.ToUpper(), DefineProperty[i, 0].ToUpper(), TextCompare: false) == 0)
  748. {
  749. attributes = Attribute.GetCustomAttributes(propertyInfo);
  750. break;
  751. }
  752. }
  753. array[i] = new XpropDescriptor(this, DefineProperty[i, 1], attributes);
  754. }
  755. return new PropertyDescriptorCollection(array);
  756. }
  757. }
  758. public object GetPropertyOwner(PropertyDescriptor pd)
  759. {
  760. return this;
  761. }
  762. private void U_Bar_Disposed(object sender, EventArgs e)
  763. {
  764. try
  765. {
  766. DefineProperty = null;
  767. thetextfont = null;
  768. }
  769. catch (Exception projectError)
  770. {
  771. ProjectData.SetProjectError(projectError);
  772. ProjectData.ClearProjectError();
  773. }
  774. }
  775. public void RestoreFromString(string ss)
  776. {
  777. string[] array = Strings.Split(ss, mbsjmodule.G_MB_Spetator_Proper);
  778. if (Operators.CompareString(array[0], "1", TextCompare: false) == 0)
  779. {
  780. IsPrint = true;
  781. }
  782. else
  783. {
  784. IsPrint = false;
  785. }
  786. X = Conversions.ToSingle(array[1]);
  787. Y = Conversions.ToSingle(array[2]);
  788. EWidth = Conversions.ToSingle(array[3]);
  789. LineWidth = Conversions.ToSingle(array[4]);
  790. LineColor = Module1.ConvertStringToColor(array[5]);
  791. EHeight = Conversions.ToSingle(array[6]);
  792. LeftBorder = Conversions.ToBoolean(array[7]);
  793. RightBorder = Conversions.ToBoolean(array[8]);
  794. TopBorder = Conversions.ToBoolean(array[9]);
  795. BottomBorder = Conversions.ToBoolean(array[10]);
  796. FilledColor = Module1.ConvertStringToColor(array[11]);
  797. BarType = (BarCode)Conversions.ToInteger(array[12]);
  798. TextFont = Module1.ConvertStringToFont(array[13]);
  799. Margins = new Margins(Conversions.ToInteger(array[14]), Conversions.ToInteger(array[15]), Conversions.ToInteger(array[16]), Conversions.ToInteger(array[17]));
  800. TextValue = array[18];
  801. TextColor = Module1.ConvertStringToColor(array[19]);
  802. try
  803. {
  804. IsPrintLabel = Conversions.ToBoolean(array[20]);
  805. }
  806. catch (Exception projectError)
  807. {
  808. ProjectData.SetProjectError(projectError);
  809. IsPrintLabel = true;
  810. ProjectData.ClearProjectError();
  811. }
  812. }
  813. public string SaveAsString()
  814. {
  815. string text = ((!IsPrint) ? "0" : "1");
  816. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(X);
  817. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Y);
  818. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(EWidth);
  819. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(LineWidth);
  820. text = text + mbsjmodule.G_MB_Spetator_Proper + Module1.ConvertColorToString(LineColor);
  821. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(EHeight);
  822. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(LeftBorder, "1", "0"));
  823. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(RightBorder, "1", "0"));
  824. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(TopBorder, "1", "0"));
  825. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(BottomBorder, "1", "0"));
  826. text = text + mbsjmodule.G_MB_Spetator_Proper + Module1.ConvertColorToString(FilledColor);
  827. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString((int)BarType);
  828. text = text + mbsjmodule.G_MB_Spetator_Proper + Module1.ConvertFontToString(TextFont);
  829. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Margins.Left);
  830. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Margins.Right);
  831. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Margins.Top);
  832. text = text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Margins.Bottom);
  833. text = text + mbsjmodule.G_MB_Spetator_Proper + TextValue;
  834. text = text + mbsjmodule.G_MB_Spetator_Proper + Module1.ConvertColorToString(TextColor);
  835. return text + mbsjmodule.G_MB_Spetator_Proper + Conversions.ToString(Interaction.IIf(IsPrintLabel, "1", "0"));
  836. }
  837. }
  838. }