public void DeserializeProperties(string propertiesString) { string[] tokens = propertiesString.Split(':'); IShapeCurve curve = null; ShapePoint startPt = new ShapePoint(); ShapePoint endPt = startPt; for (int i = 1; i < tokens.Length - 1; i++) { string[] strpt = tokens[i].Split(','); endPt.Set(float.Parse(strpt[0], CultureInfo.InvariantCulture), float.Parse(strpt[1], CultureInfo.InvariantCulture)); if (bool.Parse(strpt[2])) { // Bezier curve curve = new ShapeBezier(); curve.ControlPoints[0] = endPt; //bool b = CultureInfo.CurrentCulture.UseUserOverride; NumberFormatInfo nfi = CultureInfo.CurrentCulture.NumberFormat; curve.ControlPoints[1] = new ShapePoint(float.Parse(strpt[3], CultureInfo.InvariantCulture), float.Parse(strpt[4], CultureInfo.InvariantCulture)); curve.ControlPoints[2] = new ShapePoint(float.Parse(strpt[5], CultureInfo.InvariantCulture), float.Parse(strpt[6], CultureInfo.InvariantCulture)); endPt = new ShapePoint(); curve.ControlPoints[3] = endPt; } else { // Straight Line curve = new ShapeLine(); curve.ControlPoints[0] = endPt; endPt = new ShapePoint(); curve.ControlPoints[1] = endPt; } this.Add(curve); } // Attach the end of the last line to the first point to close the shape if (curve != null) { curve.LastPoint = startPt; } }
public void DeserializeProperties(string propertiesString) { string[] strArray1 = propertiesString.Split(':'); IShapeCurve el = (IShapeCurve)null; ShapePoint shapePoint1 = new ShapePoint(); ShapePoint shapePoint2 = shapePoint1; for (int index = 1; index < strArray1.Length - 1; ++index) { string[] strArray2 = strArray1[index].Split(','); shapePoint2.Set(float.Parse(strArray2[0], (IFormatProvider)CultureInfo.InvariantCulture), float.Parse(strArray2[1], (IFormatProvider)CultureInfo.InvariantCulture)); if (bool.Parse(strArray2[2])) { el = (IShapeCurve) new ShapeBezier(); el.ControlPoints[0] = shapePoint2; NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat; el.ControlPoints[1] = new ShapePoint(float.Parse(strArray2[3], (IFormatProvider)CultureInfo.InvariantCulture), float.Parse(strArray2[4], (IFormatProvider)CultureInfo.InvariantCulture)); el.ControlPoints[2] = new ShapePoint(float.Parse(strArray2[5], (IFormatProvider)CultureInfo.InvariantCulture), float.Parse(strArray2[6], (IFormatProvider)CultureInfo.InvariantCulture)); shapePoint2 = new ShapePoint(); el.ControlPoints[3] = shapePoint2; } else { el = (IShapeCurve) new ShapeLine(); el.ControlPoints[0] = shapePoint2; shapePoint2 = new ShapePoint(); el.ControlPoints[1] = shapePoint2; } this.Add(el); } if (el == null) { return; } el.LastPoint = shapePoint1; }