//UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" private TextRecord getStyleRecord(FontBuilder fontBuilder, double height, ref System.Drawing.Color color, int xOffset, int yOffset) { TextRecord tr = new TextRecord(); if (fontBuilder != null) { tr.Font = fontBuilder.tag; tr.Height = SwfUtils.toTwips(height); } if (!color.IsEmpty) { //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" int c = SwfUtils.colorToInt(ref color); tr.Color = c; } if (xOffset > 0) { tr.X = xOffset; } if (yOffset > 0) { tr.Y = yOffset; } return(tr); }
public static LineStyle build(System.Drawing.Brush paint, System.Drawing.Pen thickness) { LineStyle ls = new LineStyle(); if (paint != null && 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'" ls.color = SwfUtils.colorToInt(ref new System.Drawing.Color[] { (System.Drawing.Color)paint }[0]); } if (thickness != null && thickness is System.Drawing.Pen) { //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'" ls.width = (int)(System.Math.Round((double)(((System.Drawing.Pen)thickness).Width * flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL))); } return(ls); }
/// <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); }