System.Drawing.Graphics.DrawRectangles C# (CSharp) Method

DrawRectangles() public method

public DrawRectangles ( Pen pen, Rectangle rects ) : void
pen Pen
rects Rectangle
return void
        public void DrawRectangles(Pen pen, Rectangle [] rects)
        {
            if (pen == null)
                throw new ArgumentNullException ("image");
            if (rects == null)
                throw new ArgumentNullException ("rects");

            foreach (var rect in rects)
                RectanglePath (rect.X, rect.Y, rect.Right, rect.Bottom);
            StrokePen (pen);
        }

Same methods

Graphics::DrawRectangles ( Pen pen, RectangleF rects ) : void

Usage Example

        /// <summary>
        /// On draw on backbuffer
        /// </summary>
        protected override void OnDrawOnBackbuffer(ref System.Drawing.Graphics gfx)
        {
            // If layer is empty or background is empty, return
            if (_layer == null || App.Room.Backgrounds[0] == null || App.Room.Backgrounds[0].Image == null)
            {
                return;
            }

            // Draw layer
            gfx.DrawImageUnscaled(_layer.GetLayerImage(App.Room.Backgrounds[0], App.Room.Backgrounds[0].GetCondensedTileset(), .5f), Point.Empty);

            // Convert tile ids to optimized binary tiles and reset the tile count
            ExportTile[] tiles = _layer.GetExportTiles(App.Room.Backgrounds[0], false, -1);
            _tileCount = 0;

            // If there are rectangles to draw, draw them
            if (tiles != null || tiles.Length > 0)
            {
                // Create a list of rectangles
                List <Rectangle> rects = new List <Rectangle>();

                // Iterate through tiles
                foreach (ExportTile tile in tiles)
                {
                    rects.Add(tile.Rect);
                }

                // Draw rectangles and set tile count
                gfx.DrawRectangles(Pens.Red, rects.ToArray());
                _tileCount = rects.Count;
            }
        }
All Usage Examples Of System.Drawing.Graphics::DrawRectangles