positioner.cs

来自「VC#里面的东西,大家可以看看」· 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 + -
显示快捷键?