/// <summary> /// 根据当前的路径生成几何组。 /// </summary> /// <param name="factory">Direct2D 工厂。</param> /// <returns>生成的几何组。</returns> public GeometryGroup GetGeometryGroup(Factory factory) { Geometry[] geometries = new Geometry[this.figureCount]; PathGeometry path = new PathGeometry(factory); GeometrySink sink = path.Open(); sink.SetFillMode(FillMode.Winding); sink.BeginFigure(this.StartPoint, FigureBegin.Filled); int cnt = this.Count; int idx = 0; for (int i = 0; i < cnt; i++) { EndFigureSegment end = this[i] as EndFigureSegment; if (end == null) { this[i].FillGeometry(sink); } else { sink.EndFigure(FigureEnd.Closed); sink.Close(); geometries[idx++] = path; path = new PathGeometry(factory); sink = path.Open(); sink.SetFillMode(FillMode.Winding); sink.BeginFigure(end.EndPoint, FigureBegin.Filled); } } sink.EndFigure(FigureEnd.Closed); sink.Close(); geometries[idx++] = path; return(new GeometryGroup(factory, FillMode.Winding, geometries)); }
/// <summary> /// 返回当前路径中包含的形状的颜色(黑/白)。 /// </summary> /// <returns>表示颜色的数组。</returns> public bool[] GetColors() { bool[] colors = new bool[figureCount]; colors[0] = this.IsBlack; int cnt = this.Count; for (int i = 0, idx = 1; i < cnt; i++) { EndFigureSegment end = this[i] as EndFigureSegment; if (end != null) { colors[idx++] = end.IsBlack; } } return(colors); }