Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
UltraGauge MultiStopRadialGradientBrushElement
posted

I am converting one of the xml preset gauges to c#. At the most basic level, I cannot create a dial.
I could use some examples using the MultiStopRadialGradientBrushElement in c#. Here's an excerpt of the multi stop section:

MultiStopRadialGradientBrushElement myMultiStopRadialGradientBrushElement = new MultiStopRadialGradientBrushElement();

PointF pf;
Rectangle rect;
ColorStop myColorStop = new ColorStop();
myColorStop.Color = Color.Transparent;
pf = new PointF( 0.8F, 0.8F );
myMultiStopRadialGradientBrushElement.FocusScales = pf;
pf = new PointF( 50F, 50F );
myMultiStopRadialGradientBrushElement.CenterPoint = pf;
myMultiStopRadialGradientBrushElement.RelativeBoundsMeasure =
Measure.Percent;
rect = new Rectangle( 2, 2, 96, 96 );
myMultiStopRadialGradientBrushElement.RelativeBounds = rect;
myColorStop.Color =Color.DarkOrange;
myMultiStopRadialGradientBrushElement.ColorStops.Add( myColorStop );
myColorStop.Color = Color.FromArgb( ((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)240)))) );
myColorStop.Stop = 0.02413793F;
myMultiStopRadialGradientBrushElement.ColorStops.Add( myColorStop );
myColorStop.Color = Color.FromArgb( ((int)(((byte)(30)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))) );
myColorStop.Stop = 0.2655172F;
myMultiStopRadialGradientBrushElement.ColorStops.Add( myColorStop );
myColorStop.Color = Color.Transparent;
myColorStop.Stop = 0.4551724F;
myMultiStopRadialGradientBrushElement.ColorStops.Add( myColorStop );
myColorStop.Color = Color.Transparent;
myColorStop.Stop = 1F;
myMultiStopRadialGradientBrushElement.ColorStops.Add( myColorStop );
myBrushElementGroup.BrushElements.Add( myMultiStopRadialGradientBrushElement );
myRadialGauge.Dial.BrushElement = myBrushElementGroup;
myRadialGauge.Margin =
new Margin( 10, 10, 10, 10, Measure .Pixels );

Parents
No Data
Reply
  • 28496
    Offline posted

    you are using the same instance of the ColorStop object over and over again.  therefore, when you set Color = Transparent and Stop = 1F at the end, this is for every ColorStop in the BrushElement (because there is only one instance).

    each time you add a colorstop to the collection, you should use this code afterwards:

    myColorStop = new ColorStop();

Children
No Data