{ Un incredibile programma di ForeCast Astronomico

  Copyright (C) 2025 starstreet_sardegna

  This source is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free
  Software Foundation; either version 3 of the License, or (at your option)
  any later version.

  This code is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.

  A copy of the GNU General Public License is available on the World Wide Web
  at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing
  to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
  Boston, MA 02110-1335, USA.
}
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
  EditBtn, Buttons, astronomy, framegrafico, frameluna, meteo_frame,
  DateUtils, FileInfo, typinfo, ImpostazioniForm, settingsutils, info_form
  ,LCLType, Menus, DateTimePicker, VisualizzaEventiForm;

type

  { TForm1 }

  TForm1 = class(TForm)
    DateEdit1: TDateEdit;
    impostazionibutton: TSpeedButton;
    ContenitoreTop: TPanel;
    InfoButton: TSpeedButton;
    EventiListButton: TSpeedButton;
    LunaView1: TLunaView;
    MenuMac: TMenuItem;
    InfoMenu: TMenuItem;
    MenuGlobale: TMainMenu;
    MeteoView1: TMeteoView;
    PianetiGraph1: TPianetiGraph;
    tempooggi: TSpeedButton;
    BarraStrumenti: TPanel;
    avanti: TSpeedButton;
    indietro: TSpeedButton;
    indietroveloce: TSpeedButton;
    avantiveloce: TSpeedButton;
    procedure AggiungiClick(Sender: TObject);
    procedure DateEdit1ButtonClick(Sender: TObject);
    procedure DateEdit1Change(Sender: TObject);
    procedure EventiListButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure InfoButtonClick(Sender: TObject);
    procedure impostazionibuttonClick(Sender: TObject);
    procedure SottraiClick(Sender: TObject);
    procedure avantiClick(Sender: TObject);
    procedure indietroClick(Sender: TObject);
    procedure indietroveloceClick(Sender: TObject);
    procedure avantiveloceClick(Sender: TObject);
    procedure tempooggiClick(Sender: TObject);



  private

  public

  end;






var
  Form1: TForm1;
  tempo:TDateTime;

  OraSimulazione: integer;
  httpsIsEnabled:boolean;
  LinguaApp:string;

 impostazionidati:TImpostazioniDati;

implementation

{$R *.lfm}

{ TForm1 }


procedure TForm1.FormCreate(Sender: TObject);
var
  versione:TVersionQuad;  //variabile per la versione del programma
  versionnumber:string;
  begin
  {$ifdef darwin}
         MenuMac.Visible:=True;
  {$endif}


 PianetiGraph1.colorform:=Form1.Color;   //passa al frame il colore del form
 Tempo:=EncodeDateTime(YearOf(Now), MonthOf(Now), DayOf(Now),0,0,0,0);
 Impostazionidati:=settingsutils.LeggiImpostazioni;
 Tempo:=DateEdit1.Date;

 Form1.tempooggiClick(nil);
 FileInfo.GetProgramVersion(versione);
  Form1.tempooggiClick(nil);
 versionnumber:=FileInfo.VersionQuadToStr(versione);
 Form1.Caption:='StarStreet Forecast App v'+versionnumber;
 info_form.versionnumber:=versionnumber;  //passo la variabile di versione a info_form
  end;


procedure TForm1.FormResize(Sender: TObject);
begin
end;

procedure TForm1.InfoButtonClick(Sender: TObject);
begin
  info_form.Informazioni.ShowModal;
end;

procedure TForm1.impostazionibuttonClick(Sender: TObject);
begin
  ImpostazioniForm.Impostazioni.ShowModal;
  impostazionidati:=ImpostazioniForm.impostazionidati;

  Form1.DateEdit1Change(nil);
end;

procedure TForm1.SottraiClick(Sender: TObject);
begin

end;

procedure TForm1.avantiClick(Sender: TObject);
begin
   DateEdit1.Date:=DateUtils.IncDay(Tempo,1);
end;

procedure TForm1.indietroClick(Sender: TObject);
begin
  DateEdit1.Date:=DateUtils.IncDay(Tempo,-1);
end;

procedure TForm1.indietroveloceClick(Sender: TObject);
begin
   DateEdit1.Date:=DateUtils.IncDay(Tempo,-5);
end;

procedure TForm1.avantiveloceClick(Sender: TObject);
begin
  DateEdit1.Date:=DateUtils.IncDay(Tempo,5);
end;


procedure TForm1.tempooggiClick(Sender: TObject);
begin
 DateEdit1.Date:=EncodeDate(YearOf(Now), MonthOf(Now), DayOf(Now));

end;

procedure TForm1.AggiungiClick(Sender: TObject);
begin

end;

procedure TForm1.DateEdit1ButtonClick(Sender: TObject);
begin

end;

procedure TForm1.DateEdit1Change(Sender: TObject);
begin
   Tempo:=DateEdit1.Date;
   PianetiGraph1.ImpostaTempoClick(nil, Tempo, impostazionidati.Latitudine,impostazionidati.Longitudine);
   LunaView1.ImpostaDataClick(nil, Tempo, impostazionidati.OraSimulazione);
   Form1.MeteoView1.OttieniMeteoClick(nil, Tempo, impostazionidati.httpsIsEnabled, impostazionidati.Latitudine, impostazionidati.Longitudine, impostazionidati.OraSimulazione);

end;

procedure TForm1.EventiListButtonClick(Sender: TObject);
begin
  VisualizzaEventiForm.Form2.Show;
end;




end.

