private float PaintGroup(StaveGroup group, float totalHeight, ICanvas canvas) { // paint into canvas var height = group.Height + (GroupSpacing * Scale); canvas.BeginRender(Width, height); Renderer.Canvas.Color = Renderer.RenderingResources.MainGlyphColor; Renderer.Canvas.TextAlign = TextAlign.Left; // NOTE: we use this negation trick to make the group paint itself to 0/0 coordinates // since we use partial drawing group.Paint(0, -group.Y, canvas); // calculate coordinates for next group totalHeight += height; var result = canvas.EndRender(); var args = new RenderFinishedEventArgs(); args.TotalWidth = Width; args.TotalHeight = totalHeight; args.Width = Width; args.Height = height; args.RenderResult = result; args.FirstMasterBarIndex = group.FirstBarIndex; args.LastMasterBarIndex = group.LastBarIndex; Renderer.OnPartialRenderFinished(args); return(height); }