// Dlg_Renewables.cpp : implementation file
//

#include "stdafx.h"
#include "SAPP1.h"
#include "SAPP1Dlg.h"
#include "Dlg_Renewables.h"

// CDlg_Renewables dialog

IMPLEMENT_DYNAMIC(CDlg_Renewables, CDialog)
CDlg_Renewables::CDlg_Renewables(CWnd* pParent /*=NULL*/)
	: CDialog(CDlg_Renewables::IDD, pParent)
	, str_comboSHWpresent(_T(""))
	, str_comboSHWCollectorType(_T(""))
	, str_comboSHWCollectorOrientation(_T(""))
	, str_comboSHWCollectorTilt(_T(""))
	, str_comboSHWOvershading(_T(""))
	, str_comboSHWGrossArea(_T(""))
	, str_editSHWApertureArea(_T(""))
	, str_editSHWZLCollectorEff(_T(""))
	, str_editSHWHLCoeff(_T(""))
	, str_comboSHWSolarStore(_T(""))
	, str_editSHWSolarVolume(_T(""))
	, str_comboSHWSolarCircPump(_T(""))
	, str_comboAdditionalElect(_T(""))
	, str_editElecGenerated(_T(""))
	, str_editTFARenewables(_T(""))
	, str_comboPVPresent(_T(""))
	, str_editPVPeakPower(_T(""))
	, str_comboPVCollectorOrientation(_T(""))
	, str_comboPVCollectorTilt(_T(""))
	, str_comboPVOvershading(_T(""))
	, str_comboWTPresent(_T(""))
	, str_editWTNumOf(_T(""))
	, str_editWTDiameter(_T(""))
	, str_editWTHeight(_T(""))
{
}

CDlg_Renewables::~CDlg_Renewables()
{
}

void CDlg_Renewables::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_STATIC_1, m_labelSWH);
	DDX_Control(pDX, IDC_STATIC_2, m_labelGeneration);
	DDX_Control(pDX, IDC_STATIC_3, m_labelPV);
	DDX_Control(pDX, IDC_STATIC_4, m_labelWT);
	DDX_Control(pDX, IDC_STATIC_zl, m_labeZL);
	DDX_Control(pDX, IDC_STATIC_CSH, m_labelCSH1);
	DDX_Control(pDX, IDC_STATIC_CSH2, m_labelCSH2);
	DDX_Control(pDX, IDC_STATIC_CSH3, m_labelCSH3);
	DDX_Control(pDX, IDC_COMBO_IsSWH, m_comboSHWpresent);
	DDX_Control(pDX, IDC_COMBO_SHWcollectorType, m_comboSHWCollectorType);
	DDX_Control(pDX, IDC_COMBO_SWHcollectorOrient, m_comboSHWCollectorOrientation);
	DDX_Control(pDX, IDC_COMBO_SHWcollectorTilt, m_comboSHWCollectorTilt);
	DDX_Control(pDX, IDC_COMBO_SHWovershading, m_comboSHWOvershading);
	DDX_Control(pDX, IDC_COMBO_SHWgrossArea, m_comboSHWGrossArea);
	DDX_Control(pDX, IDC_COMBO_SHWisSolarStoreCombined, m_comboSHWSolarStore);
	DDX_Control(pDX, IDC_COMBO_SHWPump, m_comboSHWSolarCircPump);
	DDX_Control(pDX, IDC_COMBO_SHWadditionalGen, m_comboAdditionalElect);
	DDX_Control(pDX, IDC_COMBO_PVpresent, m_comboPVPresent);
	DDX_Control(pDX, IDC_COMBO_PVcollectorOrient, m_comboPVCollectorOrientation);
	DDX_Control(pDX, IDC_COMBO__PVcollectorTilt, m_comboPVCollectorTilt);
	DDX_Control(pDX, IDC_COMBO_PVovershading, m_comboPVOvershading);
	DDX_Control(pDX, IDC_COMBO_WTpresent, m_comboWTPresent);
	DDX_Control(pDX, IDC_EDIT_SHWaperatureArea, m_editSHWApertureArea);
	DDX_Control(pDX, IDC_EDIT_SHWZLcollectorEff, m_editSHWZLCollectorEff);
	DDX_Control(pDX, IDC_EDIT_SHW_HLcoeff, m_editSHWHLCoeff);
	DDX_Control(pDX, IDC_EDIT_SHWvolume, m_editSHWSolarVolume);
	DDX_Control(pDX, IDC_EDIT_elecGenerated, m_editElecGenerated);
	DDX_Control(pDX, IDC_EDIT_TFA, m_editTFARenewables);
	DDX_Control(pDX, IDC_EDII_PVpeakPower, m_editPVPeakPower);
	DDX_Control(pDX, IDC_EDITWTnums, m_editWTNumOf);
	DDX_Control(pDX, IDC_EDIT_WTdiameter, m_editWTDiameter);
	DDX_Control(pDX, IDC_EDIT_WTheight, m_editWTHeight);
	DDX_CBString(pDX, IDC_COMBO_IsSWH, str_comboSHWpresent);
	DDX_CBString(pDX, IDC_COMBO_SHWcollectorType, str_comboSHWCollectorType);
	DDX_CBString(pDX, IDC_COMBO_SWHcollectorOrient, str_comboSHWCollectorOrientation);
	DDX_CBString(pDX, IDC_COMBO_SHWcollectorTilt, str_comboSHWCollectorTilt);
	DDX_CBString(pDX, IDC_COMBO_SHWovershading, str_comboSHWOvershading);
	DDX_CBString(pDX, IDC_COMBO_SHWgrossArea, str_comboSHWGrossArea);
	DDX_Text(pDX, IDC_EDIT_SHWaperatureArea, str_editSHWApertureArea);
	DDX_Text(pDX, IDC_EDIT_SHWZLcollectorEff, str_editSHWZLCollectorEff);
	DDX_Text(pDX, IDC_EDIT_SHW_HLcoeff, str_editSHWHLCoeff);
	DDX_CBString(pDX, IDC_COMBO_SHWisSolarStoreCombined, str_comboSHWSolarStore);
	DDX_Text(pDX, IDC_EDIT_SHWvolume, str_editSHWSolarVolume);
	DDX_CBString(pDX, IDC_COMBO_SHWPump, str_comboSHWSolarCircPump);
	DDX_CBString(pDX, IDC_COMBO_SHWadditionalGen, str_comboAdditionalElect);
	DDX_Text(pDX, IDC_EDIT_elecGenerated, str_editElecGenerated);
	DDX_Text(pDX, IDC_EDIT_TFA, str_editTFARenewables);
	DDX_CBString(pDX, IDC_COMBO_PVpresent, str_comboPVPresent);
	DDX_Text(pDX, IDC_EDII_PVpeakPower, str_editPVPeakPower);
	DDX_CBString(pDX, IDC_COMBO_PVcollectorOrient, str_comboPVCollectorOrientation);
	DDX_CBString(pDX, IDC_COMBO__PVcollectorTilt, str_comboPVCollectorTilt);
	DDX_CBString(pDX, IDC_COMBO_PVovershading, str_comboPVOvershading);
	DDX_CBString(pDX, IDC_COMBO_WTpresent, str_comboWTPresent);
	DDX_Text(pDX, IDC_EDITWTnums, str_editWTNumOf);
	DDX_Text(pDX, IDC_EDIT_WTdiameter, str_editWTDiameter);
	DDX_Text(pDX, IDC_EDIT_WTheight, str_editWTHeight);
	DDX_Control(pDX, IDC_RADIO20, m_btnExposureExposed);
	DDX_Control(pDX, IDC_RADIO21, m_btnExposureAboveAvg);
	DDX_Control(pDX, IDC_RADIO22, m_btnExposureAvg);
	DDX_Control(pDX, IDC_RADIO23, m_btnExposureBelowAvg);
	DDX_Control(pDX, IDC_RADIO24, m_btnExposureSheltered);
	DDX_Control(pDX, IDC_STATIC_exp, m_labelExposure);
}

BEGIN_MESSAGE_MAP(CDlg_Renewables, CDialog)
	ON_CBN_SELCHANGE(IDC_COMBO_IsSWH, OnCbnSelchangeComboIsswh)
	ON_CBN_SELCHANGE(IDC_COMBO_SHWcollectorType, OnCbnSelchangeComboShwcollectortype)
	ON_CBN_SELCHANGE(IDC_COMBO_SWHcollectorOrient, OnCbnSelchangeComboSwhcollectororient)
	ON_CBN_SELCHANGE(IDC_COMBO_SHWcollectorTilt, OnCbnSelchangeComboShwcollectortilt)
	ON_CBN_SELCHANGE(IDC_COMBO_SHWovershading, OnCbnSelchangeComboShwovershading)
	ON_CBN_SELCHANGE(IDC_COMBO_SHWgrossArea, OnCbnSelchangeComboShwgrossarea)
	ON_EN_CHANGE(IDC_EDIT_SHWaperatureArea, OnEnChangeEditShwaperaturearea)
	ON_EN_CHANGE(IDC_EDIT_SHWZLcollectorEff, OnEnChangeEditShwzlcollectoreff)
	ON_EN_CHANGE(IDC_EDIT_SHW_HLcoeff, OnEnChangeEditShwHlcoeff)
	ON_CBN_SELCHANGE(IDC_COMBO_SHWisSolarStoreCombined, OnCbnSelchangeComboShwissolarstorecombined)
	ON_EN_CHANGE(IDC_EDIT_SHWvolume, OnEnChangeEditShwvolume)
	ON_CBN_SELCHANGE(IDC_COMBO_SHWPump, OnCbnSelchangeComboShwpump)
	ON_CBN_SELCHANGE(IDC_COMBO_SHWadditionalGen, OnCbnSelchangeComboShwadditionalgen)
	ON_EN_CHANGE(IDC_EDIT_elecGenerated, OnEnChangeEditelecgenerated)
	ON_EN_CHANGE(IDC_EDIT_TFA, OnEnChangeEditTfa)
	ON_CBN_SELCHANGE(IDC_COMBO_PVpresent, OnCbnSelchangeComboPvpresent)
	ON_EN_CHANGE(IDC_EDII_PVpeakPower, OnEnChangeEdiiPvpeakpower)
	ON_CBN_SELCHANGE(IDC_COMBO_PVcollectorOrient, OnCbnSelchangeComboPvcollectororient)
	ON_CBN_SELCHANGE(IDC_COMBO__PVcollectorTilt, OnCbnSelchangeCombo)
	ON_CBN_SELCHANGE(IDC_COMBO_PVovershading, OnCbnSelchangeComboPvovershading)
	ON_CBN_SELCHANGE(IDC_COMBO_WTpresent, OnCbnSelchangeComboWtpresent)
	ON_EN_CHANGE(IDC_EDITWTnums, OnEnChangeEditwtnums)
	ON_EN_CHANGE(IDC_EDIT_WTdiameter, OnEnChangeEditWtdiameter)
	ON_EN_CHANGE(IDC_EDIT_WTheight, OnEnChangeEditWtheight)
	ON_BN_CLICKED(IDC_RADIO20, OnBnClickedRadio20)
	ON_BN_CLICKED(IDC_RADIO21, OnBnClickedRadio21)
	ON_BN_CLICKED(IDC_RADIO22, OnBnClickedRadio22)
	ON_BN_CLICKED(IDC_RADIO23, OnBnClickedRadio23)
	ON_BN_CLICKED(IDC_RADIO24, OnBnClickedRadio24)
END_MESSAGE_MAP()

// CDlg_Renewables message handlers
BOOL CDlg_Renewables::OnInitDialog()
{
	CDialog::OnInitDialog();

	//---------------------------------------------------
	// LABELS
	//---------------------------------------------------
	CFont *m_Font1 = new CFont;
	m_Font1->CreatePointFont(90, "Arial Bold");	
	m_labelSWH.SetFont(m_Font1); 
	m_labelSWH.SetTextColor(BLUE);

	m_labelGeneration.SetFont(m_Font1); 
	m_labelGeneration.SetTextColor(BLUE);

	m_labelPV.SetFont(m_Font1); 
	m_labelPV.SetTextColor(BLUE);

	m_labelWT.SetFont(m_Font1); 
	m_labelWT.SetTextColor(BLUE);
	
	m_labelCSH1.SetTextColor(RED);
	m_labelCSH2.SetTextColor(RED);
	m_labelCSH3.SetTextColor(RED);

	//---------------------------------------------------
	// DROP DOWN MENUS
	//---------------------------------------------------
	AddStringsToComboBoxesForRenewablesDlg();

	if(file_new_selected ==true)
	{
		SetAllValuesToDefault();		

        //-----------------------------------------------
		// EXPOSURE
		//-----------------------------------------------
		m_btnExposureExposed.SetCheck(1);			
		m_btnExposureAboveAvg.SetCheck(0);		
		m_btnExposureAvg.SetCheck(0);			
		m_btnExposureBelowAvg.SetCheck(0);
		m_btnExposureSheltered.SetCheck(0);		
	}

	DisplayValuesForRenewablesDlg();

	if(isSHWPresent == "No")
	{
		m_comboSHWCollectorType.EnableWindow(FALSE);
		m_comboSHWCollectorOrientation.EnableWindow(FALSE);
		m_comboSHWCollectorTilt.EnableWindow(FALSE);
		m_comboSHWOvershading.EnableWindow(FALSE);
		m_comboSHWGrossArea.EnableWindow(FALSE);
		m_comboSHWSolarStore.EnableWindow(FALSE);
		m_comboSHWSolarCircPump.EnableWindow(FALSE);
		m_editSHWApertureArea.EnableWindow(FALSE);
		m_editSHWZLCollectorEff.EnableWindow(FALSE);
		m_editSHWHLCoeff.EnableWindow(FALSE);
		m_editSHWSolarVolume.EnableWindow(FALSE);
	}
	else
	{
		m_comboSHWCollectorType.EnableWindow(TRUE);
		m_comboSHWCollectorOrientation.EnableWindow(TRUE);
		m_comboSHWCollectorTilt.EnableWindow(TRUE);
		m_comboSHWOvershading.EnableWindow(TRUE);
		m_comboSHWGrossArea.EnableWindow(TRUE);
		m_comboSHWSolarStore.EnableWindow(TRUE);
		m_comboSHWSolarCircPump.EnableWindow(TRUE);
		m_editSHWApertureArea.EnableWindow(TRUE);
		m_editSHWZLCollectorEff.EnableWindow(TRUE);
		m_editSHWHLCoeff.EnableWindow(TRUE);
		m_editSHWSolarVolume.EnableWindow(TRUE);
	}

	//------------------------------------------------
	// Enable or Disable additional alloable controls
	if(isRENAdditionalElectGenerated == "No")
	{
		m_editElecGenerated.EnableWindow(FALSE);
		m_editTFARenewables.EnableWindow(FALSE);
	}
	else
	{
		m_editElecGenerated.EnableWindow(TRUE);
		m_editTFARenewables.EnableWindow(TRUE);
	}

	//------------------------------------------------
	// Enable or Disable PV controls
	if(isPVPresent == "No")
	{
		m_editPVPeakPower.EnableWindow(FALSE);
		m_comboPVCollectorOrientation.EnableWindow(FALSE);
		m_comboPVCollectorTilt.EnableWindow(FALSE);
		m_comboPVOvershading.EnableWindow(FALSE);
	}
	else
	{
		m_editPVPeakPower.EnableWindow(TRUE);
		m_comboPVCollectorOrientation.EnableWindow(TRUE);
		m_comboPVCollectorTilt.EnableWindow(TRUE);
		m_comboPVOvershading.EnableWindow(TRUE);
	}

	//------------------------------------------------
	// Enable or Disable WT controls
	if(isWTPresent == "No")
	{
		m_editWTNumOf.EnableWindow(FALSE);
		m_editWTDiameter.EnableWindow(FALSE);
		m_editWTHeight.EnableWindow(FALSE);
		m_btnExposureExposed.EnableWindow(FALSE);
		m_btnExposureAboveAvg.EnableWindow(FALSE);
		m_btnExposureAvg.EnableWindow(FALSE);
		m_btnExposureBelowAvg.EnableWindow(FALSE);
		m_btnExposureSheltered.EnableWindow(FALSE);
		m_labelExposure.EnableWindow(FALSE);
	}
	else
	{
		m_editWTNumOf.EnableWindow(TRUE);
		m_editWTDiameter.EnableWindow(TRUE);
		m_editWTHeight.EnableWindow(TRUE);
		m_btnExposureExposed.EnableWindow(TRUE);
		m_btnExposureAboveAvg.EnableWindow(TRUE);
		m_btnExposureAvg.EnableWindow(TRUE);
		m_btnExposureBelowAvg.EnableWindow(TRUE);
		m_btnExposureSheltered.EnableWindow(TRUE);
		m_labelExposure.EnableWindow(TRUE);
	}

	return TRUE;
}

void CDlg_Renewables::AddStringsToComboBoxesForRenewablesDlg()
{
	m_comboSHWpresent.InsertString(0,"No");
	m_comboSHWpresent.InsertString(1,"Yes");

	m_comboSHWCollectorType.InsertString(0,"Evacuated tube");
	m_comboSHWCollectorType.InsertString(1,"Flat plate - glazed");
	m_comboSHWCollectorType.InsertString(2,"Unglazed");

	m_comboSHWCollectorOrientation.InsertString(0,"South");
	m_comboSHWCollectorOrientation.InsertString(1,"SE/SW");
	m_comboSHWCollectorOrientation.InsertString(2,"E/W");
	m_comboSHWCollectorOrientation.InsertString(3,"NE/NW");
	m_comboSHWCollectorOrientation.InsertString(4,"North");

	m_comboSHWCollectorTilt.InsertString(0,"Horizontal");
	m_comboSHWCollectorTilt.InsertString(1,"30 deg");
	m_comboSHWCollectorTilt.InsertString(2,"45 deg");
	m_comboSHWCollectorTilt.InsertString(3,"60 deg");
	m_comboSHWCollectorTilt.InsertString(4,"Vertical");

	m_comboSHWOvershading.InsertString(0,"Heavy > 80%");
	m_comboSHWOvershading.InsertString(1,"Significant > 60%-80%");
	m_comboSHWOvershading.InsertString(2,"Modest 20%-60%");
	m_comboSHWOvershading.InsertString(3,"None or Very Little < 20%");

	m_comboSHWGrossArea.InsertString(0,"No");
	m_comboSHWGrossArea.InsertString(1,"Yes");

	m_comboSHWSolarStore.InsertString(0,"No");
	m_comboSHWSolarStore.InsertString(1,"Yes");

	m_comboSHWSolarCircPump.InsertString(0,"No");
	m_comboSHWSolarCircPump.InsertString(1,"Electrically powered");
	m_comboSHWSolarCircPump.InsertString(2,"PV powered");

	m_comboAdditionalElect.InsertString(0,"No");
	m_comboAdditionalElect.InsertString(1,"Yes");

	m_comboPVPresent.InsertString(0,"No");
	m_comboPVPresent.InsertString(1,"Yes");

	m_comboPVCollectorOrientation.InsertString(0,"South");
	m_comboPVCollectorOrientation.InsertString(1,"SE/SW");
	m_comboPVCollectorOrientation.InsertString(2,"E/W");
	m_comboPVCollectorOrientation.InsertString(3,"NE/NW");
	m_comboPVCollectorOrientation.InsertString(4,"North");

	m_comboPVCollectorTilt.InsertString(0,"Horizontal");
	m_comboPVCollectorTilt.InsertString(1,"30 deg");
	m_comboPVCollectorTilt.InsertString(2,"45 deg");
	m_comboPVCollectorTilt.InsertString(3,"60 deg");
	m_comboPVCollectorTilt.InsertString(4,"Vertical");

	m_comboPVOvershading.InsertString(0,"Heavy > 80%");
	m_comboPVOvershading.InsertString(1,"Significant > 60%-80%");
	m_comboPVOvershading.InsertString(2,"Modest 20%-60%");
	m_comboPVOvershading.InsertString(3,"None or Very Little < 20%");
	
	m_comboWTPresent.InsertString(0,"No");
	m_comboWTPresent.InsertString(1,"Yes");
}

void CDlg_Renewables::DisplayValuesForRenewablesDlg()
{
	//-----------------------------------------------
	// EXPOSURE
	//-----------------------------------------------
	
	if (dwellingExposure == "Exposed")
	{
		m_btnExposureExposed.SetCheck(1);
	}
	else if (dwellingExposure == "Above average")
	{
		m_btnExposureAboveAvg.SetCheck(1);
	}
	else if (dwellingExposure == "Average")
	{
		m_btnExposureAvg.SetCheck(1);
	}
	else if (dwellingExposure == "Below average")
	{
		m_btnExposureBelowAvg.SetCheck(1);
	}
	else if (dwellingExposure == "Sheltered")
	{
		m_btnExposureSheltered.SetCheck(1);
	}		

	str_comboSHWpresent.Format("%s",isSHWPresent);
	str_comboSHWCollectorType.Format("%s",SHWCollectorType);
	str_comboSHWCollectorOrientation.Format("%s",SHWCollectorOrientation);
	str_comboSHWCollectorTilt.Format("%s",SHWCollectorTilt);
	str_comboSHWOvershading .Format("%s",SHWOvershading);
	str_comboSHWGrossArea .Format("%s",isSHWAreaGross);

	str_editSHWApertureArea.Format("%.1f",SHWApertureArea);
	str_editSHWZLCollectorEff.Format("%.0f",SHW_ZLCE);
	str_editSHWHLCoeff.Format("%.0f",SHW_HeatLossCoefficient);

	str_comboSHWSolarStore.Format("%s",isSHWSolarStoreCombined);
	str_editSHWSolarVolume.Format("%.0f",SHWDedSolStoreVol);

	str_comboSHWSolarCircPump.Format("%s",SHWSolarCircPump);
	str_comboAdditionalElect.Format("%s",isRENAdditionalElectGenerated);

	str_editElecGenerated.Format("%.1f",RENAddiationalElecGenerated);
	str_editTFARenewables .Format("%.1f",REN_TFA);

	str_comboPVPresent.Format("%s",isPVPresent);
	str_editPVPeakPower.Format("%.0f",installedPVPeakPower);

	str_comboPVCollectorOrientation.Format("%s",PVCollectorOrientation);
	str_comboPVCollectorTilt.Format("%s", PVCollectorTilt);
	str_comboPVOvershading.Format("%s",PVOvershading);
	str_comboWTPresent.Format("%s", isWTPresent);

	str_editWTNumOf.Format("%d",WTNumOf);
	str_editWTDiameter.Format("%.1f",WTDiameter);
	str_editWTHeight.Format("%.1f",WTHeight);

	UpdateData(FALSE);
}

void CDlg_Renewables::ReadInputsFromRenewablesDlg()
{
	UpdateData(TRUE);

	isSHWPresent= str_comboSHWpresent;

	//-----------------------------------------------
	// EXPOSURE
	//-----------------------------------------------
	if( m_btnExposureExposed.GetCheck()==1)
	{
		dwellingExposure = "Exposed";
	}
	else if( m_btnExposureAboveAvg.GetCheck()==1)
	{
		dwellingExposure = "Above average";
	}
	else if( m_btnExposureAvg.GetCheck()==1)
	{
		dwellingExposure = "Average";
	}
	else if( m_btnExposureBelowAvg.GetCheck()==1)
	{
		dwellingExposure = "Below average";
	}
	else if( m_btnExposureSheltered.GetCheck()==1)
	{
		dwellingExposure = "Sheltered";
	}

	//------------------------------------------------
	// Enable or Disable SHW controls
	if(isSHWPresent == "No")
	{
		//-------------------------------------------------------------------
		// These variables correspond to check btton logic in Results window
		//-------------------------------------------------------------------
		//chkSDHW
		//chkPV
		//chkWT
		//chkuCHP
		//chkuHydro
		//chkPCM
		//chkMVHR

		chkSDHW = 0;
		m_comboSHWCollectorType.EnableWindow(FALSE);
		m_comboSHWCollectorOrientation.EnableWindow(FALSE);
		m_comboSHWCollectorTilt.EnableWindow(FALSE);
		m_comboSHWOvershading.EnableWindow(FALSE);
		m_comboSHWGrossArea.EnableWindow(FALSE);
		m_comboSHWSolarStore.EnableWindow(FALSE);
		m_comboSHWSolarCircPump.EnableWindow(FALSE);
		m_editSHWApertureArea.EnableWindow(FALSE);
		m_editSHWZLCollectorEff.EnableWindow(FALSE);
		m_editSHWHLCoeff.EnableWindow(FALSE);
		m_editSHWSolarVolume.EnableWindow(FALSE);
		
	}
	else
	{
		chkSDHW = 1;
		m_comboSHWCollectorType.EnableWindow(TRUE);
		m_comboSHWCollectorOrientation.EnableWindow(TRUE);
		m_comboSHWCollectorTilt.EnableWindow(TRUE);
		m_comboSHWOvershading.EnableWindow(TRUE);
		m_comboSHWGrossArea.EnableWindow(TRUE);
		m_comboSHWSolarStore.EnableWindow(TRUE);
		m_comboSHWSolarCircPump.EnableWindow(TRUE);
		m_editSHWApertureArea.EnableWindow(TRUE);
		m_editSHWZLCollectorEff.EnableWindow(TRUE);
		m_editSHWHLCoeff.EnableWindow(TRUE);
		m_editSHWSolarVolume.EnableWindow(TRUE);
	
	}

	SHWCollectorType = str_comboSHWCollectorType;
	SHWCollectorOrientation = str_comboSHWCollectorOrientation;
	SHWCollectorTilt= str_comboSHWCollectorTilt;
	SHWOvershading = str_comboSHWOvershading;
	isSHWAreaGross = str_comboSHWGrossArea;

	SHWApertureArea = atof(str_editSHWApertureArea);
	SHW_ZLCE = atof(str_editSHWZLCollectorEff);
	SHW_HeatLossCoefficient = atof(str_editSHWHLCoeff);

	isSHWSolarStoreCombined = str_comboSHWSolarStore;
	SHWDedSolStoreVol = atof(str_editSHWSolarVolume);

	SHWSolarCircPump = str_comboSHWSolarCircPump;


	isRENAdditionalElectGenerated = str_comboAdditionalElect;
	
	//------------------------------------------------
	// Enable or Disable additional alloable controls
	if(isRENAdditionalElectGenerated == "No")
	{
		m_editElecGenerated.EnableWindow(FALSE);
		m_editTFARenewables.EnableWindow(FALSE);
	}
	else
	{
		m_editElecGenerated.EnableWindow(TRUE);
		m_editTFARenewables.EnableWindow(TRUE);
	}

	RENAddiationalElecGenerated = atof(str_editElecGenerated);
	REN_TFA = atof(str_editTFARenewables);

	isPVPresent = str_comboPVPresent;

	//------------------------------------------------
	// Enable or Disable PV controls
	if(isPVPresent == "No")
	{
		chkPV = 0;
		m_editPVPeakPower.EnableWindow(FALSE);
		m_comboPVCollectorOrientation.EnableWindow(FALSE);
		m_comboPVCollectorTilt.EnableWindow(FALSE);
		m_comboPVOvershading.EnableWindow(FALSE);
	}
	else
	{
		chkPV = 1;
		m_editPVPeakPower.EnableWindow(TRUE);
		m_comboPVCollectorOrientation.EnableWindow(TRUE);
		m_comboPVCollectorTilt.EnableWindow(TRUE);
		m_comboPVOvershading.EnableWindow(TRUE);
	}

	installedPVPeakPower = atof(str_editPVPeakPower);

	PVCollectorOrientation = str_comboPVCollectorOrientation;
	PVCollectorTilt = str_comboPVCollectorTilt;
	PVOvershading = str_comboPVOvershading;

	//------------------------------------------------
	// Enable or Disable WT controls
	isWTPresent = str_comboWTPresent;
	if(isWTPresent == "No")
	{
		chkWT  = 0;
		m_editWTNumOf.EnableWindow(FALSE);
		m_editWTDiameter.EnableWindow(FALSE);
		m_editWTHeight.EnableWindow(FALSE);
		m_btnExposureExposed.EnableWindow(FALSE);
		m_btnExposureAboveAvg.EnableWindow(FALSE);
		m_btnExposureAvg.EnableWindow(FALSE);
		m_btnExposureBelowAvg.EnableWindow(FALSE);
		m_btnExposureSheltered.EnableWindow(FALSE);
		m_labelExposure.EnableWindow(FALSE);
	}
	else
	{
		chkWT  = 1;
		m_editWTNumOf.EnableWindow(TRUE);
		m_editWTDiameter.EnableWindow(TRUE);
		m_editWTHeight.EnableWindow(TRUE);
		m_btnExposureExposed.EnableWindow(TRUE);
		m_btnExposureAboveAvg.EnableWindow(TRUE);
		m_btnExposureAvg.EnableWindow(TRUE);
		m_btnExposureBelowAvg.EnableWindow(TRUE);
		m_btnExposureSheltered.EnableWindow(TRUE);
		m_labelExposure.EnableWindow(TRUE);
	}
	
	WTNumOf    = atoi(str_editWTNumOf);
	WTDiameter = atof(str_editWTDiameter);
	WTHeight    = atof(str_editWTHeight);
}
void CDlg_Renewables::OnCbnSelchangeComboIsswh()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboShwcollectortype()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboSwhcollectororient()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboShwcollectortilt()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboShwovershading()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboShwgrossarea()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnEnChangeEditShwaperaturearea()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editSHWApertureArea, lpszValidChars) != 0) 
	{
		str_editSHWApertureArea = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
					
	// Check limit
	isCheckRange_SHWApertureArea = true;
}

void CDlg_Renewables::OnEnChangeEditShwzlcollectoreff()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editSHWZLCollectorEff, lpszValidChars) != 0) 
	{
		str_editSHWZLCollectorEff = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
					
	// Check limit
	isCheckRange_SHW_ZLCE = true;	
}

void CDlg_Renewables::OnEnChangeEditShwHlcoeff()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editSHWHLCoeff, lpszValidChars) != 0) 
	{
		str_editSHWHLCoeff = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
					
	// Check limit
	isCheckRange_SHW_HeatLossCoefficient = true;	
}

void CDlg_Renewables::OnEnChangeEditShwvolume()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editSHWSolarVolume, lpszValidChars) != 0) 
	{
		str_editSHWSolarVolume = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
					
	// Check limit
	isCheckRange_SHWDedSolStoreVol  = true;	
}

void CDlg_Renewables::OnEnChangeEditelecgenerated()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editElecGenerated, lpszValidChars) != 0) 
	{
		str_editElecGenerated = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnEnChangeEditTfa()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editTFARenewables, lpszValidChars) != 0) 
	{
		str_editTFARenewables = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnEnChangeEdiiPvpeakpower()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editPVPeakPower, lpszValidChars) != 0) 
	{
		str_editPVPeakPower = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
					
	// Check limit
	isCheckRange_installedPVPeakPower   = true;	
}

void CDlg_Renewables::OnEnChangeEditwtnums()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T("0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editWTNumOf, lpszValidChars) != 0) 
	{
		str_editWTNumOf = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
					
	// Check limit
	isCheckRange_WTNumOf   = true;	
}

void CDlg_Renewables::OnEnChangeEditWtdiameter()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editWTDiameter, lpszValidChars) != 0) 
	{
		str_editWTDiameter = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
						
	// Check limit
	isCheckRange_WTDiameter   = true;	
}

void CDlg_Renewables::OnEnChangeEditWtheight()
{
	//------------------------------------------------------------------------------
	// Empty edit box if user types any character other than numeric characters or '.'
	UpdateData(TRUE);
	static TCHAR * lpszValidChars = _T(".0123456789");
	// szText is the string we want to check for invalid chracters
	if (_tcsspnp(str_editWTHeight, lpszValidChars) != 0) 
	{
		str_editWTHeight = " ";
		UpdateData(FALSE);
		return;
	}
	ReadInputsFromRenewablesDlg();
						
	// Check limit
	isCheckRange_WTHeight    = true;	
}

void CDlg_Renewables::OnCbnSelchangeComboShwissolarstorecombined()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboShwpump()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboShwadditionalgen()
{
	ReadInputsFromRenewablesDlg();
}
void CDlg_Renewables::OnCbnSelchangeComboPvpresent()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboPvcollectororient()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeCombo()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboPvovershading()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnCbnSelchangeComboWtpresent()
{
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnBnClickedRadio20()
{
	m_btnExposureAboveAvg.SetCheck(0);
	m_btnExposureAvg.SetCheck(0);
	m_btnExposureBelowAvg.SetCheck(0);
	m_btnExposureSheltered.SetCheck(0);
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnBnClickedRadio21()
{
	m_btnExposureExposed.SetCheck(0);
	m_btnExposureAvg.SetCheck(0);
	m_btnExposureBelowAvg.SetCheck(0);
	m_btnExposureSheltered.SetCheck(0);
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnBnClickedRadio22()
{
	m_btnExposureExposed.SetCheck(0);
	m_btnExposureAboveAvg.SetCheck(0);
	m_btnExposureBelowAvg.SetCheck(0);
	m_btnExposureSheltered.SetCheck(0);
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnBnClickedRadio23()
{
	m_btnExposureExposed.SetCheck(0);
	m_btnExposureAvg.SetCheck(0);
	m_btnExposureAboveAvg.SetCheck(0);
	m_btnExposureSheltered.SetCheck(0);
	ReadInputsFromRenewablesDlg();
}

void CDlg_Renewables::OnBnClickedRadio24()
{
	m_btnExposureExposed.SetCheck(0);
	m_btnExposureAvg.SetCheck(0);
	m_btnExposureAboveAvg.SetCheck(0);
	m_btnExposureBelowAvg.SetCheck(0);
	ReadInputsFromRenewablesDlg();
}

BOOL CDlg_Renewables::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message==WM_KEYDOWN)
	{
		if(pMsg->wParam==VK_RETURN || pMsg->wParam==VK_ESCAPE)
			pMsg->wParam=NULL ;
	} 

	return CDialog::PreTranslateMessage(pMsg);
}