Index: src/ch/FeedbackNotEnoughSpaceDlg.cpp =================================================================== diff -u -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r3921d82d9605d98b2281f3f42d9f9c8385b89a3e --- src/ch/FeedbackNotEnoughSpaceDlg.cpp (.../FeedbackNotEnoughSpaceDlg.cpp) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/FeedbackNotEnoughSpaceDlg.cpp (.../FeedbackNotEnoughSpaceDlg.cpp) (revision 3921d82d9605d98b2281f3f42d9f9c8385b89a3e) @@ -19,10 +19,10 @@ #include "stdafx.h" #include "ch.h" #include "FeedbackNotEnoughSpaceDlg.h" -#include "btnIDs.h" #include "StringHelpers.h" -#include "..\Common\FileSupport.h" -#include "FeedbackHandler.h" +#include "resource.h" +#include "../libchengine/EFeedbackResult.h" + #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE @@ -32,12 +32,12 @@ ///////////////////////////////////////////////////////////////////////////// // CFeedbackNotEnoughSpaceDlg dialog - -CFeedbackNotEnoughSpaceDlg::CFeedbackNotEnoughSpaceDlg(ull_t ullSizeRequired, const tchar_t* pszSrcPath, const tchar_t* pszDstPath) - :ictranslate::CLanguageDialog(CFeedbackNotEnoughSpaceDlg::IDD), - m_bAllItems(FALSE), +CFeedbackNotEnoughSpaceDlg::CFeedbackNotEnoughSpaceDlg(unsigned long long ullSizeRequired, const wchar_t* pszSrcPath, const wchar_t* pszDstPath) + :ictranslate::CLanguageDialog(IDD_FEEDBACK_NOTENOUGHSPACE_DIALOG), + m_strDisk(pszDstPath), m_ullRequired(ullSizeRequired), - m_strDisk(pszDstPath) + m_bAllItems(FALSE), + m_fsLocal(GetLogFileData()) { m_vstrFiles.push_back(pszSrcPath); } @@ -67,28 +67,61 @@ void CFeedbackNotEnoughSpaceDlg::UpdateDialog() { // format needed text - ictranslate::CFormat fmt(GetResManager()->LoadString(IDS_NERPATH_STRING)); - fmt.SetParam(_t("%path"), m_strDisk); + ictranslate::CFormat fmt(GetResManager().LoadString(IDS_NERPATH_STRING)); + fmt.SetParam(_T("%path"), m_strDisk); CWnd* pWnd=GetDlgItem(IDC_HEADER_STATIC); if (pWnd) - pWnd->SetWindowText(fmt); + pWnd->SetWindowText(fmt.ToString()); // now the sizes - TCHAR szData[128]; pWnd=GetDlgItem(IDC_REQUIRED_STATIC); if (pWnd) - pWnd->SetWindowText(GetSizeString(m_ullRequired, szData, 128)); - ull_t ullFree; + pWnd->SetWindowText(GetSizeString(m_ullRequired)); + + unsigned long long ullFree = 0, ullTotal = 0; pWnd=GetDlgItem(IDC_AVAILABLE_STATIC); - if (pWnd && GetDynamicFreeSpace(m_strDisk, &ullFree, NULL)) - pWnd->SetWindowText(GetSizeString(ullFree, szData, 128)); + if(pWnd) + { + try + { + m_fsLocal.GetDynamicFreeSpace(chcore::PathFromString(m_strDisk), ullFree, ullTotal); + } + catch(const std::exception&) + { + ullFree = 0; + } + pWnd->SetWindowText(GetSizeString(ullFree)); + } } BOOL CFeedbackNotEnoughSpaceDlg::OnInitDialog() { CLanguageDialog::OnInitDialog(); - + + // set dialog icon + HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + SetIcon(hIcon, FALSE); + + AddResizableControl(IDC_HEADER_STATIC, 0.0, 0.0, 1.0, 0.0); + AddResizableControl(IDC_001_STATIC, 0.0, 0.0, 0.0, 0.0); + + AddResizableControl(IDC_FILES_LIST, 0.0, 0.0, 1.0, 1.0); + + AddResizableControl(IDC_003_STATIC, 0.0, 1.0, 0.0, 0.0); + AddResizableControl(IDC_004_STATIC, 0.0, 1.0, 0.0, 0.0); + + AddResizableControl(IDC_REQUIRED_STATIC, 0.0, 1.0, 1.0, 0.0); + AddResizableControl(IDC_AVAILABLE_STATIC, 0.0, 1.0, 1.0, 0.0); + + AddResizableControl(IDC_RETRY_BUTTON, 1.0, 1.0, 0.0, 0.0); + AddResizableControl(IDC_IGNORE_BUTTON, 1.0, 1.0, 0.0, 0.0); + AddResizableControl(IDCANCEL, 1.0, 1.0, 0.0, 0.0); + + AddResizableControl(IDC_ALL_ITEMS_CHECK, 0.0, 1.0, 1.0, 0.0); + + InitializeResizableControls(); + // set to top SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); @@ -99,7 +132,7 @@ // format needed text UpdateDialog(); - SetTimer(1601, 1000, NULL); + SetTimer(1601, 1000, nullptr); return TRUE; } @@ -109,18 +142,27 @@ if (nIDEvent == 1601) { // update free space - ull_t ullFree; CWnd *pWnd=GetDlgItem(IDC_AVAILABLE_STATIC); - if (pWnd && GetDynamicFreeSpace(m_strDisk, &ullFree, NULL)) + if (pWnd) { - TCHAR szData[128]; - pWnd->SetWindowText(GetSizeString(ullFree, szData, 128)); + unsigned long long ullFree = 0; + try + { + unsigned long long ullTotal = 0; + m_fsLocal.GetDynamicFreeSpace(chcore::PathFromString(m_strDisk), ullFree, ullTotal); + } + catch(const std::exception&) + { + ullFree = 0; + } + pWnd->SetWindowText(GetSizeString(ullFree)); + // end dialog if this is enough if (m_ullRequired <= ullFree) { CLanguageDialog::OnTimer(nIDEvent); - EndDialog(ID_RETRY); + EndDialog(chengine::EFeedbackResult::eResult_Retry); } } } @@ -130,20 +172,29 @@ void CFeedbackNotEnoughSpaceDlg::OnRetryButton() { - EndDialog(CFeedbackHandler::eResult_Retry); + UpdateData(TRUE); + EndDialog(chengine::EFeedbackResult::eResult_Retry); } void CFeedbackNotEnoughSpaceDlg::OnIgnoreButton() { - EndDialog(CFeedbackHandler::eResult_Skip); + UpdateData(TRUE); + EndDialog(chengine::EFeedbackResult::eResult_Ignore); } void CFeedbackNotEnoughSpaceDlg::OnLanguageChanged() { UpdateDialog(); } +void CFeedbackNotEnoughSpaceDlg::OnCancel() +{ + UpdateData(TRUE); + EndDialog(chengine::EFeedbackResult::eResult_Cancel); +} + void CFeedbackNotEnoughSpaceDlg::OnBnClickedCancel() { - EndDialog(CFeedbackHandler::eResult_Cancel); + UpdateData(TRUE); + EndDialog(chengine::EFeedbackResult::eResult_Cancel); }