#include "CFrameWnd.h"
#include"MixpanelScript.h"
void CFrameWnd::InitInstalledControls()
{
	
}


/// <summary>
/// 安装完成界面控件绑定事件
/// </summary>
void CFrameWnd::NotifyInstalled(TNotifyUI& msg)
{
	if (msg.sType == _T("click"))
	{
		if (msg.pSender->GetName() == UI_BtnOpenApp)
		{
			MixpanelScript* mix = new MixpanelScript();
			std::string GUID = mix->GetGUID();
			std::string CPUID = mix->GetCPUID();
			mix->PostData("InstallStatus_Btn_StartSuccess", CPUID, GUID,0);
			OpenApp_Click();
		}

	}
}

LRESULT CFrameWnd::InstalledMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	LRESULT lRes = 0;
	BOOL bHandled1 = TRUE;
	if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes)) return lRes;
	return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
}

 void CFrameWnd::OpenApp_Click()
{
	 if (IsNeedReStartSystem)
	 {
		 ReStartSystem();
		 return;
	 }
	 
	 wstring s = PathCore::smPath_Install + L"\\" + Product::smName_Application;
	 auto histance = ShellExecute(NULL, L"open", s.c_str(), NULL, NULL, SW_SHOWNORMAL);
	 assert(histance > (HINSTANCE)HINSTANCE_ERROR);
	 ::DestroyWindow(m_hWnd);

}

void CFrameWnd::Thread_OpenApp( ThreadData threadData)
{

}

void CFrameWnd::ReStartSystem()
{
	if (IsNeedReStartSystem)
	{
		if (MSGID_OK == MessageBoxWnd::Show(m_hWnd, MessageContentType::ReStartSystem))
		{
			system("shutdown -i -r");
		}
	}
}