//---------------------------------------------------------------------------

#include <vcl.h>
#include <dstring.h>
#pragma hdrstop

#include "NextScreen.h"
#include "LastScreen.h"
#include "FileManager.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TAnalysisInput *AnalysisInput;


String other_species;
bool omit_1_scan, Extract_File_Name, Extract_Date, Extract_Time, Extract_Aux2;
int smoothing_points;
int number_replicates;
float ViO2, VfO2, ViH2O2, VfH2O2, ViHS, VfHS, ViFeS, VfFeS, ViOther, VfOther;

//---------------------------------------------------------------------------
__fastcall TAnalysisInput::TAnalysisInput(TComponent* Owner)
        : TForm(Owner)
{

}
//---------------------------------------------------------------------------
void __fastcall TAnalysisInput::NextClick(TObject *Sender)
{

        if (ComboBox1->ItemIndex == 1)
        {   smoothing_points = Edit13->Text.ToInt(); }
        else
        {   smoothing_points = 1;}

        number_replicates = Edit1->Text.ToInt();

//  need to be able to make the Vi & Vo values accept negative, decimal inputs.        
        if (CheckBox7->Checked)
        {   ViO2 = StrToFloat(AnsiString(Edit2->Text));
            VfO2 = StrToFloat(AnsiString(Edit3->Text));
        }
// do I need these else statements since if checkbox isn't checked, we won't need Vi & Vf
        else
        {   ViO2 = 0; VfO2 = 0;   }

        if (CheckBox8->Checked)
        {   ViH2O2 = Edit4->Text.ToInt();
            VfH2O2 = Edit5->Text.ToInt();
        }
        else
        {   ViH2O2 = 0; VfH2O2 = 0;   }

        if (CheckBox9->Checked)
        {   ViHS = Edit6->Text.ToInt();
            VfHS = Edit7->Text.ToInt();
        }
        else
        {   ViHS = 0; VfHS = 0;   }

        if (CheckBox9->Checked)
        {   ViFeS = Edit8->Text.ToInt();
            VfFeS = Edit9->Text.ToInt();
        }
        else
        {   ViFeS = 0; VfFeS = 0;   }

        other_species = Edit10->Text;

        if (CheckBox10->Checked)
        {   ViOther = Edit11->Text.ToInt();
            VfOther = Edit12->Text.ToInt();
        }
        else
        {   ViOther = 0; VfOther = 0;  }

// going on to show requested components on ReviewScreen...

        ReviewScreen->number_Replicates->Caption = AnalysisInput->Edit1->Text;

        ReviewScreen->Omit_First->Caption = AnalysisInput->Edit14->Text;

        int variable = smoothing_points*2+1;

        ReviewScreen->Smoothing_Num->Caption = AnsiString(variable);


        for (int i=0; i< FileScreen->ListBox1->Items->Count; i++)
        {  ReviewScreen->ListBox1->Items->Add(FileScreen->ListBox1->Items->Strings[i]); }



        ReviewScreen->Show();
}
//---------------------------------------------------------------------------
void __fastcall TAnalysisInput::FormShow(TObject *Sender)
{
        FileScreen->WindowState = wsMinimized;        
}
//---------------------------------------------------------------------------

void __fastcall TAnalysisInput::Edit1Change(TObject *Sender)
{
 if (Edit1->Text.ToInt()>20 && Edit1->Text !='0')
    { Edit1->Text=20;}
}
//---------------------------------------------------------------------------

void __fastcall TAnalysisInput::Edit14Change(TObject *Sender)
{
if (Edit14->Text.ToInt()>=Edit1->Text.ToInt() && Edit14->Text != '0')
   {
    Application->MessageBox(
           "Number of scans to ignore MUST be less than the number of replicates.","Error",
           MB_OK);
   }
}
//---------------------------------------------------------------------------

void __fastcall TAnalysisInput::ComboBox1Change(TObject *Sender)
{
   if (ComboBox1->ItemIndex ==0)
   {Edit13->Text='0';}
}
//---------------------------------------------------------------------------

