/// <summary> /// Initializes a new instance of TeapotMesh. /// </summary> public TeapotMesh() { // One-time transfer of points in verticesTeapot array. Point3DCollection vertices = Geometry.Positions; for (int i = 0; i < verticesTeapot.Length; i += 3) vertices.Add(new Point3D(verticesTeapot[i + 0], verticesTeapot[i + 1], verticesTeapot[i + 2])); // One-time transfer vectors in normalsTeapot array. Vector3DCollection normals = Geometry.Normals; for (int i = 0; i < normalsTeapot.Length; i += 3) normals.Add(new Vector3D(normalsTeapot[i + 0], normalsTeapot[i + 1], normalsTeapot[i + 2])); // Initialize TriangleRange and invoke PropertyChanged. TriangleRange = new TeapotTriangleRange(); }
/// <summary> /// Converts the specified object to a TeapotTriangleRange. /// </summary> /// <param name="context"> /// Describes the context information of a type. /// </param> /// <param name="culture"> /// Describes the CultureInfo of the type being converted. /// </param> /// <param name="value"> /// The object being converted. /// </param> /// <returns> /// The TeapotTriangleRange created from converting value. /// </returns> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value.GetType() != typeof(string)) { return(base.ConvertFrom(context, culture, value)); } string str = (value as string).Trim(); PropertyInfo[] props = typeof(TeapotTriangleRange).GetProperties(BindingFlags.Public | BindingFlags.Static); foreach (PropertyInfo prop in props) { if (prop.PropertyType == typeof(TeapotTriangleRange) && 0 == String.Compare(str, prop.Name, true)) { return(prop.GetValue(null, null)); } } return(TeapotTriangleRange.Parse(value as string)); }