public static BoundingRectangle GetBoundsFromPath(List<PathInfo> list) { // Only support simple paths if (list.First().segmentType != SegmentType.Move) { return null; } if (list.Last().segmentType != SegmentType.Close) { return null; } if (list.Skip(1).Take(list.Count - 2).Any(p => p.segmentType != SegmentType.Line)) { return null; } BoundingRectangle ret = new BoundingRectangle(); foreach (var i in list.Take(list.Count - 1)) { ret.UpdateBounds(i.point); } return ret; }