unit GestoreDelForm;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls,Temperature,LeggiNumeri;
type
{ TForm1 }
TForm1 = class(TForm)
LabelUnita: TLabel;
LabelRisultato: TLabel;
LabeledEditIngresso: TLabeledEdit;
RadioButtonCelsius: TRadioButton;
RadioButtonKelvin: TRadioButton;
RadioGroupConversione: TRadioGroup;
procedure FormCreate(Sender: TObject);
procedure LabeledEditIngressoChange(Sender: TObject);
procedure LabeledEditIngressoKeyPress(Sender: TObject; var Key: char);
procedure RadioButtonKelvinChange(Sender: TObject);
private
{ private declarations }
procedure stampaRisultato(temperatura:double);
procedure focalizza;
var attivo:boolean;
public
{ public declarations }
end;
var
Form1: TForm1;
g:gradi;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
attivo:=false;
g:=gradi.crea;
Form1.Caption:='Kelvin';
LabeledEditIngresso.EditLabel.Caption:='Temperatura';
LabeledEditIngresso.Caption:='';
RadioGroupConversione.Caption:='Converti in';
RadioButtonCelsius.Caption:='Celsius';
RadioButtonKelvin.Caption:='Kelvin';
LabelUnita.Caption:='°C';
RadioButtonKelvin.Checked:=true;
LabelRisultato.Caption:='';
LabeledEditIngresso.ReadOnly:=true;
LabelUnita.Caption:='°C';
end;
procedure TForm1.LabeledEditIngressoChange(Sender: TObject);
begin
stampaRisultato(StrToFloatDef(LabeledEditIngresso.Caption, 0.0));
end;
procedure TForm1.LabeledEditIngressoKeyPress(Sender: TObject; var Key: char);
begin
LabeledEditIngresso.Caption:=tasto(LabeledEditIngresso.Caption, Key);
end;
procedure TForm1.stampaRisultato(temperatura:double);
begin
if RadioButtonCelsius.Checked then
begin
LabelRisultato.Caption:=g.aCelsius(temperatura);
LabelUnita.Caption:='K';
end
else
begin
LabelRisultato.Caption:=g.aKelvin(temperatura);
LabelUnita.Caption:='°C';
end;
focalizza;
end;
procedure TForm1.RadioButtonKelvinChange(Sender: TObject);
begin
stampaRisultato(StrToFloatDef(LabeledEditIngresso.Caption, 0.0));
end;
procedure TForm1.focalizza;
begin
if attivo then
begin
LabeledEditIngresso.SetFocus;
LabeledEditIngresso.SelStart:=length(LabeledEditIngresso.Caption);
LabeledEditIngresso.SelLength:=0;
end
else attivo:=true;
end;
end.