packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/Direct2D/D2DShapes/D2DShapesControl.cs
/// <summary>
/// Renders the scene to the given render target.
/// Clears the scene, then draws all shapes
/// </summary>
/// <param name="renderTarget">The render target.</param>
Renders the scene to the given render target.
Clears the scene, then draws all shapes
Renders the scene to the given render target . Clears the scene then draws all shapes
private void RenderScene(RenderTarget renderTarget)
        {
            Cursor c = null;
            if (renderMode != RenderModes.HwndRenderTarget)
            {
                c = Cursor;
                Cursor = Cursors.WaitCursor;
            }
            renderTarget.BeginDraw();
            renderTarget.Clear(BackColorF);
            for (int i = 0; i < drawingShapes.Count; i++)
            {
                DrawingShape shape = drawingShapes[i];
                renderTarget.Tags = new Tags((ulong)i, 0);
                shape.Draw(renderTarget);
            }
            Tags tags;
            ErrorCode errorCode;
            if (!renderTarget.TryEndDraw(out tags, out errorCode))
            {
                Debug.WriteLine(String.Format("Failed EndDraw. Error: {0}, tag1: {1}, tag2: {2}, shape[{1}]: {3}",
                    errorCode, tags.Tag1, tags.Tag2,
                    (int)tags.Tag1 < drawingShapes.Count ? drawingShapes[(int)tags.Tag1].ToString() : "<none>"));
            }
            if (renderMode != RenderModes.HwndRenderTarget)
                Cursor = c;
        }
private void RenderScene ( RenderTarget renderTarget ) { Cursor c = null ; if ( renderMode != RenderModes . HwndRenderTarget ) { c = Cursor ; Cursor = Cursors . WaitCursor ; } renderTarget . BeginDraw ( ) ; renderTarget . Clear ( BackColorF ) ; for ( int i = 0 ; i < drawingShapes . Count ; i ++ ) { DrawingShape shape = drawingShapes [ i ] ; renderTarget . Tags = new Tags ( ( ulong ) i , 0 ) ; shape . Draw ( renderTarget ) ; } Tags tags ; ErrorCode errorCode ; if ( ! renderTarget . TryEndDraw ( out tags , out errorCode ) ) { Debug . WriteLine ( String . Format ( " " , errorCode , tags . Tag1 , tags . Tag2 , ( int ) tags . Tag1 < drawingShapes . Count ? drawingShapes [ ( int ) tags . Tag1 ] . ToString ( ) : " " ) ) ; } if ( renderMode != RenderModes . HwndRenderTarget ) Cursor = c ; }
Renders the scene to the given render target.
Renders the scene to the given render target .
//tag with shape index for debugging
renderTarget
RenderTarget
The render target.
The render target .