/// <summary> /// Gets the coordinate and flag sequence arrays to be set as property values. /// </summary> /// <param name="points">The points to be transformed.</param> /// <param name="Coordinates">The coordinate sequence array.</param> /// <param name="Flags">The flag sequence array.</param> /// <param name="filterControlPoints">if set to <c>true</c> control points will be ignored during translation.</param> /// <returns> /// <c>true</c> if successfully transformed; otherwise, <c>false</c>. /// </returns> internal static bool TransformToCoordinateAndFlagSequence(List<PolyPointDescriptor> points, out Point[] Coordinates, out unodrawing.PolygonFlags[] Flags, bool filterControlPoints = false) { bool success = false; Coordinates = null; Flags = null; if (points != null) { Coordinates = new Point[points.Count]; Flags = new unodrawing.PolygonFlags[points.Count]; if (points.Count > 0) { try { int i = 0; foreach (var item in points) { if (!filterControlPoints || item.Flag == PolygonFlags.NORMAL) { // System.Linq.Enumerable.ElementAt(points, i); Coordinates[i] = new Point(item.X, item.Y); Flags[i] = (unodrawing.PolygonFlags)item.Flag; i++; } } if (i < points.Count) { Coordinates = Coordinates.Take(i).ToArray(); Flags = Flags.Take(i).ToArray(); //TODO: check if this works } } catch { return false; } } success = true; } return success; }
/// <summary> /// Builds the poly polygon bezier coords property value. /// </summary> /// <param name="points">The points.</param> /// <returns>a PolyPolygonBezierCoords, which multidimensional arrays are filled with the given coordinates and flags</returns> internal static PolyPolygonBezierCoords BuildPolyPolygonBezierCoords(List<List<PolyPointDescriptor>> points) { PolyPolygonBezierCoords property = new PolyPolygonBezierCoords(); if (points != null && points.Count > 0) { Point[][] AllCoordinates = new Point[points.Count][]; unodrawing.PolygonFlags[][] AllFlags = new unodrawing.PolygonFlags[points.Count][]; int i = 0; foreach (var item in points) { Point[] Coordinates; unodrawing.PolygonFlags[] Flags; bool success = TransformToCoordinateAndFlagSequence(item, out Coordinates, out Flags); if (success) { AllCoordinates[i] = Coordinates; AllFlags[i] = Flags; i++; } } property.Coordinates = AllCoordinates; property.Flags = AllFlags; } return property; }