예제 #1
0
        void IGraphicsRenderer.Render(GraphicsRenderContext context, ILayoutArea area)
        {
            _layoutArea = area;
            const string ErrorMsg = "IGraphicsRenderer was configured improperly.";

            CalendarContentRange content = area.ContentRange as CalendarContentRange;

            if (content == null)
            {
                Trace.TraceError(ErrorMsg);
                return;
            }

            CalendarDataRegion calendar = content.Owner as CalendarDataRegion;

            if (calendar == null)
            {
                Trace.TraceError(ErrorMsg);
                return;
            }

            if (context.DoContent)
            {
                Render(content, context.Canvas, new RectangleF(area.Left, area.Top, area.Width, area.Height));
            }
        }
예제 #2
0
            public ImageInfo Render(ILayoutArea area, string mimeType, SizeF dpi)
            {
                var content = area.ContentRange as RtfControlContentRange;
                var rtf     = content.Info.Rtf;

                var sizeInInches = new SizeF(area.Width / 1440, area.Height / 1440);
                var stream       = RtfRenderer.RenderToStream(rtf, sizeInInches);

                return(new ImageInfo(stream, "image/emf"));
            }
예제 #3
0
            private void ProcessLayoutArea(ILayoutArea area)
            {
                Assert.IsNotNull(area);
                Assert.IsNotNull(area.Children);

                foreach (ILayoutArea child in area.Children)
                {
                    if (child.ContentRange is CalendarContentRange)
                    {
                        // TODO - fix!!!
                        _graphicsRenderer.Render(new GraphicsRenderContext(this, GraphicsCanvasFactory.Create(GetGraphics()), new TextMetricsProvider(), RenderersFactory.Instance, null), child);
                        _calendarLayoutArea = child;
                        break;
                    }
                }
            }
예제 #4
0
            void IGraphicsRenderer.Render(GraphicsRenderContext context, ILayoutArea area)
            {
                var    reportItem = (SvgImage)area.ReportItem;
                string svg        = Convert.ToString(reportItem._properties.GetValue("Svg")).Trim();

                var doc = new XmlDocument();

                try
                {
                    doc.LoadXml(svg);
                }
                catch (XmlException)
                {
                    throw new Exception(Properties.Resources.ExceptionMessage);
                }

                var svgDocument = SvgDocument.Open(doc);

                using (var renderer = new SvgRenderer(context, new RectangleF(area.Left, area.Top, area.Width, area.Height)))
                    svgDocument.Draw(renderer);
            }
예제 #5
0
 public ImageInfo RenderBackground(ILayoutArea layoutArea, string mimeType, SizeF dpi)
 {
     return(null);
 }
예제 #6
0
            ImageInfo IImageRenderer.Render(ILayoutArea layoutArea, string mimeType, SizeF dpi)
            {
                var reportItem = layoutArea.ReportItem;

                var customData = ((ICustomReportItem)reportItem).CustomData;

                if (customData == null)
                {
                    return(new ImageInfo());
                }
                if (customData.DataRowGroupings == null || customData.DataRowGroupings.Count != 1)
                {
                    return(new ImageInfo());
                }
                var values = new List <double>(customData.DataRowGroupings[0].Count);

                // read the values from nested data members
                foreach (DataMember member in customData.DataRowGroupings[0])
                {
                    double value;
                    if (ReadValue(member, out value))                     // we have to check that there is corresponding property to read series value
                    {
                        values.Add(value);
                    }
                }

                var bounds = GetImageBounds(reportItem, layoutArea);

                if (dpi.IsEmpty)
                {
                    dpi = new SizeF(Resolution.Width, Resolution.Height);
                }
                var imageSize = new Size(FromTwipsToPixels(bounds.Width, dpi.Width), FromTwipsToPixels(bounds.Height, dpi.Height));

                if (imageSize.Width == 0 || imageSize.Height == 0)
                {
                    return(new ImageInfo());
                }

                using (var nonScaledImage = new Bitmap(imageSize.Width, imageSize.Height))
                {
                    nonScaledImage.SetResolution(dpi.Width, dpi.Height);
                    using (var chart = new System.Windows.Forms.DataVisualization.Charting.Chart {
                        Dock = DockStyle.Fill, Size = imageSize
                    })
                    {
                        var chartArea = new ChartArea("Main");
                        chart.ChartAreas.Add(chartArea);

                        // Create series and add it to the chart
                        var seriesColumns = new Series("Columns");
                        foreach (var val in values)
                        {
                            seriesColumns.Points.Add(Convert.ToDouble(val));
                        }
                        seriesColumns.ChartType = SeriesChartType.Radar;

                        chart.Series.Add(seriesColumns);
                        chart.DrawToBitmap(nonScaledImage, new Rectangle(Point.Empty, imageSize));
                    }
                    var stream = new MemoryStream();
                    nonScaledImage.Save(stream, ImageFormat.Png);
                    stream.Flush();
                    stream.Position = 0;
                    return(new ImageInfo(stream, "image/png"));
                }
            }
예제 #7
0
 private static RectangleF GetImageBounds(IReportItem reportItem, ILayoutArea layoutArea)
 {
     return(layoutArea != null
                             ? new RectangleF(layoutArea.Left, layoutArea.Top, layoutArea.Width, layoutArea.Height)
                             : new RectangleF(reportItem.Left.ToTwips(), reportItem.Top.ToTwips(), reportItem.Width.ToTwips(), reportItem.Height.ToTwips()));
 }