Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Pointers for Meter or Gauge?

Using MS, Ver 7.1.
Is it possible to show more than one pointer with a meter or gauge? For example, it would be nice to see the active pointer and a maximum pointer, in a different color.
Thanks in advance for the help,
Dennis
0 Kudos
Message 1 of 10
(5,753 Views)

Hi,

I'm not sure if 7.1 is the same as 7.0, but you

1. Right click the control and go to properties

2. There should be a tabe called "pointers".  under the listbox there is a add button.  press the add button.

3. When you do the Value, do ControlName.pointer.item(index of pointer).value

Hope this helps...

B

0 Kudos
Message 2 of 10
(5,746 Views)

Hello Bum,

Well, I've hunted for "pointers" in the properties page for both the meter and gauge. I can't find it.

Thanks for the help,

Dennis

0 Kudos
Message 3 of 10
(5,746 Views)
This can be accomplished by writing a little code. I created a class that derives from Gauge and exposed two properties; MaxPointerColor and MaxPointerValue. To use the class, drop a Gauge and change the line in InitializeComponent to instantiate the MultiplePointerGauge instead. You can still use the designer to configure the gauge after this change. To do this with a Meter you can follow the same pattern.
 public class MultiplePointerGauge : Gauge
        {
            private double _maxPointerValue;
            private Color _maxPointerColor;

            public MultiplePointerGauge() : base()
            {
                GaugeStyle = new MultiplePointersStyle();
                _maxPointerColor = PointerColor;
                _maxPointerValue = Value;
            }

            public Color MaxPointerColor
            {
                get
                {
                    return _maxPointerColor;
                }
                set
                {
                    _maxPointerColor = value;
                    Invalidate();
                }
            }

            public double MaxPointerValue
            {
                get
                {
                    return _maxPointerValue;
                }
                set
                {
                    _maxPointerValue = value;
                    Invalidate();
                }
            }

            private class MultiplePointersStyle : GaugeStyle
            {
                private GaugeStyle _baseStyle;

                public MultiplePointersStyle() : this(GaugeStyle.SunkenWithThickNeedle3D)
                {
                }

                public MultiplePointersStyle(GaugeStyle baseStyle)
                {
                    if(baseStyle == null)
                        throw new ArgumentNullException("baseStyle");

                    _baseStyle = baseStyle;                
                }

                public override void DrawSpindle(IGauge context, RadialNumericPointerStyleDrawArgs args)
                {      
                    _baseStyle.DrawSpindle(context, args);     
                }

                public override float GetDialRadius(IRadialNumericPointer context,
                    Graphics graphics, Rectangle bounds)
                {      
                    return _baseStyle.GetDialRadius(context, graphics, bounds);
                }     
  
                public override void DrawDial(IRadialNumericPointer context,
                    RadialNumericPointerStyleDrawArgs args)
                {      
                    _baseStyle.DrawDial(context, args);
                }

                public override RadialNumericPointerHitTestInfo HitTest(IRadialNumericPointer context,
                    Rectangle bounds, int x, int y)
                {      
                    return _baseStyle.HitTest(context, bounds, x, y);     
                }

                public override void DrawPointer(INumericPointer context,
                    NumericPointerStyleDrawArgs args, double value)
                {
                    MultiplePointerGauge gauge = context as MultiplePointerGauge;

                    Color defaultColor = context.PointerColor;
                    _baseStyle.DrawPointer(context, args, value);

                    context.PointerColor = gauge.MaxPointerColor;
                    _baseStyle.DrawPointer(context, args, gauge.MaxPointerValue);
                    context.PointerColor = defaultColor;
                }     
  
                public override float GetScaleRadius(IRadialNumericPointer context,
                    Graphics graphics, Rectangle bounds)
                {      
                    return _baseStyle.GetScaleRadius (context, graphics, bounds);
                }  
            }  
        }
Message 4 of 10
(5,736 Views)
Wow! Thanks for the great response. I'll try it out soon.
It looks like I'll add to my C# skills by studying it.
Thanks a lot,
Dennis
0 Kudos
Message 5 of 10
(5,725 Views)

Hi,

 

Converted the class code to VB.NET, see the 2 new properties, but don't see a 2nd pointer.

Can someone please post a sample program in VB.NET or C# please.

 

Why isn't there a pointers collection like in the ActiveX version of the control?

 

I need a 2nd pointer for my app...please help 😉

 

 

0 Kudos
Message 6 of 10
(5,231 Views)

U could try to use the control in 6.0, then convert the 6.0 project into vb.net.  I don't know why, but in 6.0 you can add multiple pointers.  I attached a pic of the ActiveX interface in 6.0 hope it uploaded.  Not sure why this functionality isn't readily apparent in later versions...

0 Kudos
Message 7 of 10
(5,225 Views)

Yes. I know, but I didn't want to use an ActiveX control when there's a NET version.

I think NI designed the NET controls completly new. That's ok for me. But it's not ok

that they lost some of their functionality ;-(

 

The NET version is out now for about 5 years and they didn't add a collection for pointers,

very disappointing I must say.

0 Kudos
Message 8 of 10
(5,222 Views)

For that particular need (a max indicator), a workaround is to use the [RangeFills] collection.  You can specify a range that is from an 'x' angle to 'x+1' and make its width to something large, such as 10 or 20. That way you will have a specific indicator in your gauge.

 

Another option is to use a CustomDivisions collection element.

0 Kudos
Message 9 of 10
(5,065 Views)

hi can you attach a small application which uses your class

thanks..

0 Kudos
Message 10 of 10
(4,291 Views)