/// <summary> /// Instantiates and sets the barcode properties based on the settings. /// </summary> /// <returns>Instantiated and set up barcode.</returns> private BarCode AssembleBarCode() { BarCode barCode = GetBarCode(); barCode.Unit = _settings.Unit; barCode.Dpi = _settings.Dpi; barCode.BarHeight = _settings.BarHeight; barCode.OffsetWidth = _settings.OffsetWidth; barCode.OffsetHeight = _settings.OffsetHeight; barCode.TextPosition = _settings.TextPosition; barCode.BarColor = _settings.BarColor; barCode.BackColor = _settings.BackColor; barCode.FontColor = _settings.FontColor; barCode.Font = _settings.Font; if (barCode is IOptionalChecksum) { ((IOptionalChecksum)barCode).UseChecksum = _settings.UseChecksum; } if (barCode is EanUpc) { ((EanUpc)barCode).GuardExtraHeight = _settings.GuardExtraHeight; } if (barCode is ModuleBarCode) { ((ModuleBarCode)barCode).ModuleWidth = _settings.ModuleWidth; } if (barCode is ThicknessBarCode) { ((ThicknessBarCode)barCode).NarrowWidth = _settings.NarrowWidth; ((ThicknessBarCode)barCode).WideWidth = _settings.WideWidth; } return(barCode); }
public override void ImportSettings(BarCode barCode) { base.ImportSettings(barCode); if (barCode is EanUpc) { this.guardExtraHeight = ((EanUpc)barCode).GuardExtraHeight; } }
public override void ImportSettings(BarCode barCode) { base.ImportSettings(barCode); if (barCode is ThicknessBarCode) { this.WideWidth = ((ThicknessBarCode)barCode).WideWidth; this.NarrowWidth = ((ThicknessBarCode)barCode).NarrowWidth; } }
public override void ImportSettings(BarCode barCode) { base.ImportSettings(barCode); if (barCode is ModuleBarCode) { this.ModuleWidth = ((ModuleBarCode)barCode).ModuleWidth; } }
public virtual void ImportSettings(BarCode barCode) { barHeight = barCode.barHeight; offsetWidth = barCode.offsetWidth; offsetHeight = barCode.offsetHeight; textPosition = barCode.textPosition; barColor = barCode.barColor; backColor = barCode.backColor; fontColor = barCode.fontColor; font = barCode.font; if (this is IOptionalChecksum && barCode is IOptionalChecksum) { ((IOptionalChecksum)this).UseChecksum = ((IOptionalChecksum)barCode).UseChecksum; } }
/// <summary> /// Generates an image with the rendered barcode based on the settings (<see cref="IBarCodeSettings"/>). /// </summary> /// <returns>The generated barcode image.</returns> /// <exception cref="BarCodeFormatException"> /// If the data in the settings can't be rendered by the selected barcode. /// </exception> public Image GenerateImage() { BarCode bc = AssembleBarCode(); return(bc.DrawImage(_settings.Data)); }
/// <summary> /// Tests if the barcode would render with the given settings (<see cref="IBarCodeSettings"/>), without format errors. /// </summary> /// <param name="errorMessage">Outputs the error message if a <see cref="BarCodeFormatException"/> was thrown.</param> /// <returns><c>True</c> if the barcode rendering test went ok, <c>false</c> otherwise.</returns> public bool TestRender(out string errorMessage) { BarCode bc = AssembleBarCode(); return(bc.TestRender(_settings.Data, out errorMessage)); }