예제 #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);
        }
예제 #2
0
파일: EanUpc.cs 프로젝트: zyj0021/nbarcodes
 public override void ImportSettings(BarCode barCode)
 {
     base.ImportSettings(barCode);
     if (barCode is EanUpc)
     {
         this.guardExtraHeight =
             ((EanUpc)barCode).GuardExtraHeight;
     }
 }
예제 #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;
     }
 }
예제 #4
0
 public override void ImportSettings(BarCode barCode)
 {
     base.ImportSettings(barCode);
     if (barCode is ModuleBarCode)
     {
         this.ModuleWidth =
             ((ModuleBarCode)barCode).ModuleWidth;
     }
 }
예제 #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;
     }
 }
예제 #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));
        }
예제 #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));
        }