Пример #1
0
        /// <summary>
        /// Draws the <see cref="Catalog"/> tile with the specified index to the <see
        /// cref="TileCopyBuffer"/>.</summary>
        /// <param name="index">
        /// The tile index in the <see cref="Catalog"/> bitmap whose contents to draw.</param>
        /// <exception cref="ObjectDisposedException">
        /// The <see cref="CatalogManager"/> object has been disposed of.</exception>
        /// <remarks>
        /// <b>DrawTile</b> draws the <see cref="Catalog"/> tile at the specified <paramref
        /// name="index"/> to the <see cref="TileCopyBuffer"/>. Any existing buffer contents are
        /// overwritten.</remarks>

        public void DrawTileToBuffer(int index)
        {
            if (IsDisposed)
            {
                ThrowHelper.ThrowObjectDisposedException(null);
            }

            // compute source rectangle
            RectI source = GetTileBounds(index);

            // copy catalog tile to buffer
            TileCopyBuffer.Lock();
            TileCopyBuffer.Read(0, 0, Catalog, source);
            TileCopyBuffer.Unlock();
        }
Пример #2
0
        /// <summary>
        /// Draws the <see cref="Catalog"/> tile with the specified index.</summary>
        /// <param name="context">
        /// The <see cref="DrawingContext"/> for the drawing.</param>
        /// <param name="index">
        /// The tile index in the <see cref="Catalog"/> bitmap whose contents to draw.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="context"/> is a null reference.</exception>
        /// <exception cref="ObjectDisposedException">
        /// The <see cref="CatalogManager"/> object has been disposed of.</exception>
        /// <remarks><para>
        /// <b>DrawTile</b> draws the <see cref="Catalog"/> tile at the specified <paramref
        /// name="index"/> to pixel location (1,1) within the specified <paramref name="context"/>.
        /// </para><para>
        /// The tile is clipped by and surrounded with the <see cref="RegularPolygon"/> outline of
        /// an <see cref="PolygonGrid.Element"/> in the current <see cref="MapGrid"/>.
        /// </para></remarks>

        public void DrawTile(DrawingContext context, int index)
        {
            if (IsDisposed)
            {
                ThrowHelper.ThrowObjectDisposedException(null);
            }
            if (context == null)
            {
                ThrowHelper.ThrowArgumentNullException("context");
            }

            // compute source & target rectangles
            RectI source = GetTileBounds(index);
            Rect  target = new Rect(1, 1, source.Width, source.Height);

            // copy catalog tile to buffer
            TileCopyBuffer.Lock();
            TileCopyBuffer.Read(0, 0, Catalog, source);
            TileCopyBuffer.Unlock();

            // get scaled polygonal outline, centered on tile
            PointD offset   = new PointD((source.Width + 2) / 2.0, (source.Height + 2) / 2.0);
            var    geometry = new PathGeometry()
            {
                Figures = { MapGrid.Element.ToFigure(offset) }
            };

            geometry.Freeze();

            // draw catalog tile, clipped to polygonal region
            context.PushClip(geometry);
            context.DrawImage(TileCopyBuffer, target);
            context.Pop();

            // draw black polygon outline
            context.DrawGeometry(null, new Pen(Brushes.Black, 1.0), geometry);
        }