//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "GenererUnit.h"
#include "mainframeUnit.h"
#include "AutoGenererUnit.h"
#include "GenereringsSpeUnit.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TGenereringsFrame *GenereringsFrame;
//---------------------------------------------------------------------------
__fastcall TGenereringsFrame::TGenereringsFrame(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TGenereringsFrame::AutoGenerering()
{
	int Dage = GFRadioGroup1->ItemIndex+1;
    int Frekvens = GFRadioGroup3->ItemIndex+1;
    int Styrke = GFRadioGroup4->ItemIndex+1;

    AutoG->Show();
    AutoG->ProgressBar->Position = 0;
    for(int Timer = 1; Timer < 8; Timer++)
    {
      if(!MainFrame->Genereret)
      {
        if(MainFrame->e->StartGenerering(Frekvens, Styrke, Dage, Timer, 0, MainFrame->Skrivebeskyttet))
          MainFrame->Genereret = true;
      }
      else if(MainFrame->e->StartGenerering(Frekvens, Styrke, Dage, Timer, 1, MainFrame->Skrivebeskyttet))
        MainFrame->Genereret = true;
      AutoG->ProgressBar->Position += 15;
      MainFrame->StatusBar->Panels->Items[8]->Text = "AutoGenerere!!";
    }
    AutoG->Close();
    MainFrame->UpdateStatusBar();
    MainFrame->StatusBar->Panels->Items[8]->Text = "AutoGenerereringen er afsluttet";
}
void __fastcall TGenereringsFrame::Button1Click(TObject *Sender)
{
   int Dage, Timer, Frekvens, Styrke;
   Dage = GFRadioGroup1->ItemIndex+1;
   Timer = GFRadioGroup2->ItemIndex+2;
   Frekvens = GFRadioGroup3->ItemIndex+1;
   Styrke = GFRadioGroup4->ItemIndex+1;

   if(MainFrame->TidsSpecifikationer)
     GenSpe->Show();
   comm.NulstilSpecifikation("Generering");
   if(!MainFrame->Genereret)
   {
     if(MainFrame->e->StartGenerering(Frekvens, Styrke, Dage, Timer, 0, MainFrame->Skrivebeskyttet))
       MainFrame->Genereret = true;
   }
   else if(MainFrame->e->StartGenerering(Frekvens, Styrke, Dage, Timer, 1, MainFrame->Skrivebeskyttet))
     MainFrame->Genereret = true;
   MainFrame->UpdateStatusBar();
   MainFrame->StatusBar->Panels->Items[8]->Text = "Generereringen er afsluttet";
   GenereringsFrame->Close();
}
//---------------------------------------------------------------------------
void __fastcall TGenereringsFrame::Button2Click(TObject *Sender)
{
	GenereringsFrame->Close();
}
//---------------------------------------------------------------------------

