Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 public override void ImportSettings(BarCode barCode)
 {
     base.ImportSettings(barCode);
     if (barCode is EanUpc)
     {
         this.guardExtraHeight =
             ((EanUpc)barCode).GuardExtraHeight;
     }
 }
Ejemplo n.º 3
0
 public override void ImportSettings(BarCode barCode)
 {
     base.ImportSettings(barCode);
     if (barCode is ThicknessBarCode)
     {
         this.WideWidth   = ((ThicknessBarCode)barCode).WideWidth;
         this.NarrowWidth = ((ThicknessBarCode)barCode).NarrowWidth;
     }
 }
Ejemplo n.º 4
0
 public override void ImportSettings(BarCode barCode)
 {
     base.ImportSettings(barCode);
     if (barCode is ModuleBarCode)
     {
         this.ModuleWidth =
             ((ModuleBarCode)barCode).ModuleWidth;
     }
 }
Ejemplo n.º 5
0
 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;
     }
 }
Ejemplo n.º 6
0
        /// <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));
        }
Ejemplo n.º 7
0
        /// <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));
        }