?? rectanglearray.cs
字號:
using System;
using System.Drawing;
using System.Collections.Specialized;
namespace DDGameHelper
{
/// <summary>
/// RectangleArray 的摘要說明。
/// </summary>
public class RectangleArray
{
protected Rectangle[] _rectangles;
public Rectangle[] Rectangles{get{return _rectangles;}set{_rectangles=value;}}
public RectangleArray()
{
_rectangles = new Rectangle[0];
}
public RectangleArray(int totalWidth, int totalHeight, int cellWidth, int cellHeight, int count)
{
_rectangles = RectArrayMaker(totalWidth, totalHeight, cellWidth, cellHeight, count);
}
/// <summary>
/// Rect數(shù)組 創(chuàng)建器(根據(jù) Rect 及 bitmap 的大小自動創(chuàng)建 count 個 Rect)
/// </summary>
public static Rectangle[] RectArrayMaker(int totalWidth, int totalHeight, int cellWidth, int cellHeight, int count)
{
int w = totalWidth / cellWidth;
int h = totalHeight / cellHeight;
Rectangle[] rc = new Rectangle[0];
if(count>0)
{
rc = new Rectangle[count];
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
int c = i * h + j;
if (c >= count)return rc;
System.Drawing.Point p = new System.Drawing.Point(j * cellWidth, i * cellHeight);
rc[c] = new System.Drawing.Rectangle(p, new Size(cellWidth, cellHeight));
}
}
}
else
{
rc = new Rectangle[w * h];
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
System.Drawing.Point p = new System.Drawing.Point(j * cellWidth, i * cellHeight);
rc[i * w + j] = new System.Drawing.Rectangle(p, new Size(cellWidth, cellHeight));
}
}
}
return rc;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -