Esempio n. 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));
                }
            }
        }
Esempio n. 2
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 content of the designer component in Visual Studio.
        /// </summary>
        public override void Draw(Graphics graphics, ReportItemDrawParams reportItemDrawParameters)
        {
            // initialization
            var         blackSolidBrush = new SolidBrush(Color.Black);
            var         graySolidBrush  = new SolidBrush(Color.Gray);
            const float margin          = 3f;

            // draw the name of the report item
            var nameText = Name;
            var nameFont = new Font("Arial", 10);

            graphics.DrawString(nameText, nameFont, blackSolidBrush, new PointF(margin, margin));

            // draw the name of the report item
            var codeText = Code.ToString();
            var codeFont = new Font("Courier New", 8);
            var codeYPos = margin + graphics.MeasureString(nameText, nameFont).Height + 8f;

            graphics.DrawString(codeText, codeFont, graySolidBrush, new PointF(margin, codeYPos));
        }
        public override void Draw(Graphics gr, ReportItemDrawParams dp)
        {
            if (gr == null)
            {
                throw new ArgumentNullException("gr");
            }

            int pixelWidth  = (int)Math.Round(Width);
            int pixelHeight = (int)Math.Round(Height);

            if (pixelWidth > pixelHeight)
            {
                pixelWidth = pixelHeight;
            }
            else
            {
                pixelHeight = pixelWidth;
            }

            int alpha = 255;

            Color      color                = Color.FromArgb(alpha, Style.Color.Value.Color);
            Color      borderColor          = Style.Border.Color.Value.Color;
            Pen        borderPen            = new Pen(borderColor);
            SolidBrush colorBrush           = new SolidBrush(color);
            SolidBrush backgroundColorBrush = new SolidBrush(Style.BackgroundColor.Value.Color);

            gr.FillRectangle(backgroundColorBrush, 0, 0, pixelWidth, pixelHeight);
            gr.FillRectangle(colorBrush, 3 * pixelWidth / 8, 3 * pixelHeight / 8, pixelWidth / 2, pixelHeight / 2);
            gr.DrawRectangle(borderPen, 3 * pixelWidth / 8, 3 * pixelHeight / 8, pixelWidth / 2, pixelHeight / 2);
            Point[] points = new Point[3];
            points[0] = new Point(3 * pixelWidth / 8, pixelHeight / 8);
            points[1] = new Point(pixelWidth / 8, 3 * pixelHeight / 5);
            points[2] = new Point(5 * pixelWidth / 8, 3 * pixelHeight / 5);
            gr.FillPolygon(colorBrush, points);
            gr.DrawPolygon(borderPen, points);
            borderPen.Dispose();
            colorBrush.Dispose();
            backgroundColorBrush.Dispose();
        }
        /// <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));
                }
            }
        }