现在流行“抓眼球的艺术”。那我就从Presentation之View开创吧。
unit IWA.View.LoginViewIntf;
interface
type
TLoginEvent = procedure of object;
ILoginView = interface
['{CC037F47-BBDA-461E-8A8B-A6C2B7680CCD}']
function GetUserID: string;
procedure SetUserName(const Value: string);
function GetUserPassword: string;
procedure SetOnSubmit(const Value: TLoginEvent);
property UserID: string read GetUserID;
property UserName: string write SetUserName;
property UserPassword: string read GetUserPassword;
property OnSubmit: TLoginEvent write SetOnSubmit;
end;
implementation
end.
==========================================================================
unit IWA.IWForm.LoginForm;
interface
uses
......,
IWA.View.LoginViewIntf,
......;
type
TIWLoginForm = class(TIWAppForm, ILoginView)
IWEditUserPassword: TIWEdit;
IWEditUserID: TIWEdit;
IWButtonSubmit: TIWButton;
procedure IWButtonSubmitAsyncClick(Sender: TObject;
EventParams: TStringList);
private
FOnSubmit: TLoginEvent;
function GetUserID: string;
procedure SetUserName(const Value: string);
function GetUserPassword: string;
procedure SetOnSubmit(const Value: TLoginEvent);
protected
public
end;
implementation
{$R *.dfm}
{ TIWLoginForm }
function TIWLoginForm.GetUserID: string;
begin
Result := IWEditUserID.Text;
end;
function TIWLoginForm.GetUserPassword: string;
begin
Result := IWEditUserPassword.Text;
end;
procedure TIWLoginForm.IWButtonSubmitAsyncClick(Sender: TObject;
EventParams: TStringList);
begin
if Assigned(FOnSubmit) then
FOnSubmit;
end;
procedure TIWLoginForm.SetOnSubmit(const Value: TLoginEvent);
begin
FOnSubmit := Value;
end;
procedure TIWLoginForm.SetUserName(const Value: string);
begin
IWButtonSubmit.Caption := Value; //没有任何意义,仅用于测试
end;
end.