Hello.. I would like to give gradient color to mulilayer object's fill color & pen color (Objcts-Ellips,Rectangle, Line,text and polygon) is it possible? pls help me with sample codes....
Here is the code snippet which illustrates how to set gradient color for rectangle vector object:
Aurigma.GraphicsMill.WinControls.RectangleVObject rectangle = new Aurigma.GraphicsMill.WinControls.RectangleVObject(0F, 0F,multiLayerViewer1.WorkspaceWidth/10, multiLayerViewer1.WorkspaceHeight/10);
//Modify stroke and fill parameters
rectangle.Pen = new System.Drawing.Pen(System.Drawing.Color.BlanchedAlmond, 10F);
//Fill gradient
rectangle.Brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 10),new Point(200, 10), System.Drawing.Color.Wheat, System.Drawing.Color.Black);
//Add the rectangle to a layer
multiLayerViewer1.Layers[0].VObjects.Add(rectangle);
...
using (Brush aGradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 10), new Point(200, 10), Color.Blue, Color.Red))
rectangle.Pen = new System.Drawing.Pen(aGradientBrush, 10F);
...
Sorry, but it is impossible. Pen and brush use standard LinearGradientBrush class to set the gradient color. Unfortunately, there is no way to apply it to ImageVObject of Graphics Mill.
I am using following code to apply gradient color in multilayer background object's color. but it shows error. Using (Brush aGradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 10), new Point(200, 10), Color.Blue, Color.Red)) background.Color = new System.Drawing.Pen(aGradientBrush).Color;
Okay, thank you for the details. I checked it, and confirm that it is impossible to set gradient color of SolidBackgroundVObject. I recommend you to use lock RectangleVObject as a background, and set the gradient color in the way described above of this thread.
"using (Brush aGradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 10), new Point(200, 10), Color.Blue, Color.Red)) rectangle.Pen = new System.Drawing.Pen(aGradientBrush, 10F);" to make gradient pen color. but its making error with "multiLayerViewer.SaveState()". pls provide me a solution...
I attached a sample, you please add a rectangle or ellips to multilayerviewer and change its settings (by changing brush or....).. it will make error... in this, i added the above code for pen. After setting the pen , moving objects making a unhandled exception ....
Okay, I tried the sample, and got the error. Unfortunately, here setting gradient color for Pen is impossible. There is Pen is a class of System.Drawing, which has its own Color property. It cannot be gradient color. Therefore, you face the exception.