How do I Gradient Fill A Polygon the Compact Framework way?

M

mcm

Help! I need to gradient fill a Polygon on a Windows CE 5.0 system. How do I do it?


This works beautifully on a Windows Vista desktop as the target:
//*******************************
GraphicsPath pathPoints;

// fill the points path (for example a rounded rectangle)

Brush brushButton = new LinearGradientBrush(rectDraw, colorTop, colorBottom, LinearGradientMode.Vertical);
e.Graphics.FillPath(brushButton, pathPoints);

//*******************************


However I need to run my app on a CE 5.0 (.NET) system.
I've made the shape into a Polygon since the Compact Framework doesn't have a "GraphicsPath" - however, I really want to fill the polygon with a gradient.

//*******************************
Point[] pointArray;

// fill the point array with (for example) a manually generated rounded rectangle

Brush brushFill = new SolidBrush(Color.Blue); // I want this to be a gradien not solid!!!!
e.Graphics.FillPolygon(brushFill, pointArray);
//********************************

Microsoft shows how to fill a rectangle: http://msdn2.microsoft.com/en-us/library/ms229655.aspx
but not a polygon.

How do I do it?
 
M

Mark Erikson

Help!  I need to gradient fill a Polygon on a Windows CE 5.0 system.  How do I do it?

This works beautifully on a Windows Vista desktop as the target:
//*******************************
GraphicsPath pathPoints;

// fill the points path (for example a rounded rectangle)

Brush brushButton = new LinearGradientBrush(rectDraw, colorTop, colorBottom, LinearGradientMode.Vertical);
e.Graphics.FillPath(brushButton, pathPoints);

//*******************************

However I need to run my app on a CE 5.0 (.NET) system.
I've made the shape into a Polygon since the Compact Framework doesn't have a "GraphicsPath" - however, I really want to fill the polygon with a gradient.

//*******************************
Point[]  pointArray;

// fill the point array with (for example) a manually generated rounded rectangle

Brush brushFill = new SolidBrush(Color.Blue);   // I want this to be agradien not solid!!!!
e.Graphics.FillPolygon(brushFill, pointArray);
//********************************

Microsoft shows how to fill a rectangle:http://msdn2.microsoft.com/en-us/library/ms229655.aspx
but not a polygon.

How do I do it?

There's a GDI+ replacement for the Compact Framework, the XrossOne
Mobile GDI+ toolkit. XrossOne seems to have disappeared, but I've
mirrored the toolkit on my site: http://www.isquaredsoftware.com/code.php
. This toolkit includes a GraphicsPath implementation, some
GradientBrushes, and Graphics.DrawPath().

Hope this helps!

Mark Erikson
http://www.isquaredsoftware.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top