Пример #1
0
        public override void Draw(PointD start, int pageNumber)
        {
            base.Draw(start, pageNumber);

            start   = DocumentHelper.CurrentPageSettings.GetInPageDrawLocation(start);
            visSize = GetSize(start);

            PointD           contStart = GetContentStart(start);
            IDrawingProvider provider  = DocumentHelper.DrawingProvider;

            if (style.BgColorSpecified)
            {
                provider.FillRectangle(
                    start.X, start.Y,
                    visSize.Width, visSize.Height, style.BgColor);
            }

            SizeD scaledVisSize = new SizeD(
                visSize.Width * provider.DrawingScaleX,
                visSize.Height * provider.DrawingScaleY);

            bool  formatError;
            SizeD size;

            GetImage(out formatError, out size, (float)scaledVisSize.Height);

            if (formatError)
            {
                DrawError(contStart);
            }
            else
            {
                double targetWidth;
                if (image.Width > scaledVisSize.Width)
                {
                    targetWidth = scaledVisSize.Width;
                }
                else
                {
                    int expand = (int)(scaledVisSize.Width / image.Width);
                    if (expand > 1)
                    {
                        GetImage(out formatError, out size, (float)scaledVisSize.Height / expand);
                    }

                    // scale with whole factor lower the blurring
                    targetWidth = image.Width * expand;
                    // center the barcode in the new spot
                    contStart.X += (int)((scaledVisSize.Width - targetWidth) / (2 * provider.DrawingScaleX));
                }

                RectangleD target = new RectangleD(contStart, new SizeD(targetWidth / provider.DrawingScaleX, visSize.Height));
                RectangleD source = new RectangleD(0, 0, image.Width, image.Height);
                provider.DrawSurface(image.Surface, target, source, InterpType.Nearest);
            }

            if (style.Border > 0f)
            {
                provider.DrawInsetRectangle(
                    start.X, start.Y,
                    visSize.Width, visSize.Height, style.Border.Value, style.BorderColor);
            }
        }
 public ValuesGetController(IDrawingProvider drawingProvider)
 {
     this.drawingProvider = drawingProvider;
 }