Exemplo n.º 1
0
        public void EndCollect()
        {
            if (this.PathGenerated != null && _psCollection.Count > 0)
            {
                PathGeometry pg = new PathGeometry();
                pg.FillRule = FillRule.Nonzero;

                PathFigureCollection figs = new PathFigureCollection();
                pg.Figures = figs;

                //닫힌 Path를 형성함
                PathSegmentCollection pscol2 = _psCollection.Clone();
                PathSegment           last   = pscol2.Last();
                pscol2.Insert(0, last);

                PathFigure fig = new PathFigure();
                fig.Segments = pscol2;
                fig.IsClosed = true;
                figs.Add(fig);

                this.PathGenerated(pg);
            }
        }
Exemplo n.º 2
0
        private static PathSegmentCollection SortPathSegmentCollection(PathSegmentCollection segments)
        {
            var n = segments.Count - 2;
            Debug.Assert(n % 2 == 0);
            var m = n / 2;

            // TODO: use better variables for v1, v2 and v3
            var v1 = Enumerable.Range(0, m).ToList();
            var v2 = v1.Select(x => x * 2 + 1);
            var v3 = v1.Select(x => x * 2 + 2);

            var sortedSegments = new List<PathSegment> { segments.First() };
            sortedSegments.AddRange(v2.Select(x => segments[x]));
            sortedSegments.Add(segments.Last());
            sortedSegments.AddRange(v3.Select(x => segments[x]).Reverse());

            return new PathSegmentCollection(sortedSegments);
        }