Revised C# Control of a Dial


Learning new aspects of Visual Studios Designer I made this control and added designer support for the control. Each dial control now has the following properties to allow easy access to the control being used:

  • Minimum - Used to set the dial minimum value property.
  • Maximum - Used to set the dials maximum value property.
  • ShowText - Shows text inside the dial.
  • DialPosition - Current value of the dial being used.
  • PositionInc - Allows the dials increment value to be changed.

Code Excerpt:

[ CategoryAttribute("Appearance"),
DescriptionAttribute("Set maximum value of dial to?"),
DefaultValueAttribute(359.5f) ]

/// <summary
/// Maximum value of dial.
/// </summary
public float Maximum
{
get{return maximum;}
set
{
if(DialPosition value)
DialPosition =
value;
maximum =
value;
}
}
[
CategoryAttribute("Appearance"),
DescriptionAttribute("Sets starting value of dial to?"),
DefaultValueAttribute(0.5f)
]
/// <summary
/// Counts get and set
/// </summary
public float DialPosition
{
get
{
return dialPosition;}
set
{
dialPosition =
value;
if( DialPosition == Maximum )
dialPosition = maximum;
if( DialPosition < Minimum )
dialPosition = minimum;
if( DialPosition Maximum )
dialPosition = maximum;
this.Refresh();
OnValueChanged(
this);
}
}