Beispiel #1
0
 //used with HwndRenderTarget
 private void RenderSceneInBackground()
 {
     if (Parent == null || render == null)
     {
         return;
     }
     if (renderMode == RenderModes.HwndRenderTarget ||
         renderMode == RenderModes.BitmapRenderTargetRealTime)
     {
         if (hwndRenderTarget == null || hwndRenderTarget.IsOccluded)
         {
             return;
         }
         CalculateFPS();
         if (renderMode == RenderModes.HwndRenderTarget)
         {
             //render scene directly on the control
             RenderScene(hwndRenderTarget);
         }
         else if (renderMode == RenderModes.BitmapRenderTargetRealTime)
         {
             //draw bitmap cache of the shapes to control
             hwndRenderTarget.BeginDraw();
             hwndRenderTarget.DrawBitmap(bitmapRenderTarget.Bitmap, 1.0f,
                                         BitmapInterpolationMode.NearestNeighbor,
                                         new RectF(0, 0, Width, Height));
             hwndRenderTarget.EndDraw();
         }
     }
 }
Beispiel #2
0
        private void RenderScene()
        {
            CreateDeviceResources();

            if (renderTarget.IsOccluded)
            {
                return;
            }

            renderTarget.BeginDraw();

            renderTarget.Clear(WhiteBackgroundColor);

            foreach (DrawingShape shape in drawingShapes)
            {
                shape.Draw(renderTarget);
            }

            renderTarget.EndDraw();
        }
Beispiel #3
0
        private void Render()
        {
            CreateDeviceResources();

            if (renderTarget.IsOccluded)
            {
                return;
            }

            SizeF renderTargetSize = renderTarget.Size;

            renderTarget.BeginDraw();

            renderTarget.Clear(new ColorF(1, 1, 1, 0));

            renderTarget.DrawTextLayout(
                new Point2F(0, 0),
                textLayout,
                blackBrush
                );

            renderTarget.EndDraw();
        }
Beispiel #4
0
        private void Render()
        {
            CreateDeviceResources();

            if (renderTarget.IsOccluded)
            {
                return;
            }

            SizeF renderTargetSize = renderTarget.Size;

            renderTarget.BeginDraw();

            renderTarget.Clear(new ColorF(1, 1, 1, 0));

            // Paint a grid background.
            RectF rf = new RectF(0.0f, 0.0f, renderTargetSize.Width, renderTargetSize.Height);

            renderTarget.FillRectangle(rf, gridPatternBitmapBrush);

            float curLeft = 0;

            rf = new RectF(
                curLeft,
                renderTargetSize.Height,
                (curLeft + renderTargetSize.Width / 5.0F),
                renderTargetSize.Height - renderTargetSize.Height * ((float)x1 / 100.0F));

            renderTarget.FillRectangle(rf, solidBrush1);

            textLayout = dwriteFactory.CreateTextLayout(String.Format("  {0}%", x1), textFormat, renderTargetSize.Width / 5.0F, 30);

            renderTarget.DrawTextLayout(
                new Point2F(curLeft, renderTargetSize.Height - 30),
                textLayout,
                blackBrush);

            curLeft = (curLeft + renderTargetSize.Width / 5.0F);
            rf      = new RectF(
                curLeft,
                renderTargetSize.Height,
                (curLeft + renderTargetSize.Width / 5.0F),
                renderTargetSize.Height - renderTargetSize.Height * ((float)x2 / 100.0F));
            renderTarget.FillRectangle(rf, radialGradientBrush);
            renderTarget.DrawText(
                String.Format("  {0}%", x2),
                textFormat,
                new RectF(curLeft, renderTargetSize.Height - 30, (curLeft + renderTargetSize.Width / 5.0F), renderTargetSize.Height), blackBrush);

            curLeft = (curLeft + renderTargetSize.Width / 5.0F);
            rf      = new RectF(
                curLeft,
                renderTargetSize.Height,
                (curLeft + renderTargetSize.Width / 5.0F),
                renderTargetSize.Height - renderTargetSize.Height * ((float)x3 / 100.0F));
            renderTarget.FillRectangle(rf, solidBrush3);
            renderTarget.DrawText(
                String.Format("  {0}%", x3),
                textFormat,
                new RectF(curLeft, renderTargetSize.Height - 30, (curLeft + renderTargetSize.Width / 5.0F), renderTargetSize.Height), blackBrush);

            curLeft = (curLeft + renderTargetSize.Width / 5.0F);
            rf      = new RectF(
                curLeft,
                renderTargetSize.Height,
                (curLeft + renderTargetSize.Width / 5.0F),
                renderTargetSize.Height - renderTargetSize.Height * ((float)x4 / 100.0F));
            renderTarget.FillRectangle(rf, linearGradientBrush);
            renderTarget.DrawText(
                String.Format("  {0}%", x4),
                textFormat,
                new RectF(curLeft, renderTargetSize.Height - 30, (curLeft + renderTargetSize.Width / 5.0F), renderTargetSize.Height), blackBrush);


            curLeft = (curLeft + renderTargetSize.Width / 5.0F);
            rf      = new RectF(
                curLeft,
                renderTargetSize.Height,
                (curLeft + renderTargetSize.Width / 5.0F),
                renderTargetSize.Height - renderTargetSize.Height * ((float)x5 / 100.0F));
            renderTarget.FillRectangle(rf, solidBrush2);
            renderTarget.DrawText(
                String.Format("  {0}%", x5),
                textFormat,
                new RectF(curLeft, renderTargetSize.Height - 30, (curLeft + renderTargetSize.Width / 5.0F), renderTargetSize.Height), blackBrush);

            renderTarget.EndDraw();
        }