| |
1 |
1 |
|
| |
2 |
2 |
|
| |
3 |
3 |
|
| |
4 |
4 |
|
| |
5 |
5 |
|
| |
6 |
6 |
|
| |
7 |
7 |
|
| |
8 |
8 |
|
| |
9 |
9 |
|
| |
10 |
10 |
|
| |
11 |
11 |
|
| |
12 |
12 |
|
| |
13 |
13 |
|
| |
14 |
14 |
|
| |
15 |
15 |
|
| |
16 |
16 |
|
| |
17 |
17 |
|
| |
18 |
18 |
|
| |
19 |
19 |
#include "stdafx.h" |
| |
20 |
20 |
#include <boost/shared_array.hpp> |
|
| |
81 |
80 |
|
| |
82 |
81 |
BEGIN_MESSAGE_MAP(CCustomCopyDlg,ictranslate::CLanguageDialog) |
| |
83 |
82 |
|
| |
84 |
83 |
ON_BN_CLICKED(IDC_ADDDIR_BUTTON, OnAddDirectoryButton) |
| |
85 |
84 |
ON_BN_CLICKED(IDC_ADDFILE_BUTTON, OnAddFilesButton) |
| |
86 |
85 |
ON_BN_CLICKED(IDC_REMOVEFILEFOLDER_BUTTON, OnRemoveButton) |
| |
87 |
86 |
ON_BN_CLICKED(IDC_DESTBROWSE_BUTTON, OnBrowseButton) |
| |
88 |
87 |
ON_BN_CLICKED(IDC_BUFFERSIZES_BUTTON, OnChangebufferButton) |
| |
89 |
88 |
ON_BN_CLICKED(IDC_ADDFILTER_BUTTON, OnAddfilterButton) |
| |
90 |
89 |
ON_BN_CLICKED(IDC_REMOVEFILTER_BUTTON, OnRemovefilterButton) |
| |
91 |
90 |
ON_WM_DESTROY() |
| |
92 |
91 |
ON_BN_CLICKED(IDC_FILTERS_CHECK, OnFiltersCheck) |
| |
93 |
92 |
ON_BN_CLICKED(IDC_STANDARD_CHECK, OnStandardCheck) |
| |
94 |
93 |
ON_BN_CLICKED(IDC_ADVANCED_CHECK, OnAdvancedCheck) |
| |
95 |
94 |
ON_NOTIFY(NM_DBLCLK, IDC_FILTERS_LIST, OnDblclkFiltersList) |
| |
96 |
95 |
ON_LBN_DBLCLK(IDC_BUFFERSIZES_LIST, OnDblclkBuffersizesList) |
| |
97 |
96 |
ON_CBN_EDITCHANGE(IDC_DESTPATH_COMBOBOXEX, OnEditchangeDestpathComboboxex) |
| |
98 |
97 |
ON_BN_CLICKED(IDC_IMPORT_BUTTON, OnImportButton) |
| |
99 |
98 |
ON_BN_CLICKED(IDC_IGNOREFOLDERS_CHECK, OnIgnorefoldersCheck) |
| |
100 |
99 |
ON_BN_CLICKED(IDC_FORCEDIRECTORIES_CHECK, OnForcedirectoriesCheck) |
| |
|
100 |
ON_BN_CLICKED(IDC_EXPORT_BUTTON, OnExportButtonClicked) |
| |
101 |
101 |
|
| |
102 |
102 |
END_MESSAGE_MAP() |
| |
103 |
103 |
|
| |
104 |
104 |
|
| |
105 |
105 |
|
| |
106 |
106 |
BOOL CCustomCopyDlg::OnInitDialog() |
| |
107 |
107 |
{ |
| |
108 |
108 |
CLanguageDialog::OnInitDialog(); |
| |
109 |
109 |
|
| |
110 |
110 |
AddResizableControl(IDC_001_STATIC, 0.0, 0.0, 1.0, 0.0); |
| |
111 |
111 |
AddResizableControl(IDC_FILES_LIST, 0.0, 0.0, 1.0, 0.5); |
| |
112 |
112 |
AddResizableControl(IDC_ADDFILE_BUTTON, 1.0, 0.0, 0.0, 0.0); |
| |
113 |
113 |
AddResizableControl(IDC_ADDDIR_BUTTON, 1.0, 0.0, 0.0, 0.0); |
| |
114 |
114 |
AddResizableControl(IDC_REMOVEFILEFOLDER_BUTTON, 1.0, 0.0, 0.0, 0.0); |
| |
115 |
115 |
AddResizableControl(IDC_IMPORT_BUTTON, 1.0, 0.0, 0.0, 0.0); |
| |
116 |
116 |
|
| |
117 |
117 |
AddResizableControl(IDC_002_STATIC, 0.0, 0.5, 1.0, 0.0); |
| |
118 |
118 |
AddResizableControl(IDC_DESTPATH_COMBOBOXEX, 0.0, 0.5, 1.0, 0.0); |
| |
119 |
119 |
AddResizableControl(IDC_DESTBROWSE_BUTTON, 1.0, 0.5, 0.0, 0.0); |
| |
120 |
120 |
|
|
| |
443 |
443 |
iItem=m_ctlFiles.GetNextSelectedItem(pos); |
| |
444 |
444 |
m_ctlFiles.DeleteItem(iItem); |
| |
445 |
445 |
} |
| |
446 |
446 |
} |
| |
447 |
447 |
} |
| |
448 |
448 |
|
| |
449 |
449 |
void CCustomCopyDlg::OnBrowseButton() |
| |
450 |
450 |
{ |
| |
451 |
451 |
CString strPath; |
| |
452 |
452 |
if (BrowseForFolder(GetResManager().LoadString(IDS_DSTFOLDERBROWSE_STRING), &strPath)) |
| |
453 |
453 |
{ |
| |
454 |
454 |
SetComboPath(strPath); |
| |
455 |
455 |
|
| |
456 |
456 |
} |
| |
457 |
457 |
} |
| |
458 |
458 |
|
| |
459 |
459 |
void CCustomCopyDlg::OnOK() |
| |
460 |
460 |
{ |
| |
461 |
461 |
UpdateData(TRUE); |
| |
462 |
462 |
|
| |
463 |
|
CString strPath; |
| |
464 |
|
m_ctlDstPath.GetWindowText(strPath); |
| |
465 |
|
|
| |
466 |
|
if(strPath.IsEmpty() || m_ctlFiles.GetItemCount() == 0) |
| |
|
463 |
if(!HasBasicTaskData()) |
| |
467 |
464 |
{ |
| |
468 |
465 |
MsgBox(IDS_MISSINGDATA_STRING); |
| |
469 |
466 |
return; |
| |
470 |
467 |
} |
| |
471 |
468 |
|
| |
472 |
|
|
| |
473 |
|
m_tTaskDefinition.ClearSourcePaths(); |
| |
|
469 |
UpdateInternalTaskDefinition(); |
| |
474 |
470 |
|
| |
475 |
|
|
| |
476 |
|
m_tTaskDefinition.SetDestinationPath(chcore::PathFromString(strPath)); |
| |
477 |
|
|
| |
478 |
|
for (int i = 0; i < m_ctlFiles.GetItemCount(); i++) |
| |
479 |
|
{ |
| |
480 |
|
m_tTaskDefinition.AddSourcePath(chcore::PathFromString(m_ctlFiles.GetItemText(i, 0))); |
| |
481 |
|
} |
| |
482 |
|
|
| |
483 |
|
|
| |
484 |
|
m_tTaskDefinition.SetOperationType(m_ctlOperation.GetCurSel() == 0 ? chcore::eOperation_Copy: chcore::eOperation_Move); |
| |
485 |
|
|
| |
486 |
|
|
| |
487 |
|
chcore::SetTaskPropValue<chcore::eTO_ThreadPriority>(m_tTaskDefinition.GetConfiguration(), IndexToPriority(m_ctlPriority.GetCurSel())); |
| |
488 |
|
|
| |
489 |
|
chcore::SetTaskPropValue<chcore::eTO_IgnoreDirectories>(m_tTaskDefinition.GetConfiguration(), (m_bIgnoreFolders != 0)); |
| |
490 |
|
chcore::SetTaskPropValue<chcore::eTO_CreateDirectoriesRelativeToRoot>(m_tTaskDefinition.GetConfiguration(), (m_bForceDirectories != 0)); |
| |
491 |
|
chcore::SetTaskPropValue<chcore::eTO_CreateEmptyFiles>(m_tTaskDefinition.GetConfiguration(), (m_bOnlyCreate != 0)); |
| |
492 |
|
|
| |
493 |
471 |
CLanguageDialog::OnOK(); |
| |
494 |
472 |
} |
| |
495 |
473 |
|
| |
496 |
474 |
void CCustomCopyDlg::SetBuffersizesString() |
| |
497 |
475 |
{ |
| |
498 |
476 |
CRect rcList; |
| |
499 |
477 |
m_ctlBufferSizes.GetWindowRect(&rcList); |
| |
500 |
478 |
rcList.right-=2*GetSystemMetrics(SM_CXEDGE); |
| |
501 |
479 |
|
| |
502 |
480 |
m_ctlBufferSizes.SetColumnWidth(rcList.Width()/3); |
| |
503 |
481 |
|
| |
504 |
482 |
|
| |
505 |
483 |
m_ctlBufferSizes.ResetContent(); |
| |
506 |
484 |
|
| |
507 |
485 |
|
| |
508 |
486 |
TCHAR szSize[64]; |
| |
509 |
487 |
ictranslate::CFormat fmt; |
| |
510 |
488 |
|
| |
511 |
489 |
chcore::TBufferSizes bsSizes; |
| |
512 |
490 |
bsSizes.SetOnlyDefault(chcore::GetTaskPropValue<chcore::eTO_UseOnlyDefaultBuffer>(m_tTaskDefinition.GetConfiguration())); |
|
| |
1041 |
1019 |
|
| |
1042 |
1020 |
ictranslate::CFormat fmt(GetResManager().LoadString(IDS_IMPORTREPORT_STRING)); |
| |
1043 |
1021 |
fmt.SetParam(_t("%count"), uiCount); |
| |
1044 |
1022 |
AfxMessageBox(fmt); |
| |
1045 |
1023 |
} |
| |
1046 |
1024 |
} |
| |
1047 |
1025 |
|
| |
1048 |
1026 |
void CCustomCopyDlg::OnForcedirectoriesCheck() |
| |
1049 |
1027 |
{ |
| |
1050 |
1028 |
UpdateData(TRUE); |
| |
1051 |
1029 |
|
| |
1052 |
1030 |
GetDlgItem(IDC_IGNOREFOLDERS_CHECK)->EnableWindow(!m_bForceDirectories); |
| |
1053 |
1031 |
} |
| |
1054 |
1032 |
|
| |
1055 |
1033 |
void CCustomCopyDlg::OnIgnorefoldersCheck() |
| |
1056 |
1034 |
{ |
| |
1057 |
1035 |
UpdateData(TRUE); |
| |
1058 |
1036 |
|
| |
1059 |
1037 |
GetDlgItem(IDC_FORCEDIRECTORIES_CHECK)->EnableWindow(!m_bIgnoreFolders); |
| |
1060 |
1038 |
} |
| |
|
1039 |
|
| |
|
1040 |
void CCustomCopyDlg::OnExportButtonClicked() |
| |
|
1041 |
{ |
| |
|
1042 |
UpdateData(TRUE); |
| |
|
1043 |
|
| |
|
1044 |
if (!HasBasicTaskData()) |
| |
|
1045 |
{ |
| |
|
1046 |
MsgBox(IDS_MISSINGDATA_STRING); |
| |
|
1047 |
return; |
| |
|
1048 |
} |
| |
|
1049 |
|
| |
|
1050 |
UpdateInternalTaskDefinition(); |
| |
|
1051 |
|
| |
|
1052 |
CFileDialog dlg(FALSE, _T("xml"), _T("Task"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, GetResManager().LoadString(IDS_FLTALLFILTER_STRING)); |
| |
|
1053 |
if (dlg.DoModal() == IDOK) |
| |
|
1054 |
{ |
| |
|
1055 |
CString strError; |
| |
|
1056 |
try |
| |
|
1057 |
{ |
| |
|
1058 |
m_tTaskDefinition.Store(chcore::PathFromString(dlg.GetPathName())); |
| |
|
1059 |
} |
| |
|
1060 |
catch (const std::exception& e) |
| |
|
1061 |
{ |
| |
|
1062 |
strError = e.what(); |
| |
|
1063 |
} |
| |
|
1064 |
|
| |
|
1065 |
if (!strError.IsEmpty()) |
| |
|
1066 |
{ |
| |
|
1067 |
ictranslate::CFormat fmt; |
| |
|
1068 |
fmt.SetFormat(GetResManager().LoadString(IDS_EXPORTING_TASK_FAILED)); |
| |
|
1069 |
fmt.SetParam(_t("%reason"), strError); |
| |
|
1070 |
|
| |
|
1071 |
AfxMessageBox(fmt, MB_OK | MB_ICONERROR); |
| |
|
1072 |
} |
| |
|
1073 |
} |
| |
|
1074 |
} |
| |
|
1075 |
|
| |
|
1076 |
void CCustomCopyDlg::UpdateInternalTaskDefinition() |
| |
|
1077 |
{ |
| |
|
1078 |
CString strDstPath; |
| |
|
1079 |
m_ctlDstPath.GetWindowText(strDstPath); |
| |
|
1080 |
|
| |
|
1081 |
|
| |
|
1082 |
m_tTaskDefinition.ClearSourcePaths(); |
| |
|
1083 |
|
| |
|
1084 |
|
| |
|
1085 |
m_tTaskDefinition.SetDestinationPath(chcore::PathFromString(strDstPath)); |
| |
|
1086 |
|
| |
|
1087 |
for (int i = 0; i < m_ctlFiles.GetItemCount(); i++) |
| |
|
1088 |
{ |
| |
|
1089 |
m_tTaskDefinition.AddSourcePath(chcore::PathFromString(m_ctlFiles.GetItemText(i, 0))); |
| |
|
1090 |
} |
| |
|
1091 |
|
| |
|
1092 |
|
| |
|
1093 |
m_tTaskDefinition.SetOperationType(m_ctlOperation.GetCurSel() == 0 ? chcore::eOperation_Copy : chcore::eOperation_Move); |
| |
|
1094 |
|
| |
|
1095 |
|
| |
|
1096 |
chcore::SetTaskPropValue<chcore::eTO_ThreadPriority>(m_tTaskDefinition.GetConfiguration(), IndexToPriority(m_ctlPriority.GetCurSel())); |
| |
|
1097 |
|
| |
|
1098 |
chcore::SetTaskPropValue<chcore::eTO_IgnoreDirectories>(m_tTaskDefinition.GetConfiguration(), (m_bIgnoreFolders != 0)); |
| |
|
1099 |
chcore::SetTaskPropValue<chcore::eTO_CreateDirectoriesRelativeToRoot>(m_tTaskDefinition.GetConfiguration(), (m_bForceDirectories != 0)); |
| |
|
1100 |
chcore::SetTaskPropValue<chcore::eTO_CreateEmptyFiles>(m_tTaskDefinition.GetConfiguration(), (m_bOnlyCreate != 0)); |
| |
|
1101 |
} |
| |
|
1102 |
|
| |
|
1103 |
bool CCustomCopyDlg::HasBasicTaskData() |
| |
|
1104 |
{ |
| |
|
1105 |
CString strDstPath; |
| |
|
1106 |
m_ctlDstPath.GetWindowText(strDstPath); |
| |
|
1107 |
|
| |
|
1108 |
if (strDstPath.IsEmpty() || m_ctlFiles.GetItemCount() == 0) |
| |
|
1109 |
return false; |
| |
|
1110 |
|
| |
|
1111 |
return true; |
| |
|
1112 |
} |