unit View;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Controller;
// die View kennt eigentlich nur den Controller
type
TfoView =
class(TForm)
edtNumber1: TEdit;
edtNumber2: TEdit;
btnAddition: TButton;
edtResult: TEdit;
procedure btnAdditionClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FController: TController;
procedure DoCalculateResult(Sender: TObject; CalculateResult: Single);
public
end;
var
foView: TfoView;
implementation
{$R *.dfm}
{ TfoView }
procedure TfoView.FormCreate(Sender: TObject);
begin
FController := TController.Create;
FController.OnCalculate := DoCalculateResult;
end;
procedure TfoView.FormDestroy(Sender: TObject);
begin
FController.Free;
end;
procedure TfoView.btnAdditionClick(Sender: TObject);
// Command
begin
FController.Addition(StrToFloat(edtNumber1.Text),
StrToFloat(edtNumber2.Text));
end;
procedure TfoView.DoCalculateResult(Sender: TObject; CalculateResult: Single);
begin
edtResult.Text := FloatToStr(CalculateResult);
end;
end.