Company      |       Articles & Research      |      Services      |      Software      |      Contact

Building Infragistics Gauges in WebPart

Recently, I employ the Infragistics controls for a client project where personnel data had to be displayed in a dashboard-like format, the Gauge (UltraGauge) control being the most popular within the organization. There was some pre-existing ad-hoc development, so I got to examine numerous variations of how to suitably instantiate the various Infragistics components.

Consider the below GaugeBuilders class. The BasicGaugeFactory method consumes an id string since the UltraGauge.ID property is the only diverse property between UltraGauges on instantiatation. While this hydrates the object with the sufficient properties, the QueryAndAssignGaugeValues method consumes the UltraGauge control and an integer representing the value to set the gauge at. Since there are various Types of UltraGauges so value setting contrasts, such as RadialGauge, SegmentedDigitalGauge, LinearGauge, UltraGauge.GetType() has to be tested, probably in a not so efficient format.

Arguably, the two of these could easily be merged into one method, whereby the gauge is created and set within a single call. Or QueryAndAssignGaugeValues could just be called after UltraGauge.LoadPreset. It’s really just a preference.

C#:
  1. using System;
  2. using System.Web.UI.WebControls;
  3. using Infragistics.UltraGauge.Resources;
  4. using Infragistics.WebUI.UltraWebGauge;
  5.  
  6. namespace infragistics.Generic
  7. {
  8. public class GaugeBuilders
  9. {
  10. public static UltraGauge BasicGaugeFactory(string id)
  11. {
  12. var gauge = new UltraGauge {ID = id, Height = Unit.Pixel(250), Width = Unit.Pixel(250)};
  13. WebGaugeDeploymentScenario deployment = gauge.DeploymentScenario;
  14. deployment.Mode = ImageDeploymentMode.FileSystem;
  15. deployment.FilePath = "~/GaugeImages";
  16. deployment.ImageURL = "~/GaugeImages/gauge_month_#SEQNUM(100).png";
  17. deployment.ImageTQpe = GaugeImageType.Png;
  18. gauge.LoadPreset( @"Path_To_Your_XML_Structure_FIle ", true);
  19. return gauge;
  20. }
  21.  
  22. public static void QueryAndAssignGaugeValues(UltraGauge gaugeParameter, int number)
  23. {
  24. foreach (Gauge gauge in gaugeParameter.Gauges)
  25. {
  26. Type gaugeType = gauge.GetType();
  27. if (Equals(gaugeType, typeof (RadialGauge)))
  28. {
  29. var rg = (RadialGauge) gauge;
  30. rg.Scales[0].Markers[0].Value = number;
  31. }
  32. if (Equals(gaugeType, typeof (SegmentedDigitalGauge)))
  33. {
  34. var rg = (SegmentedDigitalGauge) gauge;
  35. rg.Text = number.ToString();
  36. }
  37. if (Equals(gaugeType, typeof (LinearGauge)))
  38. {
  39. var rg = (LinearGauge) gauge;
  40. if (rg.Scales[0] != null)
  41. {
  42. rg.Scales[0].Markers[0].Value = Convert.ToInt32(number);
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }

share save 171 16 Building Infragistics Gauges in WebPart

Related posts:

  1. The Infragistics SharePoint Demo Is Funny, But Depressing
  2. Building A Simple SharePoint 2007 / WSS v3 WebPart
  3. Building SharePoint WebParts in Chrome and Delphi
  4. Using DescriptionAttribute And Reflection For Building Typed Collections Off Enumerations
  5. CATPCHA WebPart For SharePoint Blogs Is Done!

2 Comments »

  1. This is a lot better than the infragistics example, at least it is reasonable to follow.

    Comment by Steve Christopherson — September 8, 2009 @ 8:47 pm

  2. Kindly tell me how we add Infragistics.UltraGauge.Resources namespace in C#
    I simply wrote using “Infragistics.UltraGauge.Resources ” but it gives me an error
    Thanks in Advance

    Comment by fahim — December 3, 2010 @ 11:32 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment