Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

ScaleRangeFillStyle for Slide Controls

I am trying change the color of the slide fill style to match the current range fill when the ValueEnterRange event is fired.  How do you obtain the range fill style properties?  I can get the style from the ScaleRangeFillEventArgs parameter "e" (ScaleRangeFillStyle style = e.ScaleRangeFill.Style 😉  but there are no properties associated with the style.

0 Kudos
Message 1 of 5
(5,861 Views)

Hi justwakingup,

 

You can create a new ScaleRangeFillStyle using the CreateSolidStyle Method, which creates a solid fill of a specified color. The ScaleRangeFillStyle Class also has a method to create a gradient style, and create a fill style that is drawn using a particular fill style and a given color.

 

Regards,

 

Alexandra

National Instruments
Applications Engineer
0 Kudos
Message 2 of 5
(5,847 Views)

I have a property editor that allows the end user of the application create the RangeFills.  I need to read back the colors that they have chosen.  Is there a way to do this?  Almost every other color property of the control that I tried to find is available.

0 Kudos
Message 3 of 5
(5,842 Views)

Hi justwakingup,

 

Based on the documentation in our Help files, I see no way to get the color back once it is set.

 

Regards,

 

Alexandra

National Instruments
Applications Engineer
0 Kudos
Message 4 of 5
(5,829 Views)

For anyone interested in solving this issue I found this work around using Type Converters

 

//Convert Range Fill Styles to string
TypeConverter styleCon = TypeDescriptor.GetConverter(typeof(ScaleRangeFillStyle));
foreach (ScaleRangeFill range in BarGauge.RangeFills)
{

string strFill = styleCon.ConvertToString(range.Style);
}

 

 

//Restore the range fill styles
BarGauge.RangeFills[i].Style = (ScaleRangeFillStyle)styleCon.ConvertFromString(strFill);

 

This allows you to convert the style to a string which will look something like : "Solid: Blue" for a solid blue fill style.  I then parsed the string to get the color and used a Color Converter like this

 

TypeConverter colorCon = TypeDescriptor.GetConverter(typeof(Color));

 

BarGauge.FillColor = (Color)colorCon.ConvertFromString(strColor);

0 Kudos
Message 5 of 5
(5,796 Views)