/// <summary> /// The <see cref="TreeView.DrawNode"/> event handler /// for the <see cref="TreeView"/> <see cref="trvTrials"/>. /// Adds drawing of trial icons to default drawing behaviour. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">An empty <see cref="EventArgs"/></param> private void trvTrials_DrawNode(object sender, DrawTreeNodeEventArgs e) { e.DrawDefault = true; Rectangle idBounds = e.Node.Bounds; idBounds.Offset(e.Node.Bounds.Width + 2, 0); string idString = "(ID:" + e.Node.Name + ")"; e.Graphics.DrawString(idString, this.trvTrials.Font, Brushes.Black, idBounds.Location); SizeF textSize = e.Graphics.MeasureString(idString, this.trvTrials.Font); // If the randomize flag is set, draw a dice icon // to the right of the label text. bool randomize = ((SlideshowTreeNode)e.Node).Randomize; if (randomize) { Rectangle diceBounds = e.Node.Bounds; diceBounds.Offset(e.Node.Bounds.Width + 10 + (int)textSize.Width, 0); Slideshow.DrawDice(e.Graphics, diceBounds.Location); } }