//UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
		private void  init(System.Drawing.Drawing2D.GraphicsPath shape, Point origin, FillStyle fs, LineStyle ls, bool fill)
		{
			builder = new ShapeBuilder(origin);
			linestyles = new System.Collections.ArrayList(2);
			fillstyles = new System.Collections.ArrayList(2);
			
			if (fill && fs != null)
			{
				builder.UseFillStyle0 = true;
				builder.CurrentFillStyle0 = addFillStyle(fs);
			}
			
			if (ls != null)
				builder.CurrentLineStyle = addLineStyle(ls);
			
			//UPGRADE_TODO: Method 'java.awt.Shape.getPathIterator' was converted to 'System.Drawing.Drawing2D.GraphicsPathIterator.GraphicsPathIterator' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtShapegetPathIterator_javaawtgeomAffineTransform'"
			builder.processShape(new PathIteratorWrapper(new System.Drawing.Drawing2D.GraphicsPathIterator(shape)));
		}
        public static DefineShape buildImage(DefineBits tag, int width, int height)
        {
            // Create Fill Style
            Matrix matrix = new Matrix();

            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            matrix.scaleX = (int)System.Math.Round((double)(flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE));
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            matrix.scaleY   = (int)System.Math.Round((double)(flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE));
            matrix.hasScale = true;             //Apply runtime scale of 20 (for twips)
            FillStyle fs = new FillStyle(FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP, matrix, tag);

            // Apply Fill Styles
            ShapeWithStyle sws = new ShapeWithStyle();

            sws.fillstyles = new System.Collections.ArrayList();
            //UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.add' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
            int fsIndex = sws.fillstyles.Add(fs) >= 0?sws.fillstyles.LastIndexOf(fs) + 1:0;

            sws.linestyles = new System.Collections.ArrayList();

            // Build Raw SWF Shape
            ShapeBuilder builder = new ShapeBuilder(new Point());

            builder.UseFillStyle0     = true;
            builder.CurrentFillStyle0 = fsIndex;
            builder.move(0, 0);
            builder.straight(width, 0);
            builder.straight(width, height);
            builder.straight(0, height);
            builder.straight(0, 0);
            builder.correctRoundingErrors();
            sws.shapeRecords = builder.build().shapeRecords;

            // Wrap up into a SWF DefineShape Tag
            DefineShape defineShape = new DefineShape(flash.swf.TagValues_Fields.stagDefineShape3);

            defineShape.bounds         = new Rect(width * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL, height * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL);
            defineShape.shapeWithStyle = sws;

            return(defineShape);
        }
		public static DefineShape buildImage(DefineBits tag, int width, int height)
		{
			// Create Fill Style
			Matrix matrix = new Matrix();
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			matrix.scaleX = (int) System.Math.Round((double) (flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE));
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			matrix.scaleY = (int) System.Math.Round((double) (flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL * flash.swf.SwfConstants_Fields.FIXED_POINT_MULTIPLE));
			matrix.hasScale = true; //Apply runtime scale of 20 (for twips)
			FillStyle fs = new FillStyle(FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP, matrix, tag);
			
			// Apply Fill Styles
			ShapeWithStyle sws = new ShapeWithStyle();
			sws.fillstyles = new System.Collections.ArrayList();
			//UPGRADE_TODO: The equivalent in .NET for method 'java.util.ArrayList.add' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
			int fsIndex = sws.fillstyles.Add(fs) >= 0?sws.fillstyles.LastIndexOf(fs) + 1:0;
			sws.linestyles = new System.Collections.ArrayList();
			
			// Build Raw SWF Shape
			ShapeBuilder builder = new ShapeBuilder(new Point());
			builder.UseFillStyle0 = true;
			builder.CurrentFillStyle0 = fsIndex;
			builder.move(0, 0);
			builder.straight(width, 0);
			builder.straight(width, height);
			builder.straight(0, height);
			builder.straight(0, 0);
			builder.correctRoundingErrors();
			sws.shapeRecords = builder.build().shapeRecords;
			
			// Wrap up into a SWF DefineShape Tag
			DefineShape defineShape = new DefineShape(flash.swf.TagValues_Fields.stagDefineShape3);
			defineShape.bounds = new Rect(width * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL, height * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL);
			defineShape.shapeWithStyle = sws;
			
			return defineShape;
		}
        //UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
        public ShapeWithStyleBuilder(System.Drawing.Drawing2D.GraphicsPath shape, GraphicContext graphicContext, bool outline, bool fill)
        {
            Point origin = new Point((double)graphicContext.getPen().X, (double)graphicContext.getPen().Y);

            System.Drawing.Brush paint  = graphicContext.Paint;
            System.Drawing.Pen   stroke = graphicContext.Stroke;

            FillStyle fs = null;
            LineStyle ls = null;

            if (fill && paint != null)
            {
                System.Drawing.RectangleF tempAux = shape.GetBounds();
                //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                fs = FillStyleBuilder.build(paint, ref tempAux, graphicContext.Transform);
            }

            if (outline && stroke != null)
            {
                ls = LineStyleBuilder.build(paint, stroke);
            }

            init(shape, origin, fs, ls, fill);
        }
		/// <summary> Utility method to create an appropriate <code>FillStyle</code> from a <code>Paint</code>.</summary>
		/// <param name="paint">an AWT <code>Paint</code> instance
		/// </param>
		/// <param name="bounds">- required for gradient ratio calculation
		/// </param>
		/// <returns> a new <code>FillStyle</code> representing the given paint
		/// </returns>
		//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
		public static FillStyle build(System.Drawing.Brush paint, ref System.Drawing.RectangleF bounds, System.Drawing.Drawing2D.Matrix transform)
		{
			FillStyle fs = null;
			
			if (paint != null)
			{
				double width = (double) bounds.Width;
				double height = (double) bounds.Height;
				
				if (paint is System.Drawing.Color)
				{
					//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
					fs = new FillStyle(SwfUtils.colorToInt(ref new System.Drawing.Color[]{(System.Drawing.Color) paint}[0]));
				}
				else if (paint is System.Drawing.Drawing2D.LinearGradientBrush)
				{
					System.Drawing.Drawing2D.LinearGradientBrush gp = (System.Drawing.Drawing2D.LinearGradientBrush) paint;
					//UPGRADE_ISSUE: Method 'java.awt.geom.AffineTransform.transform' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtgeomAffineTransformtransform_javaawtgeomPoint2D_javaawtgeomPoint2D'"
					System.Drawing.PointF tempAux = System.Drawing.PointF.Empty;
					System.Drawing.PointF tempAux2 = System.Drawing.PointF.Empty;
					System.Drawing.PointF tempAux3 = transform.transform(new System.Drawing.PointF(gp.Rectangle.X, gp.Rectangle.Y), tempAux);
					//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
					System.Drawing.PointF tempAux4 = transform.transform(new System.Drawing.PointF(gp.Rectangle.Height, gp.Rectangle.Width), tempAux2);
					System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref tempAux3, ref tempAux4, width, height, width, height);
					fs = new FillStyle();
					fs.matrix = MatrixBuilder.build(gt);
					
					fs.type = FillStyle.FILL_LINEAR_GRADIENT;
					
					fs.gradient = new Gradient();
					fs.gradient.records = new GradRecord[2];
					System.Drawing.Color tempAux5 = (gp.LinearColors)[0];
					//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
					fs.gradient.records[0] = new GradRecord(0, SwfUtils.colorToInt(ref tempAux5)); //from left
					System.Drawing.Color tempAux6 = (gp.LinearColors)[1];
					//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
					fs.gradient.records[1] = new GradRecord(255, SwfUtils.colorToInt(ref tempAux6)); //to right
				}
				else if (paint is LinearGradientPaint)
				{
					LinearGradientPaint lgp = (LinearGradientPaint) paint;
					System.Drawing.PointF start = lgp.getStartPoint();
					System.Drawing.PointF end = lgp.getEndPoint();
					
					//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
					System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref start, ref end, width, height, width, height);
					
					fs = new FillStyle();
					fs.matrix = MatrixBuilder.build(gt);
					
					System.Drawing.Color[] colors = lgp.getColors();
					float[] ratios = lgp.getFractions();
					
					if (colors.Length == 0 || colors.Length != ratios.Length)
					//Invalid fill so we skip
					{
						return null;
					}
					else if (colors.Length == 1)
					//Solid fill
					{
						//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
						return new FillStyle(SwfUtils.colorToInt(ref colors[0]));
					}
					else
					{
						fs.type = FillStyle.FILL_LINEAR_GRADIENT;
						
						//Maximum of 8 gradient control points records
						int len = ratios.Length;
						if (len > 8)
							len = 8;
						fs.gradient = new Gradient();
						fs.gradient.records = new GradRecord[len];
						
						for (int i = 0; i < len; i++)
						{
							//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
							//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
							fs.gradient.records[i] = new GradRecord((int) System.Math.Round((double) (255 * ratios[i])), SwfUtils.colorToInt(ref colors[i]));
						}
					}
				}
				else if (paint is RadialGradientPaint)
				{
					RadialGradientPaint rgp = (RadialGradientPaint) paint;
					
					//Note: Flash doesn't support the focal point of a radial gradient
					//Point2D cp = rgp.getCenterPoint();
					//Point2D fp = rgp.getFocusPoint();
					double diameter = rgp.getRadius() * 2.0;
					double outerX = diameter * rgp.getTransform().getScaleX();
					double outerY = diameter * rgp.getTransform().getScaleY();
					
					System.Drawing.PointF tempAux7 = System.Drawing.PointF.Empty;
					System.Drawing.PointF tempAux8 = System.Drawing.PointF.Empty;
					//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
					System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref tempAux7, ref tempAux8, width, height, outerX, outerY);
					fs = new FillStyle();
					fs.matrix = MatrixBuilder.build(gt);
					
					fs.type = FillStyle.FILL_RADIAL_GRADIENT;
					
					System.Drawing.Color[] colors = rgp.getColors();
					float[] ratios = rgp.getFractions();
					
					fs.gradient = new Gradient();
					fs.gradient.records = new GradRecord[ratios.Length <= 8?ratios.Length:8];
					for (int i = 0; i < ratios.Length && i < 8; i++)
					{
						//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
						//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
						fs.gradient.records[i] = new GradRecord((int) System.Math.Round((double) (255 * ratios[i])), SwfUtils.colorToInt(ref colors[i]));
					}
				}
				else if (paint is System.Drawing.TextureBrush)
				{
					System.Drawing.TextureBrush tp = (System.Drawing.TextureBrush) paint;
					System.Drawing.Image image = (System.Drawing.Image) tp.Image;
					
					DefineBitsLossless tag = DefineBitsLosslessBuilder.build(new LosslessImage(image));
					
					//Apply Twips Scale of 20 x 20
					System.Drawing.Drawing2D.Matrix at = new System.Drawing.Drawing2D.Matrix();
					at.Scale((System.Single) flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL, (System.Single) flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL);
					Matrix matrix = MatrixBuilder.build(at);
					
					fs = new FillStyle(FillStyle.FILL_BITS, matrix, tag);
				}
			}
			
			return fs;
		}
		public virtual void  fillstyle(SaxAttributesSupport attributes)
		{
			DefineShape defineShape = (DefineShape) stack[stack.Count - 1];
			bool hasAlpha = (defineShape.code == flash.swf.TagValues_Fields.stagDefineShape3);
			FillStyle fillstyle = new FillStyle();
			if (hasAttribute(attributes, "color"))
			{
				fillstyle.Type = FillStyle.FILL_SOLID;
				fillstyle.color = hasAlpha?parseRGBA(getAttribute(attributes, "color")):parseRGB(getAttribute(attributes, "color"));
			}
			if (hasAttribute(attributes, "gradient"))
			{
				// todo support radial gradients
				fillstyle.Type = FillStyle.FILL_LINEAR_GRADIENT;
				fillstyle.gradient = parseGradient(getAttribute(attributes, "gradient"), hasAlpha);
				fillstyle.matrix = parseMatrix(getAttribute(attributes, "matrix"));
			}
			if (hasAttribute(attributes, "idref"))
			{
				// todo support clipped bitmaps
				fillstyle.Type = FillStyle.FILL_BITS; // tiled
				int idref = parseInt(getAttribute(attributes, "idref"));
				// todo check to make sure bitmapId points to a bitmap
				fillstyle.bitmap = findCharacter(idref);
				fillstyle.matrix = parseMatrix(getAttribute(attributes, "matrix"));
			}
			
			defineShape.shapeWithStyle.fillstyles.Add(fillstyle);
		}
		/// <summary> Adds a new fill style to the <code>FillStyleArray</code>. If the given <code>FillStyle</code>
		/// is <code>null</code>, the style is ignored and an index of 0 is returned.
		/// </summary>
		/// <param name="fs">the new <code>FillStyle</code>
		/// </param>
		/// <returns> index pointing to this fill style in the <code>FillStyleArray</code>
		/// </returns>
		public int addFillStyle(FillStyle fs)
		{
			//UPGRADE_TODO: The equivalent in .NET for method 'java.util.List.add' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
			return fillstyles.Add(fs) >= 0?((System.Collections.ArrayList) fillstyles).LastIndexOf(fs) + 1:0; //Index in a 1-based array, 0 = none
		}
		//UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
		public ShapeWithStyleBuilder(System.Drawing.Drawing2D.GraphicsPath shape, Point origin, FillStyle fs, LineStyle ls, bool fill)
		{
			init(shape, origin, fs, ls, fill);
		}
		private void  encodeFillStyle(FillStyle style, SwfEncoder w, int shape)
		{
			w.writeUI8(style.type);
			switch (style.type)
			{
				
				case FillStyle.FILL_SOLID:  // 0x00
					if ((shape == flash.swf.TagValues_Fields.stagDefineShape3) || (shape == flash.swf.TagValues_Fields.stagDefineShape6))
						encodeRGBA(style.color, w);
					else
						encodeRGB(style.color, w);
					break;
				
				case FillStyle.FILL_GRADIENT: 
				// 0x10 linear gradient fill
				case FillStyle.FILL_RADIAL_GRADIENT: 
				// 0x12 radial gradient fill
				case FillStyle.FILL_FOCAL_RADIAL_GRADIENT:  // 0x13 focal radial gradient fill
					encodeMatrix(style.matrix, w);
					encodeGradient(style.gradient, w, shape);
					break;
				
				case FillStyle.FILL_BITS: 
				// 0x40 tiled bitmap fill
				case (FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP): 
				// 0x41 clipped bitmap fill
				case (FillStyle.FILL_BITS | FillStyle.FILL_BITS_NOSMOOTH): 
				// 0x42 tiled non-smoothed fill
				case (FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP | FillStyle.FILL_BITS_NOSMOOTH):  // 0x43 clipped non-smoothed fill
					w.writeUI16(dict.getId(style.bitmap));
					encodeMatrix(style.matrix, w);
					break;
				}
		}
		//UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
		public DefineShapeBuilder(System.Drawing.Drawing2D.GraphicsPath shape, Point origin, FillStyle fs, LineStyle ls, bool fill):this()
		{
			sws = new ShapeWithStyleBuilder(shape, origin, fs, ls, fill);
		}
Beispiel #11
0
        /// <summary> Utility method to create an appropriate <code>FillStyle</code> from a <code>Paint</code>.</summary>
        /// <param name="paint">an AWT <code>Paint</code> instance
        /// </param>
        /// <param name="bounds">- required for gradient ratio calculation
        /// </param>
        /// <returns> a new <code>FillStyle</code> representing the given paint
        /// </returns>
        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
        public static FillStyle build(System.Drawing.Brush paint, ref System.Drawing.RectangleF bounds, System.Drawing.Drawing2D.Matrix transform)
        {
            FillStyle fs = null;

            if (paint != null)
            {
                double width  = (double)bounds.Width;
                double height = (double)bounds.Height;

                if (paint is System.Drawing.Color)
                {
                    //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                    fs = new FillStyle(SwfUtils.colorToInt(ref new System.Drawing.Color[] { (System.Drawing.Color)paint }[0]));
                }
                else if (paint is System.Drawing.Drawing2D.LinearGradientBrush)
                {
                    System.Drawing.Drawing2D.LinearGradientBrush gp = (System.Drawing.Drawing2D.LinearGradientBrush)paint;
                    //UPGRADE_ISSUE: Method 'java.awt.geom.AffineTransform.transform' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtgeomAffineTransformtransform_javaawtgeomPoint2D_javaawtgeomPoint2D'"
                    System.Drawing.PointF tempAux  = System.Drawing.PointF.Empty;
                    System.Drawing.PointF tempAux2 = System.Drawing.PointF.Empty;
                    System.Drawing.PointF tempAux3 = transform.transform(new System.Drawing.PointF(gp.Rectangle.X, gp.Rectangle.Y), tempAux);
                    //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                    System.Drawing.PointF           tempAux4 = transform.transform(new System.Drawing.PointF(gp.Rectangle.Height, gp.Rectangle.Width), tempAux2);
                    System.Drawing.Drawing2D.Matrix gt       = objectBoundingBoxTransform(ref tempAux3, ref tempAux4, width, height, width, height);
                    fs        = new FillStyle();
                    fs.matrix = MatrixBuilder.build(gt);

                    fs.type = FillStyle.FILL_LINEAR_GRADIENT;

                    fs.gradient         = new Gradient();
                    fs.gradient.records = new GradRecord[2];
                    System.Drawing.Color tempAux5 = (gp.LinearColors)[0];
                    //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                    fs.gradient.records[0] = new GradRecord(0, SwfUtils.colorToInt(ref tempAux5));                     //from left
                    System.Drawing.Color tempAux6 = (gp.LinearColors)[1];
                    //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                    fs.gradient.records[1] = new GradRecord(255, SwfUtils.colorToInt(ref tempAux6));                     //to right
                }
                else if (paint is LinearGradientPaint)
                {
                    LinearGradientPaint   lgp   = (LinearGradientPaint)paint;
                    System.Drawing.PointF start = lgp.getStartPoint();
                    System.Drawing.PointF end   = lgp.getEndPoint();

                    //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                    System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref start, ref end, width, height, width, height);

                    fs        = new FillStyle();
                    fs.matrix = MatrixBuilder.build(gt);

                    System.Drawing.Color[] colors = lgp.getColors();
                    float[] ratios = lgp.getFractions();

                    if (colors.Length == 0 || colors.Length != ratios.Length)
                    //Invalid fill so we skip
                    {
                        return(null);
                    }
                    else if (colors.Length == 1)
                    //Solid fill
                    {
                        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                        return(new FillStyle(SwfUtils.colorToInt(ref colors[0])));
                    }
                    else
                    {
                        fs.type = FillStyle.FILL_LINEAR_GRADIENT;

                        //Maximum of 8 gradient control points records
                        int len = ratios.Length;
                        if (len > 8)
                        {
                            len = 8;
                        }
                        fs.gradient         = new Gradient();
                        fs.gradient.records = new GradRecord[len];

                        for (int i = 0; i < len; i++)
                        {
                            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                            fs.gradient.records[i] = new GradRecord((int)System.Math.Round((double)(255 * ratios[i])), SwfUtils.colorToInt(ref colors[i]));
                        }
                    }
                }
                else if (paint is RadialGradientPaint)
                {
                    RadialGradientPaint rgp = (RadialGradientPaint)paint;

                    //Note: Flash doesn't support the focal point of a radial gradient
                    //Point2D cp = rgp.getCenterPoint();
                    //Point2D fp = rgp.getFocusPoint();
                    double diameter = rgp.getRadius() * 2.0;
                    double outerX   = diameter * rgp.getTransform().getScaleX();
                    double outerY   = diameter * rgp.getTransform().getScaleY();

                    System.Drawing.PointF tempAux7 = System.Drawing.PointF.Empty;
                    System.Drawing.PointF tempAux8 = System.Drawing.PointF.Empty;
                    //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                    System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref tempAux7, ref tempAux8, width, height, outerX, outerY);
                    fs        = new FillStyle();
                    fs.matrix = MatrixBuilder.build(gt);

                    fs.type = FillStyle.FILL_RADIAL_GRADIENT;

                    System.Drawing.Color[] colors = rgp.getColors();
                    float[] ratios = rgp.getFractions();

                    fs.gradient         = new Gradient();
                    fs.gradient.records = new GradRecord[ratios.Length <= 8?ratios.Length:8];
                    for (int i = 0; i < ratios.Length && i < 8; i++)
                    {
                        //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'"
                        fs.gradient.records[i] = new GradRecord((int)System.Math.Round((double)(255 * ratios[i])), SwfUtils.colorToInt(ref colors[i]));
                    }
                }
                else if (paint is System.Drawing.TextureBrush)
                {
                    System.Drawing.TextureBrush tp    = (System.Drawing.TextureBrush)paint;
                    System.Drawing.Image        image = (System.Drawing.Image)tp.Image;

                    DefineBitsLossless tag = DefineBitsLosslessBuilder.build(new LosslessImage(image));

                    //Apply Twips Scale of 20 x 20
                    System.Drawing.Drawing2D.Matrix at = new System.Drawing.Drawing2D.Matrix();
                    at.Scale((System.Single)flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL, (System.Single)flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL);
                    Matrix matrix = MatrixBuilder.build(at);

                    fs = new FillStyle(FillStyle.FILL_BITS, matrix, tag);
                }
            }

            return(fs);
        }
        //UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
        private void  init(System.Drawing.Drawing2D.GraphicsPath shape, Point origin, FillStyle fs, LineStyle ls, bool fill)
        {
            builder    = new ShapeBuilder(origin);
            linestyles = new System.Collections.ArrayList(2);
            fillstyles = new System.Collections.ArrayList(2);

            if (fill && fs != null)
            {
                builder.UseFillStyle0     = true;
                builder.CurrentFillStyle0 = addFillStyle(fs);
            }

            if (ls != null)
            {
                builder.CurrentLineStyle = addLineStyle(ls);
            }

            //UPGRADE_TODO: Method 'java.awt.Shape.getPathIterator' was converted to 'System.Drawing.Drawing2D.GraphicsPathIterator.GraphicsPathIterator' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtShapegetPathIterator_javaawtgeomAffineTransform'"
            builder.processShape(new PathIteratorWrapper(new System.Drawing.Drawing2D.GraphicsPathIterator(shape)));
        }
 //UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
 public ShapeWithStyleBuilder(System.Drawing.Drawing2D.GraphicsPath shape, Point origin, FillStyle fs, LineStyle ls, bool fill)
 {
     init(shape, origin, fs, ls, fill);
 }
 /// <summary> Adds a new fill style to the <code>FillStyleArray</code>. If the given <code>FillStyle</code>
 /// is <code>null</code>, the style is ignored and an index of 0 is returned.
 /// </summary>
 /// <param name="fs">the new <code>FillStyle</code>
 /// </param>
 /// <returns> index pointing to this fill style in the <code>FillStyleArray</code>
 /// </returns>
 public int addFillStyle(FillStyle fs)
 {
     //UPGRADE_TODO: The equivalent in .NET for method 'java.util.List.add' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
     return(fillstyles.Add(fs) >= 0?((System.Collections.ArrayList)fillstyles).LastIndexOf(fs) + 1:0);             //Index in a 1-based array, 0 = none
 }
 //UPGRADE_TODO: Interface 'java.awt.Shape' was converted to 'System.Drawing.Drawing2D.GraphicsPath' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
 public DefineShapeBuilder(System.Drawing.Drawing2D.GraphicsPath shape, Point origin, FillStyle fs, LineStyle ls, bool fill) : this()
 {
     sws = new ShapeWithStyleBuilder(shape, origin, fs, ls, fill);
 }