unit design;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  fcButton, fcImgBtn, Buttons, ActnList, ComCtrls, ToolWin, ExtCtrls,
  StdCtrls;

type
  TfmDesign = class(TForm)
    CoolBar1: TCoolBar;
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ActionList1: TActionList;
    actOpenFile: TAction;
    actSaveFile: TAction;
    sbWG: TSpeedButton;
    sbPhotoV: TSpeedButton;
    SpeedButton3: TSpeedButton;
    sbBat: TSpeedButton;
    SpeedButton6: TSpeedButton;
    upPanel: TScrollBox;
    StaticText1: TStaticText;
    stModelName: TStaticText;
    stVr: TStaticText;
    StaticText4: TStaticText;
    StaticText5: TStaticText;
    stHZConType: TStaticText;
    stHZCalc: TStaticText;
    StaticText13: TStaticText;
    StaticText14: TStaticText;
    StaticText15: TStaticText;
    stRatedPower: TStaticText;
    StaticText17: TStaticText;
    sysHolder: TPanel;
    StaticText18: TStaticText;
    StaticText19: TStaticText;
    StaticText20: TStaticText;
    Splitter1: TSplitter;
    StaticText2: TStaticText;
    stPhPr: TStaticText;
    StaticText6: TStaticText;
    StaticText3: TStaticText;
    stBatCap: TStaticText;
    StaticText16: TStaticText;
    StaticText10: TStaticText;
    stBatVolts: TStaticText;
    StaticText12: TStaticText;
    StaticText21: TStaticText;
    stBatCapA: TStaticText;
    StaticText23: TStaticText;
    StaticText7: TStaticText;
    stHZPower: TStaticText;
    StaticText22: TStaticText;
    StaticText8: TStaticText;
    procedure sbWGClick(Sender: TObject);
    procedure ActionList1Update(Action: TBasicAction;
      var Handled: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmDesign: TfmDesign;

implementation

uses wgEd, Data, FormHolder, BatEd, PhotovEd, HZed, RestEd;

{$R *.DFM}

procedure TfmDesign.sbWGClick(Sender: TObject);
const
  FormClasses : array[0..4] of TFormClass =
   (
     TFmWGEd,
     TFmPhotovEd,
     TFmHzEd,
     TFmBatEd,
     TfmRestEd
   );
begin
  with TSpeedButton(Sender) do
  if Down and (FormClasses[tag]<>nil) then
     HoldFormClass(sysHolder,fmHolder.panel1,False,true,FormClasses[Tag]);
end;

procedure TfmDesign.ActionList1Update(Action: TBasicAction;
  var Handled: Boolean);
const
  HZConTypeDes : array[0..1] of string =
    (
      'Στον πίνακα καταναλώσεων',
      'Στον φορτιστή μπαταριών'
    );

begin
  { Ανεμογεννήτρια }
  stRatedPower.Caption := Format('%0.2f',[wg.RatedPower]);
  stModelName.Caption  := WG.ModelName;
  stVr.Caption         := Format('%0.2f',[wg.Vr]);

  {Φωτοβολταϊκό }
  stPhPr.Caption       := Format('%0.2f',[PhPower]);

  {Μπαταρίες }
  stBatCap.Caption     := Format('%0.2f',[MaxBateryCapacity]);
  stBatVolts.caption   := Format('%0.2f',[BateryVoltage]);
  if BateryVoltage<>0 then
     stBatCapA.Caption := Format('%0.2f',[MaxBateryCapacity/BateryVoltage])
  else
     stBatCapA.Caption := '-';

  { HZ }
  stHZPower.Caption    := Format('%0.2f',[HZPower]);
  stHZConType.Caption  := HZConTypeDes[HZConType];
  if HZCalc then
     stHZCalc.Caption := '(υπολογ. από τις καταναλώσεις)'
  else
     stHZCalc.Caption := ''; 
end;

procedure TfmDesign.FormCreate(Sender: TObject);
begin
  sbWGClick(sbWG);
end;

end.
