drawmemento.cs

来自「c#设计模式随书源码 c#设计模式随书源码」· CS 代码 · 共 32 行

CS
32
字号
using System;
using CsharpPats;
namespace State
{
	/// <summary>
	/// save the state of a visual rectangle
	/// </summary>
	public class DrawMemento : Memento 	{
		private int x, y, w, h;
		private Rectangle  rect;
		private Drawing visDraw;
		//------
		public DrawMemento(Drawing d) 	{
			 visDraw = d;
			rect = visDraw.getRects ();
			x = rect.x;
			y = rect.y ;  
			w = rect.w;
			h = rect.h;
		}
		//-----
		public void restore() {
			 //restore the state of a drawing object
			rect.x = x;
			rect.y = y;
			rect.h = h;
			rect.w = w;
			visDraw.setRects( rect);
		}
	}
}

⌨️ 快捷键说明

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