|
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace TSWizards.Controls
{
/// <summary>
/// Summary description for BulletList.
/// </summary>
public class BulletList : Label
{
char bulletCharacter = '�';
StringCollection items;
public BulletList()
{
items = new StringCollection();
}
[Browsable(true)]
[Category("Appearance")]
[Description("A collection of items to appear with a bullet")]
[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design",
"System.Drawing.Design.UITypeEditor, System.Drawing")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public virtual StringCollection Items
{
get
{
return items;
}
}
[Browsable(true)]
[Category("Appearance")]
[Description("Gets/Sets the character that will be displayed before each bulleted item")]
[DefaultValue('�')]
public virtual char BulletCharacter
{
get
{
return bulletCharacter;
}
set
{
bulletCharacter = value;
}
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
PointF drawPoint = new PointF(0.0f, 0.0f);
using( Brush brush = new SolidBrush(ForeColor) )
{
StringFormat format = StringFormat.GenericTypographic;
SizeF size = g.MeasureString(Text, Font);
g.DrawString( Text, Font, brush, drawPoint, format );
foreach(string item in items)
{
string str = BulletCharacter + " " + item;
drawPoint.Y += size.Height;// + (float) Font.FontFamily.GetLineSpacing(Font.Style);
size = g.MeasureString(str, Font);
System.Diagnostics.Trace.WriteLine(drawPoint.ToString());
g.DrawString( str, Font, brush, drawPoint, format);
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
James has been programming in C/C++ since 1998, and grew fond of databases in 1999. His latest interest has been in C# and .NET where he has been having fun writing code starting when .NET v1.0 was in its first beta.
He is currently a senior developer and consultant for
InfoPlanIT, a small international consulting company that focuses on custom solutions and business intelligence applications.
He was previously employed by ComponentOne where he was a Product Manager for the ActiveReports, Data Dynamics Reports, and ActiveAnalysis products.
Code contained in articles where he is the sole author is licensed via the
new BSD license.