//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "ZagrPlus.h"
#include "String_doubleUnit.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TZagrPlusForm *ZagrPlusForm;
//---------------------------------------------------------------------------
__fastcall TZagrPlusForm::TZagrPlusForm(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TZagrPlusForm::BitBtnCancelClick(TObject *Sender)
{
   Close();

}
//---------------------------------------------------------------------------
void __fastcall TZagrPlusForm::FormShow(TObject *Sender)
{
   type_zagr = -1;
   CheckBox_Weight->Checked = false;
}
//---------------------------------------------------------------------------
void __fastcall TZagrPlusForm::ComboBox_type_zagrChange(TObject *Sender)
{
   switch (ComboBox_type_zagr->ItemIndex) {
   case 0:
	 Edit_gamma_f->Text =  1.1;
   break;
   case 1:
	 Edit_gamma_f->Text =  1.1;
   break;
   case 2:
	 Edit_gamma_f->Text =  1.1;
   break;
   case 3:
	 Edit_gamma_f->Text =  1.05;
   break;
   }
}
//---------------------------------------------------------------------------
void __fastcall TZagrPlusForm::BitBtnDoneClick(TObject *Sender)
{
   int rc = String_double_plus(Label_gamma_f->Caption, Edit_gamma_f->Text, &koeff_gamma_f);
	   if (rc>0) return;
		 // Установить понижающий коэфф.
	   rc = String_double_plus(Label_koef_low->Caption, Edit_koef_low->Text, &koeff_low);
	   if (rc>0) return;

	   type_zagr = ComboBox_type_zagr->ItemIndex;
	   if (CheckBox_Weight->Checked)
		 flag_weight = true;
	   else
		 flag_weight = false;

	   Close();
}
//---------------------------------------------------------------------------
void __fastcall TZagrPlusForm::CheckBox_WeightClick(TObject *Sender)
{
   if (CheckBox_Weight->Checked) {
	  ComboBox_type_zagr->ItemIndex = 0;
	  ComboBox_type_zagr->Enabled = false;
	  Edit_gamma_f->ReadOnly =  true;
	  Edit_koef_low->ReadOnly = true;
	  Edit_gamma_f->Text =  1.05;
	  Edit_koef_low->Text =  1.0;
   }
   else {
	  ComboBox_type_zagr->Enabled = true;
	  Edit_gamma_f->ReadOnly =  false;
	  Edit_koef_low->ReadOnly = false;
   }
}
//---------------------------------------------------------------------------

