/// <summary> /// The <see cref="TreeView.DrawNode"/> event handler /// for the <see cref="TreeView"/> <see cref="trvSlideshow"/>. /// Performs customized drawing of the <see cref="TreeNode"/>s. /// That is a trial icon or a dice icon when trial or shuffling mode is set. /// </summary> /// <param name="sender">Source of the event.</param> /// <param name="e">A <see cref="DrawTreeNodeEventArgs"/> that contains the event data.</param> private void trvSlideshow_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.trvSlideshow.Font, Brushes.Black, idBounds.Location); SizeF textSize = e.Graphics.MeasureString(idString, this.trvSlideshow.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); } // If the disabled flag is set, draw a disabled icon // to the right of the label text. var node = e.Node as SlideshowTreeNode; if (node.Slide != null) { if (node.Slide.IsDisabled) { Rectangle disabledBounds = e.Node.Bounds; disabledBounds.Offset(e.Node.Bounds.Width + 10 + (int)textSize.Width, 0); Slideshow.DrawDisabled(e.Graphics, disabledBounds.Location); } } }