positioner.cs
来自「Csharp设计模式图书加源代码是csharp程序员学习模式编程的一本好书」· CS 代码 · 共 47 行
CS
47 行
using System;
namespace Flyweight
{
/// <summary>
/// Summary description for Positioner.
/// </summary>
public class Positioner {
private const int pLeft = 30;
private const int pTop = 30;
private const int HSpace = 70;
private const int VSpace = 80;
private const int rowMax = 2;
private int x, y, cnt;
//-----
public Positioner() {
reset();
}
//-----
public void reset() {
x = pLeft;
y = pTop;
cnt = 0;
}
//-----
public int nextX() {
return x;
}
//-----
public void incr() {
cnt++;
if (cnt > rowMax) { //reset to start new row
cnt = 0;
x = pLeft;
y += VSpace;
}
else {
x += HSpace;
}
}
//-----
public int nextY() {
return y;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?