⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statemanager.cs

📁 c#设计模式随书源码 c#设计模式随书源码
💻 CS
字号:
using System;

namespace State
{
	/// <summary>
	/// Summary description for StateManager.
	/// </summary>
	public class StateManager 	{
		private State currentState;
		private RectState rState;
		private ArrowState aState;
		private CircleState cState;
		private FillState fState;

		public StateManager(Mediator med) 		{
			//create an instance of each state
			rState = new RectState(med);
			cState = new CircleState(med);
			aState = new ArrowState(med);
			fState = new FillState(med);
			//and initialize them
			//set default state
			currentState = aState;
		}
		//-----
		//These methods are called when the toolbuttons are clicked
		public void setRect() {
			currentState = rState;
		}
		//-----
		public void setCircle() {
			currentState = cState;
		}
		public void setFill() {
			currentState = fState;
		}
		public void setArrow() {
			currentState = aState;
		}
		public void mouseDown(int x, int y) {
			currentState.mouseDown (x, y);
		}
		public void mouseUp(int x, int y) {
			currentState.mouseUp (x, y);
		}
		public void mouseDrag(int x, int y) {
			currentState.mouseDrag (x, y);
		}
		public void selectOne(Drawing d) {
			currentState.selectOne (d);
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -