private int ReadRectangle(XmlNode rectNode) { float result = 0f; float result2 = 0f; float result3 = 0f; float result4 = 0f; float result5 = -1f; float result6 = -1f; string attributeContent = GetAttributeContent(rectNode, "x"); if (attributeContent == "ERROR") { return(0); } float.TryParse(attributeContent, out result); attributeContent = GetAttributeContent(rectNode, "y"); if (attributeContent == "ERROR") { return(0); } float.TryParse(attributeContent, out result2); attributeContent = GetAttributeContent(rectNode, "width"); if (attributeContent == "ERROR") { return(0); } float.TryParse(attributeContent, out result3); attributeContent = GetAttributeContent(rectNode, "height"); if (attributeContent == "ERROR") { return(0); } float.TryParse(attributeContent, out result4); attributeContent = GetAttributeContent(rectNode, "rx"); if (attributeContent != "ERROR") { float.TryParse(attributeContent, out result5); } attributeContent = GetAttributeContent(rectNode, "ry"); if (attributeContent != "ERROR") { float.TryParse(attributeContent, out result6); } else { result6 = result5; } string text = GetAttributeContent(rectNode, "id"); if (result5 == -1f && result6 == -1f) { Rectangle rectangle = new Rectangle(); rectangle.offset = new Vector2(result + result3 / 2f, 0f - result2 - result4 / 2f); rectangle.axis = SplinePrimitive.Axis.nZ; rectangle.size = new Vector2(result3, result4); if (text == "ERROR") { text = fileName + "_rectangle" + (rectangles.Count + 1); } buffer = new SplineDefinition(text, rectangle.GetSpline()); } else { RoundedRectangle roundedRectangle = new RoundedRectangle(); roundedRectangle.offset = new Vector2(result + result3 / 2f, 0f - result2 - result4 / 2f); roundedRectangle.axis = SplinePrimitive.Axis.nZ; roundedRectangle.size = new Vector2(result3, result4); roundedRectangle.xRadius = result5; roundedRectangle.yRadius = result6; if (text == "ERROR") { text = fileName + "_roundedRectangle" + (rectangles.Count + 1); } buffer = new SplineDefinition(text, roundedRectangle.GetSpline()); } int result7 = ParseTransformation(rectNode); WriteBufferTo(rectangles); return(result7); }
int ReadRectangle(XmlNode rectNode) { float x = 0f, y = 0f, w = 0f, h = 0f, rx = -1f, ry = -1f; string attribute = GetAttributeContent(rectNode, "x"); if (attribute == "ERROR") { return(0); } float.TryParse(attribute, out x); attribute = GetAttributeContent(rectNode, "y"); if (attribute == "ERROR") { return(0); } float.TryParse(attribute, out y); attribute = GetAttributeContent(rectNode, "width"); if (attribute == "ERROR") { return(0); } float.TryParse(attribute, out w); attribute = GetAttributeContent(rectNode, "height"); if (attribute == "ERROR") { return(0); } float.TryParse(attribute, out h); attribute = GetAttributeContent(rectNode, "rx"); if (attribute != "ERROR") { float.TryParse(attribute, out rx); } attribute = GetAttributeContent(rectNode, "ry"); if (attribute != "ERROR") { float.TryParse(attribute, out ry); } else { ry = rx; } string elementName = GetAttributeContent(rectNode, "id"); if (rx == -1f && ry == -1f) { Rectangle rect = new Rectangle(); rect.offset = new Vector2(x + w / 2f, -y - h / 2f); rect.axis = SplinePrimitive.Axis.nZ; rect.size = new Vector2(w, h); if (elementName == "ERROR") { elementName = fileName + "_rectangle" + (rectangles.Count + 1); } buffer = new SplineDefinition(elementName, rect.GetSpline()); } else { RoundedRectangle rect = new RoundedRectangle(); rect.offset = new Vector2(x + w / 2f, -y - h / 2f); rect.axis = SplinePrimitive.Axis.nZ; rect.size = new Vector2(w, h); rect.xRadius = rx; rect.yRadius = ry; if (elementName == "ERROR") { elementName = fileName + "_roundedRectangle" + (rectangles.Count + 1); } buffer = new SplineDefinition(elementName, rect.GetSpline()); } int addedTransforms = ParseTransformation(rectNode); WriteBufferTo(rectangles); return(addedTransforms); }