BarcodeObject.DesignExt.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using FastReport.Utils;
  5. using FastReport.Forms;
  6. namespace FastReport.Barcode
  7. {
  8. partial class BarcodeObject : IHasEditor
  9. {
  10. #region Private Methods
  11. private bool ShouldSerializePadding()
  12. {
  13. return Padding != new System.Windows.Forms.Padding();
  14. }
  15. #endregion
  16. #region Public Methods
  17. /// <inheritdoc/>
  18. public override SmartTagBase GetSmartTag()
  19. {
  20. return new BarcodeSmartTag(this);
  21. }
  22. /// <inheritdoc/>
  23. public override ContextMenuBase GetContextMenu()
  24. {
  25. return new BarcodeObjectMenu(Report.Designer);
  26. }
  27. /// <inheritdoc/>
  28. public override SizeF GetPreferredSize()
  29. {
  30. if ((Page as ReportPage).IsImperialUnitsUsed)
  31. return new SizeF(Units.Inches * 1, Units.Inches * 1);
  32. return new SizeF(Units.Centimeters * 2.5f, Units.Centimeters * 2.5f);
  33. }
  34. /// <inheritdoc/>
  35. public override void OnBeforeInsert(int flags)
  36. {
  37. Barcode = (BarcodeBase)Activator.CreateInstance(Barcodes.Items[flags].objType);
  38. Text = barcode.GetDefaultValue();
  39. }
  40. /// <inheritdoc/>
  41. public bool InvokeEditor()
  42. {
  43. bool res = false;
  44. bool isRichBarcode = false;
  45. if (Barcode is BarcodeQR || Barcode is BarcodeAztec)
  46. isRichBarcode = true;
  47. using (BarcodeEditorForm form = new BarcodeEditorForm(Text, Report, Brackets, isRichBarcode))
  48. {
  49. if (!form.IsDisposed)
  50. {
  51. DialogResult result = form.ShowDialog();
  52. if (result == DialogResult.OK)
  53. {
  54. AllowExpressions = true;
  55. Text = form.result;
  56. res = true;
  57. }
  58. }
  59. }
  60. return res;
  61. }
  62. /// <inheritdoc/>
  63. public override int GetImageIndex()
  64. {
  65. return Barcode is Barcode2DBase ? 149 : 123;
  66. }
  67. #endregion
  68. }
  69. }