internal static void CalcGeometryAndBoundsWithTransform(StrokeNodeIterator iterator, DrawingAttributes drawingAttributes, MatrixTypes stylusTipMatrixType, bool calculateBounds, out Geometry geometry, out Rect bounds) { StreamGeometry streamGeometry = new StreamGeometry(); streamGeometry.FillRule = FillRule.Nonzero; StreamGeometryContext streamGeometryContext = streamGeometry.Open(); geometry = streamGeometry; bounds = Rect.Empty; try { List <Point> list = new List <Point>(iterator.Count * 4); int num = iterator.Count * 2; int num2 = 0; for (int i = 0; i < num; i++) { list.Add(new Point(0.0, 0.0)); } List <Point> list2 = new List <Point>(); double lastAngle = 0.0; bool flag = false; Rect rect = new Rect(0.0, 0.0, 0.0, 0.0); for (int j = 0; j < iterator.Count; j++) { StrokeNode strokeNode = iterator[j]; Rect bounds2 = strokeNode.GetBounds(); if (calculateBounds) { bounds.Union(bounds2); } double num3 = Math.Abs(GetAngleDeltaFromLast(strokeNode.PreviousPosition, strokeNode.Position, ref lastAngle)); double num4 = 45.0; if (stylusTipMatrixType == MatrixTypes.TRANSFORM_IS_UNKNOWN) { num4 = 10.0; } else if (bounds2.Height > 40.0 || bounds2.Width > 40.0) { num4 = 20.0; } bool flag2 = num3 > num4 && num3 < 360.0 - num4; double val = rect.Height * rect.Width; double val2 = bounds2.Height * bounds2.Width; bool flag3 = false; if (Math.Min(val, val2) / Math.Max(val, val2) <= 0.7) { flag3 = true; } rect = bounds2; if ((j <= 1 || j >= iterator.Count - 2) | flag2 | flag3) { if (flag2 && !flag && j > 1 && j < iterator.Count - 1) { list2.Clear(); strokeNode.GetPreviousContourPoints(list2); AddFigureToStreamGeometryContext(streamGeometryContext, list2, strokeNode.IsEllipse); flag = true; } list2.Clear(); strokeNode.GetContourPoints(list2); AddFigureToStreamGeometryContext(streamGeometryContext, list2, strokeNode.IsEllipse); } if (!flag2) { flag = false; } Quad connectingQuad = strokeNode.GetConnectingQuad(); if (!connectingQuad.IsEmpty) { list[num2++] = connectingQuad.A; list[num2++] = connectingQuad.B; list.Add(connectingQuad.D); list.Add(connectingQuad.C); } if (strokeNode.IsLastNode && num2 > 0) { int num5 = iterator.Count * 2; int num6 = list.Count - 1; int num7 = num2; for (int k = num5; k <= num6; k++) { list[num7] = list[k]; num7++; } int num8 = num5 - num2; list.RemoveRange(num6 - num8 + 1, num8); int num9 = num2; int num10 = list.Count - 1; while (num9 < num10) { Point value = list[num9]; list[num9] = list[num10]; list[num10] = value; num9++; num10--; } AddFigureToStreamGeometryContext(streamGeometryContext, list, isBezierFigure: false); } } } finally { streamGeometryContext.Close(); geometry.Freeze(); } }