📄 mainview.pas
字号:
unit MainView;
// This code was generated by the EasyMVC OTA Wizard
// www.eazisoft.com
interface
uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, StdCtrls, ComCtrls, ExtCtrls, Forms, patterns, Menus,
IndexTreeView;
type
TViewMain = class(TFORM, IObserver)
MainMenu1: TMainMenu;
File1: TMenuItem;
mnuExit: TMenuItem;
Help1: TMenuItem;
mnuAbout: TMenuItem;
mnuHelp: TMenuItem;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
StatusBar1: TStatusBar;
Splitter1: TSplitter;
pnlIndex: TPanel;
Label1: TLabel;
PageControl2: TPageControl;
TabSheet2: TTabSheet;
pnlChildren: TPanel;
Panel1: TPanel;
Splitter2: TSplitter;
pnlMother: TPanel;
Splitter3: TSplitter;
pnlFather: TPanel;
procedure mnuExitClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FIndexFrame,
FFatherFrame,
FMotherFrame,
FBabyFrame: TFrame;
{ Private declarations }
procedure UpdateView(o: TObject); //from IObserver
// procedure setIndexFrame(AFrame: TFrame);
procedure setFrame(AFrame: TFrame; AParent: TPanel);
procedure setInfo(s: string);
public
{ Public declarations }
procedure setNotifyEventHandler(ANotifyEvent: TNotifyEvent);
procedure UnLoadFrames;
end;
implementation
uses commandlist;
{$R *.dfm}
procedure TViewMain.UnLoadFrames;
begin
if assigned(self.fIndexFrame) then
begin
findexFrame.parent := nil;
findexFrame := nil;
end;
if assigned(FFatherFrame) then
begin
FFatherFrame.parent := nil;
FFatherFrame := nil;
end;
if assigned(FMotherFrame) then
begin
FMotherFrame.parent := nil;
FMotherFrame := nil;
end;
if assigned(FBabyFrame) then
begin
FBabyFrame.parent := nil;
FBabyFrame := nil;
end;
end;
procedure TViewMain.setInfo(s: string);
begin
label1.Caption := s;
end;
procedure TViewMain.UpdateView(o: TObject);
var
cmd: TCommand;
begin
{write your code here}
if o is TCommand then
begin
cmd := TCommand(o);
if cmd.equals(CMD_SHOW_INDEXTREE) and (self.FIndexFrame <> TFrame(cmd.getParamObject)) then
begin
self.FIndexFrame := TFrame(cmd.getParamObject);
setFrame(TFrame(cmd.getParamObject), pnlIndex);
end
else if cmd.equals(CMD_SHOW_FATHERVIEW) and (self.FFatherFrame <> TFrame(cmd.getParamObject)) then
begin
self.FFatherFrame := TFrame(cmd.getParamObject);
setFrame(TFrame(cmd.getParamObject), pnlFather);
end
else if cmd.equals(CMD_SHOW_MOTHERVIEW) and (self.FMotherFrame <> TFrame(cmd.getParamObject)) then
begin
self.FMotherFrame := TFrame(cmd.getParamObject);
setFrame(TFrame(cmd.getParamObject), pnlMother);
end
else if cmd.equals(CMD_SHOW_CHILDRENVIEW) and (self.FBabyFrame <> TFrame(cmd.getParamObject)) then
begin
self.FBabyFrame := TFrame(cmd.getParamObject);
setFrame(TFrame(cmd.getParamObject), pnlChildren);
end
else if cmd.equals(CMD_NODE_SELECT) then
begin
self.setInfo(TCommand(cmd.getParamObject).getCommandTxt);
end;
end;
freeAndNil(o);
end;
//procedure TViewMain.setIndexFrame(AFrame: TFrame);
//begin
// if assigned(AFrame) and (AFrame <> FIndexFrame) then
// begin
// UnLoadFrames;
// self.findexFrame := AFrame;
// findexFrame.Parent := pnlIndex;
// findexFrame.Align := alClient;
// end;
//end;
procedure TViewMain.setFrame(AFrame: TFrame; AParent: TPanel);
begin
if assigned(AFrame) then
begin
AFrame.Parent := AParent;
AFrame.Align := alClient;
end;
end;
procedure TViewMain.mnuExitClick(Sender: TObject);
begin
//it's no neccessary to ask the Controller determine everything
//so close here
close;
end;
procedure TViewMain.setNotifyEventHandler(ANotifyEvent: TNotifyEvent);
begin
if assigned(ANotifyEvent) then
begin
mnuHelp.OnClick := ANotifyEvent;
mnuAbout.OnClick := ANotifyEvent;
end;
end;
procedure TViewMain.FormDestroy(Sender: TObject);
begin
//must unload the indexframe,otherwise it will be released by MainView
self.UnLoadFrames;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -