易截截图软件、单文件、免安装、纯绿色、仅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图像处理

    设置图像关键颜色,使图像的某种或某个范围的颜色成为透明色,是图片合成、动画显示中经常用的图像处理手段。下面是实现代码:
过程定义:
// 设置色键(透明范围)。colorLow 低色键值; colorHigh 高色键值
// 当像素A、R、G、B值同时大于等于colorLow和小于等于colorHigh时为透明色
procedu ......

Delphi图像处理

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

DELPHI深度探索 (第2版)PDF电子书

 推荐给大家[url=DELPHI深度探索 (第2版)PDF电子书][/url]
因为需要前几天在网上搜搜过这本书书,可没有,源码倒是有,今天打开经常去的网站,居然发现提供下载了,这个网站自己差不多每天都要打开看看,这几天忙糊涂了,居然没有看到,在这推荐给大家,能下载的,速度很快。
[url=http://www.delphifans.com/Soft ......

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

1. 产品类
{《HeadFirst设计模式》工厂模式之简单工厂 }
{ 产品类 }
{ 编译工具 :Delphi7.0 }
{ 联系方式 :xshlife@163.com }

unit uProducts;

interface

type
TPizza = class(TObject)
public
procedure Prepare; virt ......

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

      容器的主要职责有两个:存放元素和浏览元素。根据单一职责原则(SRP)要将二者分开,于是将浏览功能打包封装就有了迭代器。
      用迭代器封装对动态数组的遍历:
1.容器中的元素类
{《HeadFirst设计模式》之迭代器模式 }
{ 容器中的元素类 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号