⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uview.pas

📁 Software Requirements1. Delphi 6 SP22. Oracle 8i R33. Raize 3.0.94. ExpressQuantumGrid 4.505. Expres
💻 PAS
字号:
unit UView;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, RzPanel, jpeg, RzBckgnd, RzCommon,
  MyFactory, MyModel, MyView, UModel, MyTools;

type
  TView = class(TFrame, IView)
    RzPanel1: TRzPanel;
    FrameController: TRzFrameController;
    RzBackground1: TRzBackground;
    RzPanel2: TRzPanel;
  protected
    Model: TModel;
    ModelFactory: TModelFactory;
  public
    function GetCaption: string; virtual; abstract;
  public
    constructor Create(Owner: TComponent; ModelFactory: TModelFactory); overload; virtual;
    destructor Destroy; override;
  protected
    procedure InitView; virtual;
    procedure InitModel; virtual;
    procedure SetModel(Model: TModel); virtual;
{---------------------------------------- IView ----------------------------------------}
  public
    function GetModel: TModel; virtual;
    function GetModelFactory: TModelFactory; virtual;
    procedure Refresh(Parameters: IParameters); virtual;
  end;

  TViewClass = class of TView;

implementation

uses
  MyException;

{$R *.dfm}

{ TView }

constructor TView.Create(Owner: TComponent; ModelFactory: TModelFactory);
begin
  inherited Create(Owner);
  Self.ModelFactory := ModelFactory;
  InitModel;
  try
    InitView;
  except
    on E: Exception do
      raise EInitViewException.Create(Self.ClassName, E.Message);
  end;
end;

destructor TView.Destroy;
begin
{
  Model := nil;
  ModelFactory.FreeModel;
  ModelFactory := nil;
}  
  inherited;
end;

function TView.GetModel: TModel;
begin
  Result := Model;
end;

function TView.GetModelFactory: TModelFactory;
begin
  Result := ModelFactory;
end;

procedure TView.InitModel;
begin
  try
    Model := TModel(ModelFactory.GetModel);
  except
    on E: Exception do
      raise EViewCreateException.Create(Self.ClassName, E.Message);
  end;
end;

procedure TView.InitView;
begin

end;

procedure TView.Refresh(Parameters: IParameters);
begin
  inherited Refresh;
end;

procedure TView.SetModel(Model: TModel);
begin
  Self.Model := Model;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -