unit Form.Main;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls, System.Actions,
Vcl.ActnList,
Vcl.AppEvnts,
ValueSorter;
type
TForm1 =
class( TForm )
ValueEdit: TEdit;
AddButton: TButton;
SortButton: TButton;
ResetButton: TButton;
Label1: TLabel;
ApplicationEvents1: TApplicationEvents;
procedure ApplicationEvents1Idle( Sender: TObject;
var Done: Boolean );
procedure ValueEditChange( Sender: TObject );
procedure AddButtonClick( Sender: TObject );
procedure SortButtonClick( Sender: TObject );
procedure ResetButtonClick( Sender: TObject );
private
FValueSorter: TValueSorter;
public
procedure AfterConstruction;
override;
procedure BeforeDestruction;
override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.AddButtonClick( Sender: TObject );
begin
FValueSorter.AddValue;
end;
procedure TForm1.AfterConstruction;
begin
inherited;
FValueSorter := TValueSorter.Create;
end;
procedure TForm1.ApplicationEvents1Idle( Sender: TObject;
var Done: Boolean );
begin
// Aktualisierung der Anzeige
ValueEdit.Text := FValueSorter.CurrentValue;
Label1.Caption := FValueSorter.ValuesAsString;
AddButton.Enabled := FValueSorter.CanAddValue;
SortButton.Enabled := FValueSorter.CanSort;
ResetButton.Enabled := FValueSorter.CanReset;
end;
procedure TForm1.BeforeDestruction;
begin
FValueSorter.Free;
inherited;
end;
procedure TForm1.ResetButtonClick( Sender: TObject );
begin
FValueSorter.Reset;
end;
procedure TForm1.SortButtonClick( Sender: TObject );
begin
FValueSorter.Sort;
end;
procedure TForm1.ValueEditChange( Sender: TObject );
begin
// Aktualisierung der Benutzereingabe
FValueSorter.CurrentValue := ValueEdit.Text;
end;
end.