We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Gradient Colors to be obsoleted?

I am working throught the source code and there is an obsolete flag on the GradientColors property of the Gradient Panel. It says this property is to be removed in the future.

Is there another way to create multicolor gradients? Meaning gradients with more than 2 colors.

Thanks,

Bob

7 Replies

AR Anupama Roy Syncfusion Team August 24, 2006 11:16 AM UTC


Hi Bob,

You can use the BackgroundColor inorder to get multiple colors

Code:

this.gradientPanel1.BackgroundColor = new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Horizontal, new System.Drawing.Color[] {
System.Drawing.SystemColors.Info,System.Drawing.Color.Magenta,System.Drawing.Color.Aqua});

Please let me know if you have any difficulties.

Thanks for choosing Syncfusion products.

Regards,

Anu.


AR Anupama Roy Syncfusion Team August 24, 2006 11:28 AM UTC

Hi Bob,

Please take a look this screenshot also.

Screenshot

Thanks,

Anu.



RM Robert Maxey August 24, 2006 06:11 PM UTC



>Hi Bob,

Please take a look this screenshot also.

Screenshot

Thanks,

Anu.


Anu,

This property that you point out on the screen shot is the property that is marked obsolete in the source code.

Using backcolor only gives two color gradients. There is a property in the LinearGradientBrush called InterpolationColors that allows gradients with more than two colors. I am wondering how I can supply InterpolationColors to the Gradient Panel.

But again, the code says that the property is to be obsoleted. That is why I am concerned.

Thanks.

Bob


AR Anupama Roy Syncfusion Team August 25, 2006 05:37 AM UTC


Hi Bob,

This Screenshot is taken with our current version 4.2.Could you please let us know the version of Essential Studio you are working with,so that I can provide you an accurate solution.

Thanks,

Anu.


RM Robert Maxey August 25, 2006 06:45 PM UTC



>
Hi Bob,

This Screenshot is taken with our current version 4.2.Could you please let us know the version of Essential Studio you are working with,so that I can provide you an accurate solution.

Thanks,

Anu.

I am working in 4.2. And I do see that the Gradient Colors are there. But when I look at the source code:


///
/// Gets / sets the color array that defines the gradient.
///

///
/// This property will be removed in the future. Please use the BackgroundColor property instead.
///

[Browsable(false),
Obsolete("This property will be removed in the future. Please use the BackgroundColor property instead."),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Color[] GradientColors
{
get{return (Color[])(this.BackgroundColor.GradientColors.ToArray(typeof(Color)));}
set
{
BrushInfo bi = this.BackgroundColor;

if(bi.Style == BrushStyle.Gradient)
{
this.BackgroundColor = new BrushInfo(bi.GradientStyle, new BrushInfoColorArrayList(value));
}
else if(bi.Style == BrushStyle.Pattern)
{
this.BackgroundColor = new BrushInfo(bi.PatternStyle, new BrushInfoColorArrayList(value));
}
else if(value.Length > 0)
{
this.BackgroundColor = new BrushInfo(GradientStyle.Vertical, new BrushInfoColorArrayList(value));
}
}
}


It says that the property is to be obsoleted. There are instructions to not use this function. Note the Obsolete attribute in the code above.

Bob


AR Anupama Roy Syncfusion Team August 31, 2006 04:57 AM UTC

Hi Bob,

Sorry for the delay.I had gone for a vecation and could not get back to you immediately.

If you closely observe,you can see that there is one property gradientPanel1.GradientColors and this obsolete attribute in the code above says that you should not use this property GradientColors directly.The property I had marked in the screenshot is BackgroundColor and within this property,the above mentioned GradientColors array will be passed and you can get the desired Gradient or Pattern behaviour.There is no harm in using BackgroundColor property and this will not be removed from our source code.

Please let me know if you have any other queries.

Thanks for your patience.

Best Regards,

Anu.



RM Robert Maxey August 31, 2006 11:06 PM UTC

Anu,

I understand how I can use forecolor and backcolor to make a gradient with 2 colors in it. But that gradient colors (called interpolation colors in the LinearGradientBrush) property allows more than 2 colors. You also have more control in the way gradient colors appear.

Check out the ColorBlend object is the .NET framework.

I can get by for now with 2 colors, but I would hope that future updates of your product will allow me to have gradients with more than 2 colors in them. That is why I am so concerned about obsoleting that property. It seems to be progress in the wrong direction.

Maybe I''ll need to write my own?

Thanks!

Bob

Loader.
Live Chat Icon For mobile
Up arrow icon