コード例 #1
0
 private bool GetImage(string imageName, Stream imageStream, long imageDataOffset, bool dynamicImage, out System.Drawing.Image image)
 {
     image = null;
     if (dynamicImage || string.IsNullOrEmpty(imageName) || !m_cachedImages.TryGetValue(imageName, out image))
     {
         if (imageStream == null)
         {
             imageStream = SharedRenderer.GetEmbeddedImageStream(m_renderer.RplReport, imageDataOffset, base.CreateAndRegisterStream, imageName);
             if (imageStream == null)
             {
                 return(false);
             }
         }
         if (imageStream.Position != 0L && imageStream.CanSeek)
         {
             imageStream.Position = 0L;
         }
         try
         {
             image = System.Drawing.Image.FromStream(imageStream);
         }
         catch
         {
             return(false);
         }
         AddImageToCache(image, dynamicImage, imageName);
     }
     if (!dynamicImage)
     {
         return(!string.IsNullOrEmpty(imageName));
     }
     return(false);
 }
コード例 #2
0
 private bool GetImage(string imageName, byte[] imageBytes, long imageDataOffset, bool dynamicImage, out System.Drawing.Image image)
 {
     image = null;
     if (dynamicImage || string.IsNullOrEmpty(imageName) || !m_cachedImages.TryGetValue(imageName, out image))
     {
         if (!SharedRenderer.GetImage(m_renderer.RplReport, ref imageBytes, imageDataOffset))
         {
             return(false);
         }
         try
         {
             image = System.Drawing.Image.FromStream(new MemoryStream(imageBytes));
         }
         catch
         {
             return(false);
         }
         AddImageToCache(image, dynamicImage, imageName);
     }
     if (!dynamicImage)
     {
         return(!string.IsNullOrEmpty(imageName));
     }
     return(false);
 }
コード例 #3
0
        internal override void BeginPageSection(RectangleF bounds)
        {
            base.BeginPageSection(bounds);
            int dpiX = m_commonGraphics.DpiX;
            int dpiY = m_commonGraphics.DpiY;

            m_bodyRect = new System.Drawing.Rectangle(SharedRenderer.ConvertToPixels(bounds.X, dpiX), SharedRenderer.ConvertToPixels(bounds.Y, dpiY), SharedRenderer.ConvertToPixels(bounds.Width + HalfPixelWidthX, dpiX), SharedRenderer.ConvertToPixels(bounds.Height + HalfPixelWidthY, dpiY));
            m_graphics.ResetClipAndTransform(new RectangleF(bounds.Left, bounds.Top, bounds.Width + HalfPixelWidthX, bounds.Height + HalfPixelWidthY));
        }
コード例 #4
0
        internal override void ClipTextboxRectangle(Win32DCSafeHandle hdc, RectangleF position)
        {
            if (m_bodyRect.X != 0 || m_bodyRect.Y != 0)
            {
                if (!Microsoft.ReportingServices.Rendering.RichText.Win32.GetViewportOrgEx(hdc, out m_prevViewportOrg))
                {
                    int lastWin32Error = Marshal.GetLastWin32Error();
                    throw new Exception(string.Format(CultureInfo.InvariantCulture, ImageRendererRes.Win32ErrorInfo, "GetViewportOrgEx", lastWin32Error));
                }
                if (!Microsoft.ReportingServices.Rendering.RichText.Win32.SetViewportOrgEx(hdc, m_bodyRect.X, m_bodyRect.Y, Win32ObjectSafeHandle.Zero))
                {
                    int lastWin32Error2 = Marshal.GetLastWin32Error();
                    throw new Exception(string.Format(CultureInfo.InvariantCulture, ImageRendererRes.Win32ErrorInfo, "SetViewportOrgEx", lastWin32Error2));
                }
            }
            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(SharedRenderer.ConvertToPixels(position.X, m_commonGraphics.DpiX), SharedRenderer.ConvertToPixels(position.Y, m_commonGraphics.DpiY), SharedRenderer.ConvertToPixels(position.Width, m_commonGraphics.DpiX), SharedRenderer.ConvertToPixels(position.Height, m_commonGraphics.DpiY));
            if (position.X < 0f)
            {
                rectangle.Width += rectangle.X;
                rectangle.X      = 0;
            }
            if (position.Y < 0f)
            {
                rectangle.Height += rectangle.Y;
                rectangle.Y       = 0;
            }
            rectangle.X += m_bodyRect.X;
            rectangle.Y += m_bodyRect.Y;
            if (rectangle.Right > m_bodyRect.Right)
            {
                rectangle.Width = m_bodyRect.Right - rectangle.Left;
            }
            if (rectangle.Bottom > m_bodyRect.Bottom)
            {
                rectangle.Height = m_bodyRect.Bottom - rectangle.Top;
            }
            Win32ObjectSafeHandle win32ObjectSafeHandle = Microsoft.ReportingServices.Rendering.RichText.Win32.CreateRectRgn(rectangle.X, rectangle.Y, rectangle.Right, rectangle.Bottom);

            if (win32ObjectSafeHandle.IsInvalid)
            {
                return;
            }
            try
            {
                if (Microsoft.ReportingServices.Rendering.RichText.Win32.SelectClipRgn(hdc, win32ObjectSafeHandle) == 0)
                {
                    int lastWin32Error3 = Marshal.GetLastWin32Error();
                    throw new Exception(string.Format(CultureInfo.InvariantCulture, ImageRendererRes.Win32ErrorInfo, "SelectClipRgn", lastWin32Error3));
                }
            }
            finally
            {
                win32ObjectSafeHandle.Close();
            }
        }
コード例 #5
0
        private RectangleF CalculateMetafileRectangle(IntPtr hdc, float pageWidth, float pageHeight, float DpiX, float DpiY)
        {
            int    deviceCaps  = Microsoft.ReportingServices.Rendering.RichText.Win32.GetDeviceCaps(hdc, 4);
            int    deviceCaps2 = Microsoft.ReportingServices.Rendering.RichText.Win32.GetDeviceCaps(hdc, 6);
            int    deviceCaps3 = Microsoft.ReportingServices.Rendering.RichText.Win32.GetDeviceCaps(hdc, 118);
            int    deviceCaps4 = Microsoft.ReportingServices.Rendering.RichText.Win32.GetDeviceCaps(hdc, 117);
            double num         = SharedRenderer.ConvertToPixels(pageWidth, DpiX);
            double num2        = SharedRenderer.ConvertToPixels(pageHeight, DpiY);
            float  width       = (float)(num * (double)deviceCaps * 100.0) / (float)deviceCaps3;
            float  height      = (float)(num2 * (double)deviceCaps2 * 100.0) / (float)deviceCaps4;

            return(new RectangleF(0f, 0f, width, height));
        }
コード例 #6
0
        internal override void DrawBackgroundImage(RPLImageData imageData, RPLFormat.BackgroundRepeatTypes repeat, PointF start, RectangleF position)
        {
            System.Drawing.Image image;
            bool image2 = GetImage(imageData.ImageName, imageData.ImageData, imageData.ImageDataOffset, dynamicImage: false, out image);

            if (image == null)
            {
                return;
            }
            RectangleF destination;
            RectangleF source;

            if (repeat == RPLFormat.BackgroundRepeatTypes.Clip)
            {
                if (SharedRenderer.CalculateImageClippedUnscaledBounds(this, position, image.Width, image.Height, start.X, start.Y, m_measureImageDpiX, m_measureImageDpiY, out destination, out source))
                {
                    m_graphics.DrawImage(image, destination, source);
                }
            }
            else
            {
                float num  = SharedRenderer.ConvertToMillimeters(image.Width, m_measureImageDpiX);
                float num2 = SharedRenderer.ConvertToMillimeters(image.Height, m_measureImageDpiY);
                float num3 = position.Width;
                if (repeat == RPLFormat.BackgroundRepeatTypes.RepeatY)
                {
                    num3 = num;
                }
                float num4 = position.Height;
                if (repeat == RPLFormat.BackgroundRepeatTypes.RepeatX)
                {
                    num4 = num2;
                }
                for (float num5 = start.X; num5 < num3; num5 += num)
                {
                    for (float num6 = start.Y; num6 < num4; num6 += num2)
                    {
                        if (SharedRenderer.CalculateImageClippedUnscaledBounds(this, position, image.Width, image.Height, num5, num6, m_measureImageDpiX, m_measureImageDpiY, out destination, out source))
                        {
                            m_graphics.DrawImage(image, destination, source);
                        }
                    }
                }
            }
            if (!image2)
            {
                image.Dispose();
                image = null;
            }
        }
コード例 #7
0
        internal static GDIFont GetOrCreateFont(Dictionary <string, GDIFont> gdiFonts, string fontFamily, float fontSize, RPLFormat.FontWeights fontWeight, RPLFormat.FontStyles fontStyle, RPLFormat.TextDecorations textDecoration)
        {
            string key = GetKey(fontFamily, fontSize, fontWeight, fontStyle, textDecoration);

            if (gdiFonts.TryGetValue(key, out GDIFont value))
            {
                return(value);
            }
            bool bold        = SharedRenderer.IsWeightBold(fontWeight);
            bool italic      = fontStyle == RPLFormat.FontStyles.Italic;
            bool underLine   = false;
            bool lineThrough = false;

            switch (textDecoration)
            {
            case RPLFormat.TextDecorations.Underline:
                underLine = true;
                break;

            case RPLFormat.TextDecorations.LineThrough:
                lineThrough = true;
                break;
            }
            Font font = null;

            try
            {
                font  = FontCache.CreateGdiPlusFont(fontFamily, fontSize, ref bold, ref italic, lineThrough, underLine);
                value = new GDIFont(key, font, fontSize);
                gdiFonts.Add(key, value);
                return(value);
            }
            catch
            {
                if (font != null && !gdiFonts.ContainsKey(key))
                {
                    font.Dispose();
                    font = null;
                }
                throw;
            }
        }
コード例 #8
0
        public void DrawTextRun(TextRun run, Paragraph paragraph, Win32DCSafeHandle hdc, float dpiX, FontCache fontCache, int x, int y, int baselineY, int lineHeight, Rectangle layoutRectangle)
        {
            TypeCode typeCode = ((RPLTextBoxPropsDef)m_source.Definition).SharedTypeCode;

            if (typeCode == TypeCode.Object)
            {
                typeCode = m_source.TypeCode;
            }
            ReportTextRun reportTextRun = run.TextRunProperties as ReportTextRun;

            if (reportTextRun != null && reportTextRun.ActionInfo != null && reportTextRun.ActionInfo.Actions.Length != 0)
            {
                RPLActionInfo actionInfo = reportTextRun.ActionInfo;
                RectangleF    position   = default(RectangleF);
                if (WritingMode == RPLFormat.WritingModes.Horizontal)
                {
                    position.Width  = SharedRenderer.ConvertToMillimeters(run.GetWidth(hdc, fontCache), fontCache.Dpi);
                    position.Height = SharedRenderer.ConvertToMillimeters(run.GetHeight(hdc, fontCache), fontCache.Dpi);
                    position.X      = SharedRenderer.ConvertToMillimeters(layoutRectangle.X, fontCache.Dpi) + SharedRenderer.ConvertToMillimeters(x, fontCache.Dpi);
                    position.Y      = SharedRenderer.ConvertToMillimeters(layoutRectangle.Y, fontCache.Dpi) + (SharedRenderer.ConvertToMillimeters(y, fontCache.Dpi) - position.Height);
                }
                else
                {
                    position.Width  = SharedRenderer.ConvertToMillimeters(run.GetHeight(hdc, fontCache), fontCache.Dpi);
                    position.Height = SharedRenderer.ConvertToMillimeters(run.GetWidth(hdc, fontCache), fontCache.Dpi);
                    if (WritingMode == RPLFormat.WritingModes.Vertical)
                    {
                        position.X = SharedRenderer.ConvertToMillimeters(layoutRectangle.Right, fontCache.Dpi) - SharedRenderer.ConvertToMillimeters(y, fontCache.Dpi);
                        position.Y = SharedRenderer.ConvertToMillimeters(layoutRectangle.Y, fontCache.Dpi) + SharedRenderer.ConvertToMillimeters(x, fontCache.Dpi);
                    }
                    else
                    {
                        position.X = SharedRenderer.ConvertToMillimeters(layoutRectangle.X, fontCache.Dpi) + SharedRenderer.ConvertToMillimeters(y, fontCache.Dpi) - position.Width;
                        position.Y = SharedRenderer.ConvertToMillimeters(layoutRectangle.Bottom, fontCache.Dpi) - SharedRenderer.ConvertToMillimeters(x, fontCache.Dpi) - position.Height;
                    }
                }
                m_writer.ProcessAction(reportTextRun.UniqueName, actionInfo, position);
            }
            m_writer.DrawTextRun(hdc, fontCache, this, run, typeCode, paragraph.ParagraphProps.Alignment, VerticalAlignment, WritingMode, Direction, new Point(x, y), layoutRectangle, lineHeight, baselineY);
        }
コード例 #9
0
        private static string GetKey(string fontFamily, float fontSize, RPLFormat.FontWeights fontWeight, RPLFormat.FontStyles fontStyle, RPLFormat.TextDecorations textDecoration)
        {
            StringBuilder stringBuilder = new StringBuilder("FO");

            stringBuilder.Append(fontFamily);
            stringBuilder.Append(fontSize.ToString(CultureInfo.InvariantCulture));
            if (SharedRenderer.IsWeightBold(fontWeight))
            {
                stringBuilder.Append('b');
            }
            else
            {
                stringBuilder.Append('n');
            }
            if (fontStyle == RPLFormat.FontStyles.Italic)
            {
                stringBuilder.Append('i');
            }
            else
            {
                stringBuilder.Append('n');
            }
            switch (textDecoration)
            {
            case RPLFormat.TextDecorations.Underline:
                stringBuilder.Append('u');
                break;

            case RPLFormat.TextDecorations.LineThrough:
                stringBuilder.Append('s');
                break;

            default:
                stringBuilder.Append('n');
                break;
            }
            return(stringBuilder.ToString());
        }
コード例 #10
0
        internal override void DrawImage(RectangleF position, RPLImage image, RPLImageProps instanceProperties, RPLImagePropsDef definitionProperties)
        {
            RPLImageData image2 = instanceProperties.Image;

            System.Drawing.Image image3;
            bool flag = GetImage(image2.ImageName, image2.ImageData, image2.ImageDataOffset, dynamicImage: false, out image3);

            RPLFormat.Sizings sizing = definitionProperties.Sizing;
            if (image3 == null)
            {
                GetDefaultImage(out image3);
                flag   = true;
                sizing = RPLFormat.Sizings.Clip;
            }
            GDIImageProps gDIImageProps = new GDIImageProps(image3);

            SharedRenderer.CalculateImageRectangle(position, gDIImageProps.Width, gDIImageProps.Height, m_measureImageDpiX, m_measureImageDpiY, sizing, out RectangleF imagePositionAndSize, out RectangleF imagePortion);
            m_graphics.DrawImage(image3, imagePositionAndSize, imagePortion);
            if (!flag)
            {
                image3.Dispose();
                image3 = null;
            }
        }
コード例 #11
0
 internal int ConvertToPixels(float mm)
 {
     return(SharedRenderer.ConvertToPixels(mm, m_dpiX));
 }
コード例 #12
0
 internal float ConvertToMillimeters(int pixels)
 {
     return(SharedRenderer.ConvertToMillimeters(pixels, m_dpiX));
 }