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(); }