public void CalendarRenderWithNoDataBound()
        {
            PageDocument report = TestHelper.GetReport("Calendar-NoData.rdlx");

            TestingRenderingExtension rendererExt = new TestingRenderingExtension();

            report.Render(rendererExt, null);

            CalendarDataRegion calendar = rendererExt.GetReportItem("Calendar1") as CalendarDataRegion;

            Assert.IsNotNull(calendar);

            CalendarData         calendarData = new CalendarData(calendar);
            CalendarContentRange content      = new CalendarContentRange(calendar, calendarData.GetFirstMonth(), calendarData.GetLastMonth());

            // recalibrate graphics to twips
            RectangleF rect = new RectangleF(0, 0, 4000f, 4000f);

            CalendarDesigner.ScaleToTwipsGraphicsAndBound(GetGraphics(), ref rect);

            // create gdi canvas wrapper to use in renderer
            IDrawingCanvas canvas = GraphicsCanvasFactory.Create(GetGraphics());

            // render calendar to canvas
            CalendarRenderer.Instance.Render(content, canvas, rect);
        }
        public void TestRenderingInMultiThreads()
        {
            var report      = TestHelper.GetReport("Calendar.rdlx");
            var rendererExt = new TestingRenderingExtension();

            report.Render(rendererExt, null);

            var calendar = rendererExt.GetReportItem("Calendar1") as CalendarDataRegion;

            Assert.IsNotNull(calendar);

            var calendarData = new CalendarData(calendar);
            var content      = new CalendarContentRange(calendar, calendarData.GetFirstMonth(), calendarData.GetLastMonth());

            // recalibrate graphics to twips
            var rect = new RectangleF(0, 0, 4000f, 4000f);

            CalendarDesigner.ScaleToTwipsGraphicsAndBound(GetGraphics(), ref rect);

            // the action of rendering calendar to canvas
            System.Action render = () =>
            {
                using (var graphics = Graphics.FromHwnd(IntPtr.Zero))
                {
                    var canvas = GraphicsCanvasFactory.Create(graphics);
                    (calendar.GetRenderer <IGraphicsRenderer>() as CalendarRenderer)
                    .Render(content, canvas, rect);
                }
            };

            var isSuccess1 = false;
            var isSuccess2 = false;

            ThreadStart render1 = () =>
            {
                render();
                isSuccess1 = true;
            };

            ThreadStart render2 = () =>
            {
                render();
                isSuccess2 = true;
            };

            var thread1 = new Thread(render1);
            var thread2 = new Thread(render2);

            thread1.Start();
            thread2.Start();

            thread1.Join();
            thread2.Join();

            Assert.IsTrue(isSuccess1);
            Assert.IsTrue(isSuccess2);
        }
Ejemplo n.º 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;
                    }
                }
            }