123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using FastReport.Utils;
- using FastReport.Forms;
- namespace FastReport.Barcode
- {
- partial class BarcodeObject : IHasEditor
- {
- #region Private Methods
- private bool ShouldSerializePadding()
- {
- return Padding != new System.Windows.Forms.Padding();
- }
- #endregion
- #region Public Methods
- /// <inheritdoc/>
- public override SmartTagBase GetSmartTag()
- {
- return new BarcodeSmartTag(this);
- }
- /// <inheritdoc/>
- public override ContextMenuBase GetContextMenu()
- {
- return new BarcodeObjectMenu(Report.Designer);
- }
- /// <inheritdoc/>
- public override SizeF GetPreferredSize()
- {
- if ((Page as ReportPage).IsImperialUnitsUsed)
- return new SizeF(Units.Inches * 1, Units.Inches * 1);
- return new SizeF(Units.Centimeters * 2.5f, Units.Centimeters * 2.5f);
- }
- /// <inheritdoc/>
- public override void OnBeforeInsert(int flags)
- {
- Barcode = (BarcodeBase)Activator.CreateInstance(Barcodes.Items[flags].objType);
- Text = barcode.GetDefaultValue();
- }
- /// <inheritdoc/>
- public bool InvokeEditor()
- {
- bool res = false;
- bool isRichBarcode = false;
- if (Barcode is BarcodeQR || Barcode is BarcodeAztec)
- isRichBarcode = true;
- using (BarcodeEditorForm form = new BarcodeEditorForm(Text, Report, Brackets, isRichBarcode))
- {
- if (!form.IsDisposed)
- {
- DialogResult result = form.ShowDialog();
- if (result == DialogResult.OK)
- {
- AllowExpressions = true;
- Text = form.result;
- res = true;
- }
- }
- }
- return res;
- }
- /// <inheritdoc/>
- public override int GetImageIndex()
- {
- return Barcode is Barcode2DBase ? 149 : 123;
- }
- #endregion
- }
- }
|