当前位置: 首页>>代码示例>>C#>>正文


C# System.Drawing.Rectangle.IntersectsWith方法代码示例

本文整理汇总了C#中System.Drawing.Rectangle.IntersectsWith方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Rectangle.IntersectsWith方法的具体用法?C# System.Drawing.Rectangle.IntersectsWith怎么用?C# System.Drawing.Rectangle.IntersectsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Rectangle的用法示例。


在下文中一共展示了System.Drawing.Rectangle.IntersectsWith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawTile

 public void DrawTile(int x, int y)
 {
     System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
         x * size.Width - ScrollOffsetX,
         y * size.Height - ScrollOffsetY,
         size.Width,
         size.Height
     );
     if (rect.IntersectsWith(this.panel.ClientRectangle))
         this.panel.Invalidate(rect);
 }
开发者ID:NekoProject,项目名称:NekoKun,代码行数:11,代码来源:MapPanelBase.cs

示例2: if

        public override System.Drawing.Image this[int id]
        {
            get
            {
                if (this.tiles.ContainsKey(id))
                    return this.tiles[id];
                else
                {
                    System.Drawing.Bitmap tile = new System.Drawing.Bitmap(this.TileSize.Width, this.TileSize.Height);
                    System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(tile);
                    if (id >= 384 && this.images.Count > 1 && this.images[0] != null)
                    {
                            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
                                new System.Drawing.Point(
                                    (id - 384) % 8 * this.TileSize.Width,
                                    (id - 384) / 8 * this.TileSize.Height
                                ),
                                this.TileSize
                            );
                            if (rect.IntersectsWith(this.imagesBounds[0].Value))
                                g.DrawImage(this.images[0], 0, 0, rect, System.Drawing.GraphicsUnit.Pixel);
                    }
                    else if (id >= 48 && id < 384)
                    {
                        int tileid = id / 48 - 1;
                        if (this.images[tileid + 1] != null)
                        {
                            int subid = id % 48;
                            byte[] info = autotilesInfo[subid / 8][subid % 8];
                            for (int i = 0; i < 4; i++)
                            {
                                int pos = info[i] - 1;
                                System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
                                    pos % 6 * (this.TileSize.Width / 2),
                                    pos / 6 * (this.TileSize.Height / 2),
                                    this.TileSize.Width / 2,
                                    this.TileSize.Height / 2
                                );
                                if (rect.IntersectsWith(this.imagesBounds[tileid + 1].Value))
                                {
                                    System.Drawing.Rectangle rect2 = new System.Drawing.Rectangle(
                                        i % 2 * (this.TileSize.Width / 2),
                                        i / 2 * (this.TileSize.Height / 2),
                                        this.TileSize.Width / 2,
                                        this.TileSize.Height / 2
                                    );
                                    g.DrawImage(
                                        this.images[tileid + 1],
                                        rect2,
                                        rect,
                                        System.Drawing.GraphicsUnit.Pixel
                                    );
                                }
                            }
                        }
                    }

                    g.Dispose();
                    this.tiles.Add(id, tile);
                    return tile;
                }
            }
        }
开发者ID:NekoProject,项目名称:NekoKun,代码行数:63,代码来源:TilesetInfoXP.cs


注:本文中的System.Drawing.Rectangle.IntersectsWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。