コード例 #1
0
        /// <summary>
        /// Sets the content to all lines in the given polygon.
        /// </summary>
        /// <param name="polygon">The polygon.</param>
        public unsafe void SetContent(Polygon2D polygon)
        {
            this.EnsureNotNullOrDisposed("this");
            polygon.EnsureNotNull(nameof(polygon));
            polygon.Vertices.EnsureMoreThanZeroElements($"{nameof(polygon)}.{nameof(polygon.Vertices)}");

            using (var geoSink = _d2dGeometry !.Open())
            {
                var vertices = polygon.Vertices;

                // Start the figure
                var startPoint = vertices[0];
                geoSink.BeginFigure(
                    *(PointF *)&startPoint,
                    D2D.FigureBegin.Filled);

                // AddObject all lines
                var vertexCount = vertices.Count;

                for (var loop = 1; loop < vertexCount; loop++)
                {
                    var actVectorOrig = vertices[loop];
                    geoSink.AddLine(*(PointF *)&actVectorOrig);
                }

                // End the figure
                geoSink.EndFigure(D2D.FigureEnd.Closed);
                geoSink.Close();
            }
        }
コード例 #2
0
        /// <summary>
        /// Sets the content to all lines in the given polygon.
        /// </summary>
        /// <param name="polygon">The polygon.</param>
        public unsafe void SetContent(Polygon2D polygon)
        {
            polygon.EnsureNotNull(nameof(polygon));
            polygon.Vertices.EnsureMoreThanZeroElements($"{nameof(polygon)}.{nameof(polygon.Vertices)}");

            using (D2D.GeometrySink geoSink = m_d2dGeometry.Open())
            {
                ReadOnlyCollection <Vector2> vertices = polygon.Vertices;

                // Start the figure
                Vector2 startPoint = vertices[0];
                geoSink.BeginFigure(
                    *(SDXM.RawVector2 *) & startPoint,
                    D2D.FigureBegin.Filled);

                // Add all lines
                int vertexCount = vertices.Count;
                for (int loop = 1; loop < vertexCount; loop++)
                {
                    Vector2 actVectorOrig = vertices[loop];
                    geoSink.AddLine(*(SDXM.RawVector2 *) & actVectorOrig);
                }

                // End the figure
                geoSink.EndFigure(D2D.FigureEnd.Closed);
                geoSink.Close();
            }
        }