示例#1
0
        /// <summary>
        /// Draws the design-time representation of the barcode.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="dp">The dp.</param>
        public override void Draw(Graphics g, ReportItemDrawParams dp)
        {
            // Our background is always white
            if (dp.DrawBackground)
            {
                g.Clear(Color.White);
            }

            // Delegate drawing of outlines
            if (dp.DrawOutlines)
            {
                base.Draw(g, dp.AsOutlinesOnly());
            }

            // Draw content if we can...
            if (dp.DrawContent &&
                Symbology != BarcodeSymbology.Unknown &&
                !string.IsNullOrEmpty(Text))
            {
                BarcodeDraw drawObject =
                    BarcodeDrawFactory.GetSymbology(Symbology);
                using (System.Drawing.Image image = drawObject.Draw(
                           Text,
                           InterGlyphSpacing,
                           MinimumBarHeight,
                           MaximumBarHeight,
                           MinimumBarWidth,
                           MaximumBarWidth))
                {
                    g.DrawImage(image, new Point(0, 0));
                }
            }
        }
        /// <summary>
        /// Draws the design-time representation of the barcode.
        /// </summary>
        /// <param name="g">
        /// A <see cref="Graphics"/> object representing the designer surface.
        /// </param>
        /// <param name="dp">
        /// A <see cref="ReportItemDrawParams"/> containing draw parameters.
        /// </param>
        public override void Draw(Graphics g, ReportItemDrawParams dp)
        {
            // Our background is always white
            if (dp.DrawBackground)
            {
                g.Clear(Color.White);
            }

            // Delegate drawing of outlines
            if (dp.DrawOutlines)
            {
                base.Draw(g, dp.AsOutlinesOnly());
            }

            // Draw content if we can...
            if (dp.DrawContent &&
                Symbology != BarcodeSymbology.Unknown &&
                !string.IsNullOrEmpty(Text))
            {
                BarcodeDraw drawObject =
                    BarcodeDrawFactory.GetSymbology(Symbology);

                BarcodeMetrics metrics = drawObject.GetDefaultMetrics(30);
                metrics.Scale = Scale;

                BarcodeMetrics1d metrics1d = metrics as BarcodeMetrics1d;
                if (metrics1d != null)
                {
                    metrics1d.InterGlyphSpacing = InterGlyphSpacing;
                    metrics1d.MaxHeight         = MaximumBarHeight;
                    metrics1d.MinHeight         = MinimumBarHeight;
                    metrics1d.MaxWidth          = MaximumBarWidth;
                    metrics1d.MinWidth          = MinimumBarWidth;
                    metrics1d.RenderVertically  = RenderVertically;
                }
                else if (Symbology == BarcodeSymbology.CodeQr)
                {
                    BarcodeMetricsQr qrMetrics = (BarcodeMetricsQr)metrics;
                    if (QrVersion != null)
                    {
                        qrMetrics.Version = QrVersion.Value;
                    }
                    if (QrEncodingMode != null)
                    {
                        qrMetrics.EncodeMode = QrEncodingMode.Value;
                    }
                    if (QrErrorCorrectionMode != null)
                    {
                        qrMetrics.ErrorCorrection = QrErrorCorrectionMode.Value;
                    }
                }
                using (System.Drawing.Image image = drawObject.Draw(Text, metrics))
                {
                    g.DrawImage(image, new Point(0, 0));
                }
            }
        }
        /// <summary>
        /// Draws the design-time representation of the barcode.
        /// </summary>
        /// <param name="g">
        /// A <see cref="Graphics"/> object representing the designer surface.
        /// </param>
        /// <param name="dp">
        /// A <see cref="ReportItemDrawParams"/> containing draw parameters.
        /// </param>
        public override void Draw(Graphics g, ReportItemDrawParams dp)
        {
            // Our background is always white
            if (dp.DrawBackground)
            {
                g.Clear(Color.White);
            }

            // Delegate drawing of outlines
            if (dp.DrawOutlines)
            {
                base.Draw(g, dp.AsOutlinesOnly());
            }

            // Draw content if we can...
            if (dp.DrawContent &&
                Symbology != BarcodeSymbology.Unknown &&
                !string.IsNullOrEmpty(Text))
            {
                BarcodeDraw drawObject =
                    BarcodeDrawFactory.GetSymbology(Symbology);

                BarcodeMetrics metrics = drawObject.GetDefaultMetrics(30);
                metrics.Scale = Scale;

                BarcodeMetrics1d metrics1d = metrics as BarcodeMetrics1d;
                if (metrics1d != null)
                {
                    metrics1d.InterGlyphSpacing = InterGlyphSpacing;
                    metrics1d.MaxHeight = MaximumBarHeight;
                    metrics1d.MinHeight = MinimumBarHeight;
                    metrics1d.MaxWidth = MaximumBarWidth;
                    metrics1d.MinWidth = MinimumBarWidth;
                    metrics1d.RenderVertically = RenderVertically;
                }
                else if (Symbology == BarcodeSymbology.CodeQr)
                {
                    BarcodeMetricsQr qrMetrics = (BarcodeMetricsQr)metrics;
                    if (QrVersion != null)
                    {
                        qrMetrics.Version = QrVersion.Value;
                    }
                    if (QrEncodingMode != null)
                    {
                        qrMetrics.EncodeMode = QrEncodingMode.Value;
                    }
                    if (QrErrorCorrectionMode != null)
                    {
                        qrMetrics.ErrorCorrection = QrErrorCorrectionMode.Value;
                    }
                }
                using (System.Drawing.Image image = drawObject.Draw(Text, metrics))
                {
                    g.DrawImage(image, new Point(0, 0));
                }
            }
        }
        /// <summary>
        /// Draws the design-time representation of the barcode.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="dp">The dp.</param>
        public override void Draw(Graphics g, ReportItemDrawParams dp)
        {
            // Our background is always white
            if (dp.DrawBackground)
            {
                g.Clear(Color.White);
            }

            // Delegate drawing of outlines
            if (dp.DrawOutlines)
            {
                base.Draw(g, dp.AsOutlinesOnly());
            }

            // Draw content if we can...
            if (dp.DrawContent &&
                Symbology != BarcodeSymbology.Unknown &&
                !string.IsNullOrEmpty(Text))
            {
                BarcodeDraw drawObject =
                    BarcodeDrawFactory.GetSymbology(Symbology);
                using (System.Drawing.Image image = drawObject.Draw(
                    Text,
                    InterGlyphSpacing,
                    MinimumBarHeight,
                    MaximumBarHeight,
                    MinimumBarWidth,
                    MaximumBarWidth))
                {
                    g.DrawImage(image, new Point(0, 0));
                }
            }
        }