📄 fatherctrl.pas
字号:
unit FatherCtrl;
interface
uses
SysUtils, stdctrls, forms, buttons, classes, controls, patterns,
FatherMdl, FatherView;
type
TControllerFather = class(TController)
model: TModelFather;
view: TViewFather;
protected
procedure DoCommand(ACommand: string; const args: TObject = nil); override;
public
constructor Create;
destructor Destroy; override;
procedure OnClick(Sender: TObject); //for ieventListener
procedure OnMouseEvent(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
end;
implementation
uses
commandlist;
procedure TControllerFather.OnClick(Sender: TObject);
begin
if Sender is TButton then
begin
self.SendCommand(View.getCommand, 'Father');
self.SendCommand(CMD_NODE_SELECT, 'Father');
end;
end;
procedure TControllerFather.OnMouseEvent(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
end;
constructor TControllerFather.Create;
begin
inherited;
model := TModelFather.Create;
view := TViewFather.create(nil);
view.setEventHandler(self.OnClick);
model.RegObserver(view);
end;
destructor TControllerFather.destroy;
begin
freeAndNil(model);
freeAndNil(view);
inherited;
end;
procedure TControllerFather.DoCommand(ACommand: string; const args: TObject = nil);
begin
if ACommand = CMD_REQUIRE_FATHERVIEW then
self.SendCommand(CMD_SHOW_FATHERVIEW, view)
else if (ACommand = CMD_NODE_SELECT) and
(args <> nil) and
(uppercase(TCommand(args).getCommandTxt) = uppercase('Father')) then
begin
model.response(ACommand, args as TCommand);
end
else if (ACommand = CMD_MOM_NEWCLOTHES) or
(ACommand = CMD_MOM_LOVEME) or
(ACommand = CMD_MOM_HEARD) or
(ACommand = CMD_BABY_CHOCOLATE) or
(ACommand = CMD_BABY_CARTOON) or
(ACommand = CMD_CLEAR_SELECTION) then
begin
model.response(ACommand);
end;
end;
initialization
ControlCenter.RegController(TControllerFather.Create);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -