Click here to Skip to main content
11,709,529 members (53,674 online)
Click here to Skip to main content

Tagged as

(AGauge) WinForms Gauge Control

, 29 Aug 2012 Zlib 31.8K 16
Rate this:
Please Sign up or sign in to vote.
Introduction Original AGauge controlAGauge is a gauge control for WinForms create by A.J.Bauer using GDI+.Original code was published in "Code Project - A fast and performing gauge"The version that I published here is an improved version of AGauge which contains the following changes.Download Source

Introduction

Original AGauge control

AGauge is a gauge control for WinForms create by A.J.Bauer using GDI+. Original code was published in "Code Project - A fast and performing gauge" The version that I published here is an improved version of AGauge which contains the following changes.

Improvements

Dynamic Gauge Label and Gauge Range

Properties for gauge label (previously known as CapText) and range are grouped into GaugeRanges and GaugeLabels which allow us to create any number of range and label as we wish. Range and label can be edited either from code or using the collection editor from the properties window.

[System.ComponentModel.Browsable(true),
System.ComponentModel.Category("AGauge"),
System.ComponentModel.Description("Gauge Ranges.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public AGaugeRangeCollection GaugeRanges { get { return _GaugeRanges; } }
private AGaugeRangeCollection _GaugeRanges;

[System.ComponentModel.Browsable(true),
System.ComponentModel.Category("AGauge"),
System.ComponentModel.Description("Gauge Labels.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public AGaugeLabelCollection GaugeLabels { get { return _GaugeLabels; } }
private AGaugeLabelCollection _GaugeLabels;

Besides, each label can use different Font settings since label is an instance of AGaugeLabel.

Added NeedleType Enumeration

AGauge control has 2 different type of needle design selectable from NeedleType property. Type of NeedleType property waschanged from Int32 (0 or 1) to enumeration type (NeedleType.Advance or NeedleType.Simple) to avoid invalid entry from user.

Events

Update ValueInRangeChangedEvent

ValueInRangeChangedDelegate was changed to ValueInRangeChangedEvent to allow multiple subscriptions. The event is changed to trigger only if value is entering or leaving a defined range. Besides, ValueInRangeChangedEventArgs was updated to hold current range and gauge value.

[Description("This event is raised if the value is entering or leaving
  defined range.")]
public event EventHandler<ValueInRangeChangedEventArgs> ValueInRangeChanged;
private void OnValueInRangeChanged(AGaugeRange range, Single value)
{
  EventHandler<ValueInRangeChangedEventArgs> e = ValueInRangeChanged;
  if (e != null) e(this, new ValueInRangeChangedEventArgs(range, value,
                                                            range.InRange));
}

/// <summary>
/// Event argument for <see cref="ValueInRangeChanged"/> event.
/// </summary>
public class ValueInRangeChangedEventArgs : EventArgs
{
  /// <summary>
  /// Affected GaugeRange
  /// </summary>
  public AGaugeRange Range { get; private set; }
  /// <summary>
  /// Gauge Value
  /// </summary>
  public Single Value { get; private set; }
  /// <summary>
  /// True if value is within current range.
  /// </summary>
  public bool InRange { get; private set; }
  public ValueInRangeChangedEventArgs(AGaugeRange range, Single value,
                                          bool inRange)
  {
    this.Range = range;
    this.Value = value;
    this.InRange = inRange;
  }
}

Added ValueChangedEvent

ValueChanged event is added to notify user whenever gauge value is updated. Note that attempting to set gauge value out of defined gauge range will not trigger this event.

[Description("This event is raised when gauge value changed.")]
public event EventHandler ValueChanged;
private void OnValueChanged()
{
  EventHandler e = ValueChanged;
  if (e != null) e(this, null);
}

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License

History

  • 28/08/2012: Initial Release (Version 2.0.0)

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License

Share

About the Author

Code Artist
Software Developer (Senior)
Malaysia Malaysia

You may also be interested in...

Comments and Discussions

 
QuestionCreate Linear Gauges Pin
smsheethal26-Aug-15 2:49
professionalsmsheethal26-Aug-15 2:49 
QuestionUsing the Gauge Pin
Paul Hartland22-Mar-15 6:53
memberPaul Hartland22-Mar-15 6:53 
Questionscale the gauge Pin
dxtr morgan27-Jan-15 7:45
memberdxtr morgan27-Jan-15 7:45 
AnswerRe: scale the gauge Pin
Code Artist28-Jan-15 2:25
memberCode Artist28-Jan-15 2:25 
Questionm_maxValue Pin
jhnlk20-Mar-14 4:12
memberjhnlk20-Mar-14 4:12 
QuestionaGauge Closed Pin
Member 992210316-Oct-13 12:10
memberMember 992210316-Oct-13 12:10 
AnswerRe: aGauge Closed Pin
Code Artist22-Oct-13 3:46
memberCode Artist22-Oct-13 3:46 
GeneralRe: aGauge Closed Pin
Member 992210323-Oct-13 0:21
memberMember 992210323-Oct-13 0:21 
GeneralRe: aGauge Closed Pin
Code Artist23-Oct-13 1:59
memberCode Artist23-Oct-13 1:59 
QuestionPicturebox collection and transparency Pin
N. Henrik Lauridsen7-Aug-13 20:07
memberN. Henrik Lauridsen7-Aug-13 20:07 
AnswerRe: Picturebox collection and transparency Pin
Code Artist22-Oct-13 3:55
memberCode Artist22-Oct-13 3:55 
GeneralRe: Picturebox collection and transparency Pin
N. Henrik Lauridsen22-Oct-13 4:04
memberN. Henrik Lauridsen22-Oct-13 4:04 
QuestionChrash on BaseArcStart = 315 & ScaleLinesMajorStepValue = 25 Pin
N. Henrik Lauridsen23-Jul-13 0:44
memberN. Henrik Lauridsen23-Jul-13 0:44 
AnswerRe: Chrash on BaseArcStart = 315 & ScaleLinesMajorStepValue = 25 Pin
Code Artist23-Jul-13 5:08
memberCode Artist23-Jul-13 5:08 
GeneralRe: Chrash on BaseArcStart = 315 & ScaleLinesMajorStepValue = 25 Pin
N. Henrik Lauridsen23-Jul-13 8:59
memberN. Henrik Lauridsen23-Jul-13 8:59 
GeneralRe: Chrash on BaseArcStart = 315 & ScaleLinesMajorStepValue = 25 Pin
Code Artist24-Jul-13 3:17
memberCode Artist24-Jul-13 3:17 
GeneralRe: Chrash on BaseArcStart = 315 & ScaleLinesMajorStepValue = 25 Pin
N. Henrik Lauridsen24-Jul-13 6:00
memberN. Henrik Lauridsen24-Jul-13 6:00 
GeneralRe: Chrash on BaseArcStart = 315 & ScaleLinesMajorStepValue = 25 Pin
Code Artist25-Jul-13 11:52
memberCode Artist25-Jul-13 11:52 
AnswerSolved Pin
N. Henrik Lauridsen25-Jul-13 22:53
memberN. Henrik Lauridsen25-Jul-13 22:53 
QuestionOutstanding Pin
tbrendza2-Jul-13 11:25
membertbrendza2-Jul-13 11:25 
QuestionThanks Pin
TheoSun20-Jun-13 13:12
memberTheoSun20-Jun-13 13:12 
QuestionUpgrade from previous version Pin
N. Henrik Lauridsen17-Jun-13 4:12
memberN. Henrik Lauridsen17-Jun-13 4:12 
AnswerRe: Upgrade from previous version Pin
Code Artist17-Jun-13 12:10
memberCode Artist17-Jun-13 12:10 
GeneralMy vote of 5 Pin
claudiotronic30-Apr-13 22:07
memberclaudiotronic30-Apr-13 22:07 
GeneralRe: My vote of 5 Pin
Code Artist1-May-13 2:55
memberCode Artist1-May-13 2:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150819.1 | Last Updated 29 Aug 2012
Article Copyright 2012 by Code Artist
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid