System.Drawing.Drawing2D.PathGradientBrush.Setup C# (CSharp) Method

Setup() private method

private Setup ( Graphics graphics, bool fill ) : void
graphics System.Drawing.Graphics
fill bool
return void
        internal override void Setup(Graphics graphics, bool fill)
        {
            CGContext context = graphics.context;

            // if fill is false then we are being called from a Pen stroke so
            // we need to setup a transparency layer
            // http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_shadings/dq_shadings.html#//apple_ref/doc/uid/TP30001066-CH207-BBCECJBF
            if (!fill)
            {
                context.BeginTransparencyLayer();
                hasTransparencyLayer = true;
                // Make sure we set a color here so that the gradient shows up
                graphics.lastBrushColor = Color.Black;
                return;
            }

            // if this is the same as the last that was set and no changes have been made
            // then return.
            if (graphics.LastBrush != this || changed)
            {
                //setupShadingColors();
            }

            // Transform the start and end points using the brush's transformation matrix
            gradientTransform.TransformPoints(pathPoints);

            RasterizePolygon (context, centerPoint, pathPoints, surroundColors, centerColor);

            // If we are in a Transparency layer then we need to end the transparency
            if (hasTransparencyLayer) {
                context.EndTransparencyLayer();
            }

            changed = false;

            graphics.LastBrush = this;
            // We will reset the last pen so that it can be setup again
            // so that we do not loose the settings after stroking the gradient
            // not sure where the setting are being reset so this may be a hack
            // and things are just not being restored correctly.
            graphics.LastPen = null;
            // I am setting this to be used for Text coloring in DrawString
            graphics.lastBrushColor = surroundColors[surroundColors.Length - 1];
        }