#include "InstalledPage.h"
#include "KeyVar.h"

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

InstalledPage::~InstalledPage()
{
	LayoutInstalled = NULL;
	LbInstalledPath = NULL;
	BtnOpenApp = NULL;
	BtnOpenApp = NULL;
}

void InstalledPage::InitControls()
{
	LayoutInstalled = static_cast<CVerticalLayoutUI*>(m_pm->FindControl(UI_LayoutInstalled));
	LbInstalledPath = static_cast<CLabelUI*>(m_pm->FindControl(UI_LbInstalledPath));
	BtnOpenApp = static_cast<CButtonUI*>(m_pm->FindControl(UI_BtnOpenApp));
	
}

void InstalledPage::InitLanguage()
{
	BtnOpenApp->SetText(CLanguage::GetDuiText(TextType::Btn_OpenApp));
	std::wstring ss = CLanguage::GetText(TextType::Btn_GoToFilesPath) + PathCore::smPath_Install;
	LbInstalledPath->SetText(ss.c_str());
}

void InstalledPage::InitValue()
{

}
void InstalledPage::RefreshInstalledPath(wstring sFolder)
{
	LbInstalledPath->SetToolTipWidth(720);
	//路径超过一定的长度，字符串末尾显示省略号
	if (sFolder.length() > 55)
	{
		wstring str = sFolder.substr(0, 55) + L"...";
		LbInstalledPath->SetToolTip(sFolder.c_str());
		LbInstalledPath->SetText(str.c_str());
	}
	else
	{
		LbInstalledPath->SetToolTip(L"");
		LbInstalledPath->SetText(sFolder.c_str());
	}
	
}