unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, event.fam.types, model.stockpile, controller, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
LabelEventHandlerDebug: TLabel;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure SetApplicationBackground;
procedure Button1Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure EventHandlerViewLabelUpdate;
procedure EventHandlerModelStockpileUpdate;
procedure RadioButton2Click(Sender: TObject);
private
{ Private-Deklarationen }
controller: TController;
FAMEvents: TEvents;
StockpileModel: TStockpileModel;
// Stockpile model
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
data: TArray<Double>;
begin
StockpileModel.SetData(data);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{ Create eventtype }
FAMEvents := TEvents.Create();
{ Create controller instances }
controller := TController.Create();
{ Register Event-Handler }
controller.OnUpdateUI := EventHandlerViewLabelUpdate;
controller.OnApplicationBackground := SetApplicationBackground;
{ Create object instances }
StockpileModel := TStockpileModel.Create();
{ Register Event-Handler for StockpileModel }
StockpileModel.registerOn(EventHandlerModelStockpileUpdate);
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
controller.DispatchEvent(FAMEvents.
Name.OnUpdateUI);
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
controller.DispatchEvent(FAMEvents.
Name.OnApplicationBackground);
end;
procedure TForm1.SetApplicationBackground;
begin
self.Color := clBlue;
end;
procedure TForm1.EventHandlerModelStockpileUpdate;
begin
ShowMessage('
EventHandlerModelStockpileUpdate');
end;
procedure TForm1.EventHandlerViewLabelUpdate;
begin
LabelEventHandlerDebug.caption := ('
TListener has been OnUpdateUI.');
end;
end.