易截截图软件、单文件、免安装、纯绿色、仅160KB

Delphi 设计模式:《HeadFirst设计模式》Delphi7代码

命令模式可以很轻松的实现撤销(Undo)功能。
1. 命令的接受者
unit uReceiveObject;

interface

type
TLight = class(TObject)
public
procedure Open;
procedure Off;
end;

implementation

{ TLight }

procedure TLight.Off;
begin
Writeln('Light is off.');
end;

procedure TLight.Open;
begin
Writeln('Light is on.');
end;

end.


2.命令对象
unit uReceiveObject;

interface

type
TLight = class(TObject)
public
procedure Open;
procedure Off;
end;

implementation

{ TLight }

procedure TLight.Off;
begin
Writeln('Light is off.');
end;

procedure TLight.Open;
begin
Writeln('Light is on.');
end;

end.


 
3.命令的请求者
unit uSimpleRemoteWithUndo;

interface

uses
uCommandObject;

type
TSimpleRemoteWithUndo = class(TObject)
private
FOnCommand : TCommand;
FOffCommand : TCommand;
FUndoCommand: TCommand;
public
procedure SetCommand(aOnCommand, aOffCommand: TCommand);
procedure OnButtonWasPressed;
procedure OffButtonWasPressed;
procedure UndoButtonWasPressed;
end;

implementation

{ TSimpleRemoteWithUndo }

procedure TSimpleRemoteWithUndo.OffButtonWasPressed;
begin
FOffCommand.Execute;
FUndoCommand := FOffCommand;
end;

procedure TSimpleRemoteWithUndo.OnButtonWasPressed;
begin
FOnCommand.Execute;
FUndoCommand := FOnCommand;
end;

procedure TSimpleRemoteWithUndo.SetCommand(aOnCommand, aOffCommand: TCommand);
begin
FOnCommand := aOnCommand;
FOffCommand := aOffCommand;
end;

procedure TSimpleRemoteWithUndo.UndoButtonWasPressed;
begin
FUndoCommand.Undo;
end;

end.


 
4.客户端,创建具体的命令
program pSimpleRemoteWithUndoTest;

{$APPTYPE CONSOLE}

uses
uSimpleRemoteWithUndo in 'uSimpleRemoteWithUndo.pas',
uCommandObject in 'uCommandObject.pas',
uReceiveObje


相关文档:

Delphi图像处理

    本文的线性亮度/对比度调整方法是在《改进的图像线性亮度调整方法》一文中线性亮度调整方法与《Delphi图像处理 -- Photoshop图像亮度/对比度调整》中的对比度调整方法基础上形成的,其原理和特点可参见这2篇文章:
    过程定义:
// 线性调整亮度,Value亮度值
procedure ImageL ......

Delphi 2010正式版下载(RAD Studio 2010下载)

Delphi 2010正式版下载(RAD Studio 2010下载)
在8月26日正式发布了RAD Studio 2010,就是我们所谓的Delphi 2010。RAD Studio 2010包含Delphi、C++ Builder和Delphi Prism等。 RAD Studio 2010 的新功能主要在于:增强的 IDE和可视化组件库 (VCL) 框架和基础的编译器以及其他各项工具,这使得你构建那些跨越所有的数据源和 ......

Delphi 设计模式:《HeadFirst设计模式》Delphi代码

一、一个叫声接口和几只鸭子
1、从一个叫声接口开始
{《HeadFirst设计模式》Delphi代码之模式小结 }
{ 一个叫声接口 }
{ 编译工具:Delphi2010 for win32 }
{ E-Mail :xshlife@163.com }

unit uQuackable;

interface

type
IQuackable = in ......

Delphi 设计模式:《HeadFirst设计模式》Delphi7代码

 1.策略类
{《HeadFirst设计模式》之策略模式 }
{ 本单元中的类为策略类 }
{ 编译工具: Delphi7.0 }
{ E-Mail : xshlife@163.com }

unit uStrategy;

interface

type
{飞行接口,及其实现类 }

IFlyBehavior = Interface(IInterface)
procedure Fly;
......

Delphi 设计模式:《HeadFirst设计模式》Delphi7代码

1. 复杂的子系统
unit uSubObject;

interface

type

{ TAmplifier与TTuner,TCDPlayer,TDVDPlayer相互依赖。 }
{ 在TTuner等的简单实现时用不到对TAmplifier的引用, }
{ 但现实生活中就应该让TAmplifier提供服务,所以这里保留了。 }
{ TProjector对T ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号