#include "InstallingPage.h"
#define HaveNetColor 0xFF477EDE
#define NoNetColor 0xFFB5B6B8

InstallingPage::InstallingPage(CPaintManagerUI* m_pm)
{
	this->m_pm = m_pm;
	InitControls();
	InitLanguage();
}

InstallingPage::~InstallingPage()
{
	LayoutInstalling = NULL;
	InstallingProgress = NULL;
	pTabSwitch = NULL;
	ConNoNetWork = NULL;
	installNotWork = NULL;
	installingValue = NULL;
	InstallingProgress = NULL;
}

void InstallingPage::InitControls()
{
	LayoutInstalling = static_cast<CVerticalLayoutUI*>(m_pm->FindControl(UI_LayoutInstalling));
	InstallingProgress = static_cast<CProgressUI*>(m_pm->FindControl(UI_InstallingProgress));
	pTabSwitch = static_cast<CTabLayoutUI*>(m_pm->FindControl(UI_tab_switch));
	ConNoNetWork = static_cast<CControlUI*>(m_pm->FindControl(UI_ConNoNetWork));
	installNotWork = static_cast<CLabelUI*>(m_pm->FindControl(UI_installNotWork));
	installingValue = static_cast<CLabelUI*>(m_pm->FindControl(UI_installingValue));

}

void InstallingPage::InitLanguage()
{
	installNotWork->SetText(UIstr(TextType::Text_NoNetwork));
}

CDuiString InstallingPage::UIstr(TextType textType)
{
	CDuiString duiStr(CLanguage::GetText(textType).c_str());
	return duiStr;
}

void InstallingPage::InitValue()
{

}
void InstallingPage::SetProgressValue(int value)
{
	std::wstring progressText = std::to_wstring(value) + L"%";
	installingValue->SetText(progressText.c_str());
	InstallingProgress->SetValue(value);
}

#pragma region UI界面变化

void InstallingPage::NetWorkUI(bool isNet)
{
	if (isNet)
	{
		//有网时，显示有网界面
		ConNoNetWork->SetVisible(false);
		pTabSwitch->SetVisible(true);
		InstallingProgress->SetForeColor(HaveNetColor);
		installNotWork->SetText(CLanguage::GetDuiText(TextType::Text_Installing));
	}
	else
	{
		//断网时，显示断网界面
		ConNoNetWork->SetVisible(true);
		pTabSwitch->SetVisible(false);
		InstallingProgress->SetForeColor(NoNetColor);
		installNotWork->SetText(CLanguage::GetDuiText(TextType::Text_NoNetwork));
	}
}

#pragma endregion
