WndInstall.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #include "CFrameWnd.h"
  2. #pragma region 初始化
  3. void CFrameWnd::InitHomeControls()
  4. {
  5. }
  6. LRESULT CFrameWnd::HomeMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  7. {
  8. LRESULT lRes = 0;
  9. BOOL bHandled1 = TRUE;
  10. if (m_pm.MessageHandler(uMsg, wParam, lParam, lRes)) return lRes;
  11. return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
  12. }
  13. #pragma endregion
  14. /// <summary>
  15. /// 主页控件绑定事件
  16. /// </summary>
  17. void CFrameWnd::NotifyHome(TNotifyUI& msg)
  18. {
  19. CDuiString control = msg.pSender->GetName();
  20. if (msg.sType == _T("click"))
  21. {
  22. //打开路径选择
  23. if (control == UI_BtnTextSelectFolder || control == UI_BtnIconSelectFolder)
  24. {
  25. SetSelectedFolder();
  26. }
  27. if (control == UI_BtnTermsService)
  28. {
  29. GoToLink(TermsOfServiceLink);
  30. }
  31. if (control == UI_BtnPrivacyPolicy)
  32. {
  33. GoToLink(PrivacyPolicyLink);
  34. }
  35. //点击安装按钮
  36. if (control == UI_BtnInstall)
  37. {
  38. Install_Click();
  39. }
  40. //显示隐藏自定义安装路径区域
  41. if (control == UI_CheckInstallSetting || control == UI_Lbicon) {
  42. {
  43. if (control == UI_Lbicon)
  44. {
  45. m_InstallationPage->CheckInstallSetting->SetCheck(!m_InstallationPage->CheckInstallSetting->IsSelected());
  46. }
  47. CustomInstallWndSize(m_InstallationPage->CheckInstallSetting->IsSelected());
  48. }
  49. }
  50. }
  51. }
  52. /// <summary>
  53. /// 用户隐私协议等链接
  54. /// </summary>
  55. void CFrameWnd::GoToLink(std::wstring linkStr)
  56. {
  57. const TCHAR szOperation[] = _T("open");
  58. HINSTANCE hRslt = ShellExecute(NULL, szOperation,linkStr.c_str(), NULL, NULL, SW_SHOWNORMAL);
  59. assert(hRslt > (HINSTANCE)HINSTANCE_ERROR);
  60. }
  61. //点击安装按钮
  62. void CFrameWnd::Install_Click()
  63. {
  64. //收起自定义安装的布局
  65. if (ischeckCustom)
  66. CustomInstallWndSize(!ischeckCustom);
  67. BOOL m_bOnline = NetWorkState::IsNetWorking();
  68. if (m_bOnline)
  69. {
  70. //磁盘是否有足够的空间
  71. if (DiskCore::IsEnoughDisk(PathCore::smPath_Install) == false)
  72. {
  73. MessageBoxWnd::Show(m_hWnd, MessageContentType::DiskNoSpace);
  74. return;
  75. }
  76. //获取本机版本号和网络版本号进行判断,返回是否需要安装产品,true为要安装
  77. m_isCanInstall = GetVersionState();
  78. if (m_isCanInstall)
  79. {
  80. SelectLayout(LayoutType::Installing);
  81. //进度条左下角的文案,包括安装中和断网的提示文案
  82. m_InstallingPage->installNotWork->SetText(CLanguage::GetDuiText(TextType::Text_Installing));
  83. m_InstallingPage->NetWorkUI(m_bOnline);
  84. KillAllTimer();
  85. StartTimer(Timer_Banner_ID);
  86. StartTimer(Timer_Installing_ID);
  87. thread installingThread(Thread_Installing, m_threadData);
  88. installingThread.detach();
  89. }
  90. }
  91. else
  92. {
  93. WaitForNetwork();
  94. m_InstallingPage->NetWorkUI(m_bOnline);
  95. SelectLayout(LayoutType::Installing);
  96. }
  97. }
  98. /// <summary>
  99. /// 选择安装路径
  100. /// </summary>
  101. void CFrameWnd::SetSelectedFolder()
  102. {
  103. wstring sFolder = FolderCore::FolderBrowser(m_hWnd);
  104. if (sFolder.empty() != true && sFolder != L"")
  105. {
  106. if (FolderCore::IsRootDirectoryW(sFolder) == true)
  107. {
  108. sFolder = FolderCore::AddSubFolderFromRootDirW(sFolder, Product::smName_Product);
  109. }
  110. m_InstalledPage->RefreshInstalledPath(sFolder);
  111. PathCore::smPath_Install = sFolder;
  112. m_InstallationPage->EdFilepath->SetText(sFolder.c_str());
  113. }
  114. }
  115. void CFrameWnd::Thread_GetVerstion(ThreadData threadData)
  116. {
  117. threadData.pFrame->m_isCanInstall = threadData.pFrame->GetVersionState();
  118. }
  119. bool CFrameWnd::GetVersionState()
  120. {
  121. ComparVersion comparVersion;
  122. VertionResultType state = comparVersion.GetProductInfo(Product::smName_Product, Product::URI_AppXml);
  123. m_State.m_NetFrameworkType = comparVersion.NetFramework;
  124. m_State.m_VcPlusPlusType = comparVersion.VcPlusPlus;
  125. int stateBtn;
  126. bool result = false;
  127. switch (state)
  128. {
  129. case VertionResultType::None:
  130. result = true;
  131. break;
  132. case VertionResultType::Low:
  133. stateBtn = MessageBoxWnd::Show(m_hWnd, MessageContentType::LowVersion);
  134. result = (stateBtn == IDOK ? true : false);
  135. break;
  136. case VertionResultType::Same:
  137. MessageBoxWnd::Show(m_hWnd, MessageContentType::SameVersion);
  138. result = false;
  139. break;
  140. case VertionResultType::Hight:
  141. MessageBoxWnd::Show(m_hWnd, MessageContentType::HighVertion);
  142. result = false;
  143. break;
  144. default:
  145. break;
  146. }
  147. return result;
  148. }