📄 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;
procedure mnuExitClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FIndexFrame: TFrame;
{ Private declarations }
procedure UpdateView(o: TObject); //from IObserver
procedure setIndexFrame(AFrame: TFrame);
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;
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) then
begin
setIndexFrame(TFrame(cmd.getParamObject));
end
else if cmd.equals(CMD_TREEINDEX_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.mnuExitClick(Sender: TObject);
begin
close;
//it's no neccessary to ask the Controller determine everything
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 + -