NeroDlg.cpp 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593
  1. // NeroDlg1.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "NeroDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. CNeroDlg* pDlg;
  12. CNeroDlg::CNeroDlg(CWnd* pParent /*=NULL*/) : CDialog(CNeroDlg::IDD, pParent)
  13. {
  14. m_bFromDir = 0;
  15. m_bDvd = 0;
  16. #ifdef USE_KERNEL_DLL
  17. m_nImgType = FImgtype;
  18. #endif
  19. m_checkphoto1 = 1;
  20. m_checkphoto2 = FALSE;
  21. m_checkphoto3 = FALSE;
  22. m_checkphoto4 = FALSE;
  23. m_checkphoto5 = FALSE;
  24. m_checkphoto6 = FALSE;
  25. m_hThread = NULL;
  26. m_hCtrl = NULL;
  27. pDlg = this;
  28. NowDoingBurn = false;
  29. m_nphotos = 0;
  30. m_nspase = 0;
  31. m_nphotos1 = 0;
  32. m_nspase1 = 0;
  33. m_nphotos2 = 0;
  34. m_nspase2 = 0;
  35. m_nphotos3 = 0;
  36. m_nspase3 = 0;
  37. m_nphotos4 = 0;
  38. m_nspase4 = 0;
  39. m_nphotos5 = 0;
  40. m_nspase5 = 0;
  41. m_nphotos6 = 0;
  42. m_nspase6 = 0;
  43. m_bScale = AfxGetApp()->GetProfileInt(LYFZVERSION, "cutphoto", 1);
  44. m_bDvd = AfxGetApp()->GetProfileInt(LYFZVERSION, "bDvd", 0);
  45. m_checkphoto1 = AfxGetApp()->GetProfileInt(LYFZVERSION, "m_checkphoto1", 1);
  46. m_checkphoto2 = 0;//AfxGetApp()->GetProfileInt (LYFZVERSION, "m_checkphoto2", 0);
  47. m_checkphoto3 = 0;//AfxGetApp()->GetProfileInt (LYFZVERSION, "m_checkphoto3", 0);
  48. m_checkphoto4 = AfxGetApp()->GetProfileInt(LYFZVERSION, "m_checkphoto4", 0);
  49. m_checkphoto5 = AfxGetApp()->GetProfileInt(LYFZVERSION, "m_checkphoto5", 0);
  50. m_checkphoto6 = AfxGetApp()->GetProfileInt(LYFZVERSION, "m_checkphoto6", 0);
  51. }
  52. void CNeroDlg::DoDataExchange(CDataExchange* pDX)
  53. {
  54. CDialog::DoDataExchange(pDX);
  55. //{{AFX_DATA_MAP(CNeroDlg)
  56. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  57. DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
  58. DDX_Radio(pDX, IDC_RADIO3, m_bFromDir);
  59. DDX_Radio(pDX, IDC_RADIO1, m_bDvd);
  60. DDX_Check(pDX, IDC_CHECK1, m_checkphoto1);
  61. DDX_Check(pDX, IDC_CHECK2, m_checkphoto2);
  62. DDX_Check(pDX, IDC_CHECK3, m_checkphoto3);
  63. DDX_Check(pDX, IDC_CHECK4, m_checkphoto4);
  64. DDX_Check(pDX, IDC_CHECK5, m_checkphoto5);
  65. DDX_Check(pDX, IDC_CHECK6, m_checkphoto6);
  66. DDX_Check(pDX, IDC_CHECK7, m_bScale);
  67. //}}AFX_DATA_MAP
  68. }
  69. BEGIN_MESSAGE_MAP(CNeroDlg, CDialog)
  70. //{{AFX_MSG_MAP(CNeroDlg)
  71. ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
  72. ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
  73. ON_BN_CLICKED(IDC_BUTchoosedir, OnBUTchoosedir)
  74. ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
  75. ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
  76. ON_BN_CLICKED(IDC_CHECK3, OnCheck3)
  77. ON_BN_CLICKED(IDC_CHECK4, OnCheck4)
  78. ON_BN_CLICKED(IDC_CHECK5, OnCheck5)
  79. ON_BN_CLICKED(IDC_CHECK6, OnCheck6)
  80. ON_BN_CLICKED(IDC_CHECK7, OnCheck7)
  81. ON_CBN_CLOSEUP(IDC_COMBO1, OnCloseupCombo1)
  82. ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
  83. ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  84. ON_WM_DESTROY()
  85. //}}AFX_MSG_MAP
  86. ON_BN_CLICKED(Btn_ExportToU, OnBnClickedExporttou)
  87. END_MESSAGE_MAP()
  88. // 需要处理分隔符产生的问题;
  89. BOOL CNeroDlg::OnInitDialog()
  90. {
  91. CDialog::OnInitDialog();
  92. m_Progress.SetRange(0, 100);
  93. EnableCtrls();
  94. CString filter = "id='" + m_strOrderNum + "'";
  95. g_sendhead.bsql = 0;
  96. g_sendhead.code[0] = 50; // dindansp,需要处理分隔符产生的问题;
  97. g_sendhead.tabcount = 1;
  98. g_pMainWnd->ProcessChatMessageRequest2(filter);
  99. if (g_bSendOK == 0)
  100. {
  101. return 1;
  102. }
  103. CArray<CStringArray, CStringArray>sparray;
  104. DataToArray(&sparray);
  105. CString str, spname;
  106. CStringArray spnamearray;
  107. for (int i = 0; i < sparray.GetSize(); i++)
  108. {
  109. str = sparray.ElementAt(i).ElementAt(6);
  110. spname = sparray.ElementAt(i).ElementAt(5);
  111. GetNo(str, m_noarray);
  112. }
  113. m_combo1.AddString("1200x1600");
  114. m_combo1.AddString("768x1024");
  115. m_combo1.AddString("600x800");
  116. m_combo1.AddString("480x640");
  117. int pos = AfxGetApp()->GetProfileInt(LYFZVERSION, "cutphotosize", 2);
  118. m_combo1.SetCurSel(pos);
  119. if (m_checkphoto1)OnCheck1();
  120. if (m_checkphoto2)OnCheck2();
  121. if (m_checkphoto3)OnCheck3();
  122. if (m_checkphoto4)OnCheck4();
  123. if (m_checkphoto5)OnCheck5();
  124. if (m_checkphoto6)OnCheck6();
  125. CenterWindow();
  126. return TRUE;
  127. }
  128. bool NERO_CALLBACK_ATTR CNeroDlg::IdleCallback(void *pUserData)
  129. {
  130. static MSG msg;
  131. while (!::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE))
  132. {
  133. if (!AfxGetThread()->PumpMessage())
  134. {
  135. break;
  136. }
  137. }
  138. return false;
  139. }
  140. NeroUserDlgInOut NERO_CALLBACK_ATTR CNeroDlg::UserDialog(void *pUserData, NeroUserDlgInOut type, void *data)
  141. {
  142. switch (type)
  143. {
  144. case DLG_AUTO_INSERT:
  145. return DLG_RETURN_CONTINUE;
  146. break;
  147. case DLG_DISCONNECT_RESTART:
  148. return DLG_RETURN_ON_RESTART;
  149. break;
  150. case DLG_DISCONNECT:
  151. return DLG_RETURN_CONTINUE;
  152. break;
  153. case DLG_AUTO_INSERT_RESTART:
  154. return DLG_RETURN_EXIT;
  155. break;
  156. case DLG_RESTART:
  157. return DLG_RETURN_EXIT;
  158. break;
  159. case DLG_SETTINGS_RESTART:
  160. return DLG_RETURN_CONTINUE;
  161. break;
  162. case DLG_OVERBURN:
  163. return DLG_RETURN_TRUE;
  164. break;
  165. case DLG_AUDIO_PROBLEMS:
  166. return DLG_RETURN_EXIT;
  167. break;
  168. case DLG_FILESEL_IMAGE:
  169. {
  170. // create filter for image files
  171. // create a CFileDialog object.
  172. // usage : CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL,
  173. // DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL,
  174. // CWnd* pParentWnd = NULL );
  175. //
  176. // bOpenFileDialog = TRUE, create a File Open dialog
  177. // lpszDefExt = NULL, do not automatically append a file extension
  178. // dwFlags = OFN_OVERWRITEPROMPT, makes no sense during file open,
  179. // just in case we decide to use File Save later
  180. // szFilter = "Image Files (*.nrg)|*.nrg|All Files (*.*)|*.*||"
  181. // pParentWnd = ((CNeroFiddlesDlg*)pUserData), our current Dialog window is the parent
  182. // user canceled, do not proceed with the burn process
  183. return DLG_BURNIMAGE_CANCEL;
  184. }
  185. break;
  186. case DLG_WAITCD:
  187. {
  188. AfxMessageBox("光盘不为空或类型错误");
  189. return DLG_RETURN_EXIT;
  190. break;
  191. }
  192. default:
  193. break;
  194. }
  195. //
  196. return DLG_RETURN_EXIT;
  197. }
  198. BOOL NERO_CALLBACK_ATTR CNeroDlg::ProgressCallback(void *pUserData, DWORD dwProgressInPercent)
  199. {
  200. ((CNeroDlg*)pUserData)->m_Progress.SetPos(dwProgressInPercent);
  201. return true;
  202. }
  203. BOOL NERO_CALLBACK_ATTR CNeroDlg::AbortedCallback(void *pUserData)
  204. {
  205. return false;
  206. return true;
  207. }
  208. void NERO_CALLBACK_ATTR CNeroDlg::AddLogLine(void *pUserData, NERO_TEXT_TYPE type, const char *text)
  209. {
  210. //((CNeroMFCappDlg*)pUserData)->AppendString("Log line:" +(CString)*text);
  211. return;
  212. }
  213. void NERO_CALLBACK_ATTR CNeroDlg::SetPhaseCallback(void *pUserData, const char *text)
  214. {
  215. return;
  216. }
  217. // 返回文件名;
  218. CString GetFileNameFromPath(CString strFilePath)
  219. {
  220. if ( strFilePath.IsEmpty())
  221. return _T("");
  222. static INT nIndex = 0;
  223. nIndex = strFilePath.ReverseFind(_T('\\'));
  224. if ( nIndex != -1 )
  225. {
  226. strFilePath = strFilePath.Mid(nIndex + 1);
  227. }
  228. nIndex = strFilePath.ReverseFind(_T('.'));
  229. if ( nIndex != -1 )
  230. {
  231. strFilePath = strFilePath.Left(nIndex);
  232. return strFilePath;
  233. }
  234. return _T("");
  235. }
  236. void CNeroDlg::GenSPhoto(CString dir, CStringArray &array, DWORD &nNeedSpase, BOOL bCheckNo)
  237. {
  238. using namespace helper_coffs;
  239. ffsco o;
  240. o.dirs(0);
  241. o.find(LPCSTR(dir), LPCSTR("*.*"));
  242. ffsco::typeT coo;
  243. ffsco::typeT::iterator it;
  244. coo = o.co_file();
  245. CString str;
  246. for (it = coo.begin(); coo.end() != it; it++)
  247. {
  248. str = (*it).c_str();
  249. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  250. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  251. if (str.Right(2) == "ok")continue;
  252. if (bCheckNo)
  253. {
  254. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  255. continue;
  256. }
  257. if (m_bScale)
  258. {
  259. // 客户原片和修好的片,是硬编码,对于多目录的使用有影响!
  260. if (str.Find("客户原片") != -1 || str.Find("\\修好的片") != -1)
  261. {
  262. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) != -1)
  263. {
  264. array.Add(str);
  265. CFile fp;
  266. fp.Open(str, CFile::modeRead);
  267. nNeedSpase += fp.GetLength();
  268. fp.Close();
  269. }
  270. }
  271. else
  272. {
  273. array.Add(str);
  274. CFile fp;
  275. fp.Open(str, CFile::modeRead);
  276. nNeedSpase += fp.GetLength();
  277. fp.Close();
  278. }
  279. }
  280. else
  281. array.Add(str);
  282. }
  283. }
  284. // Generate Samll Photo;
  285. void CNeroDlg::GenSPhoto(CString dir, CString sType, CStringArray &array, CStringArray &dirarray)
  286. {
  287. using namespace helper_coffs;
  288. ffsco o;
  289. o.dirs(1);
  290. o.find(LPCSTR(dir), LPCSTR("*.*"));
  291. ffsco::typeT coo;
  292. ffsco::typeT::iterator it;
  293. coo = o.co_file();
  294. CString str;
  295. for (it = coo.begin(); coo.end() != it; it++)
  296. {
  297. str = (*it).c_str();
  298. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  299. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  300. if (str.Right(2) == "ok")continue;
  301. if (m_bScale && (sType == "(初修)" || sType == "(原片)"))
  302. {
  303. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  304. {
  305. ::CreateDirectory(g_mainpath + "\\temp", NULL);
  306. ::CreateDirectory(g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)", NULL);
  307. CString dir;
  308. dir = g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)\\" + sType;
  309. ::CreateDirectory(dir, NULL);
  310. array.Add(str);
  311. dirarray.Add(dir);
  312. }
  313. }
  314. }
  315. }
  316. int GetChildCount(CString str, CStringArray &array)
  317. {
  318. CString dirname = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  319. int count = array.GetSize();
  320. CString temp;
  321. for (int i = 0; i < array.GetSize(); i++)
  322. {
  323. if (array.ElementAt(i) == str)
  324. count--;
  325. else if (array.ElementAt(i).Find(str) == -1)
  326. count--;
  327. else
  328. {
  329. temp = array.ElementAt(i);
  330. temp = temp.Left(temp.ReverseFind('\\'));
  331. if (temp != str)
  332. count--;
  333. }
  334. }
  335. return count;
  336. }
  337. void CNeroDlg::OnCancel()
  338. {
  339. // TODO: Add extra cleanup here
  340. //printf("Jeff:EndofThread\n\n");
  341. EndofThread(); // Jeff add.
  342. if (NowDoingBurn) //如果正在工作 则不能取消
  343. {
  344. if (m_Burn.NeroBurnOK)
  345. {
  346. CDialog::OnOK();
  347. return;
  348. }
  349. if (m_Burn.NeroWorkError)
  350. {
  351. CDialog::OnCancel();
  352. return;
  353. }
  354. AfxMessageBox("已经开始刻录了,不能中断");
  355. return;
  356. }
  357. CDialog::OnCancel(); //否则取消
  358. }
  359. void CNeroDlg::DoBurnOrNot()
  360. {
  361. m_Burn.NeroAPIInit();
  362. m_Burn.NeroAPIBurn();
  363. }
  364. BOOL CNeroDlg::PreTranslateMessage(MSG* pMsg)
  365. {
  366. return CDialog::PreTranslateMessage(pMsg);
  367. }
  368. void CNeroDlg::EnableCtrls()
  369. {
  370. GetDlgItem(IDC_CHECK1)->EnableWindow(!m_bFromDir);
  371. GetDlgItem(IDC_CHECK2)->EnableWindow(!m_bFromDir);
  372. GetDlgItem(IDC_CHECK3)->EnableWindow(!m_bFromDir);
  373. GetDlgItem(IDC_CHECK4)->EnableWindow(!m_bFromDir);
  374. GetDlgItem(IDC_CHECK5)->EnableWindow(!m_bFromDir);
  375. GetDlgItem(IDC_CHECK6)->EnableWindow(!m_bFromDir);
  376. GetDlgItem(IDC_BUTchoosedir)->EnableWindow(m_bFromDir);
  377. }
  378. void CNeroDlg::OnRadio3()
  379. {
  380. UpdateData();
  381. EnableCtrls();
  382. }
  383. /************************************************************************/
  384. /*
  385. CheckBox:从电脑目录中选取;
  386. */
  387. /************************************************************************/
  388. void CNeroDlg::OnRadio4()
  389. {
  390. OnRadio3();
  391. }
  392. void CNeroDlg::OnBUTchoosedir()
  393. {
  394. CString dir;
  395. GetSavePath(dir);
  396. dir.IsEmpty();
  397. GetDlgItem(IDC_EDIT1)->SetWindowText(dir);
  398. m_photoarray7.RemoveAll();
  399. CString path;
  400. path = dir;
  401. CStringArray dirarray;
  402. CString str;
  403. using namespace helper_coffs;
  404. ffsco o;
  405. o.dirs(1);
  406. o.find(LPCSTR(path), LPCSTR("*.*"));
  407. ffsco::typeT coo;
  408. ffsco::typeT::iterator it;
  409. coo = o.co_dir();
  410. for (it = coo.begin(); coo.end() != it; it++)
  411. {
  412. str = (*it).c_str();
  413. if (FindArray(&dirarray, str) == -1)
  414. {
  415. dirarray.Add(str);
  416. }
  417. }
  418. int i = 0;
  419. for ( i = 0; i < dirarray.GetSize(); i++)
  420. {
  421. using namespace helper_coffs;
  422. ffsco o;
  423. o.dirs(0);
  424. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  425. ffsco::typeT coo;
  426. ffsco::typeT::iterator it;
  427. coo = o.co_file();
  428. for (it = coo.begin(); coo.end() != it; it++)
  429. {
  430. str = (*it).c_str();
  431. m_photoarray7.Add(str);
  432. }
  433. }
  434. if (m_photoarray7.GetSize() == 0)
  435. {
  436. AfxMessageBox("警告:目录中无照片!", MB_ICONSTOP);
  437. }
  438. m_nphotos = m_photoarray7.GetSize();
  439. m_nspase = 0;
  440. for (i = 0; i < m_photoarray7.GetSize(); i++)
  441. {
  442. CFile fp;
  443. if (fp.Open(m_photoarray7.ElementAt(i), CFile::modeRead))
  444. {
  445. m_nspase += fp.GetLength();
  446. fp.Close();
  447. }
  448. }
  449. m_nspase /= (1024 * 1024);
  450. str.Format("照片:%d 占用空间:%dM", m_nphotos, m_nspase);
  451. GetDlgItem(IDC_STATIC7)->SetWindowText(str);
  452. }
  453. void CNeroDlg::OnCheck1() // 客人选中的照片(精修);
  454. {
  455. UpdateData();
  456. if (m_checkphoto1)
  457. {
  458. if (m_photoarray1.GetSize() == 0)
  459. {
  460. INT i = 0;
  461. #ifdef USE_KERNEL_DLL
  462. CString str;
  463. INT nIndex = 0;
  464. DWORD dwReturnSize = 0;
  465. CStringArray AryLoadExtImgpath;
  466. CStringArray AryWithExtImgpath;
  467. CStringArray AryOrderDirectory;
  468. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  469. // 查找精修片目录;
  470. if ( GetOrderImgpathEx(FImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) )
  471. {
  472. m_nImgType = FImgtype;
  473. INT nSize = AryLoadExtImgpath.GetSize();
  474. for ( i = 0; i < nSize; i++ )
  475. {
  476. str = AryLoadExtImgpath.ElementAt(i);
  477. nIndex = str.ReverseFind(_T('\\'));
  478. if ( nIndex != -1)
  479. {
  480. str = str.Mid(nIndex+1);
  481. if (str.ReverseFind(_T('.')) == -1) continue;
  482. if (str.GetAt(0) == 's')continue;
  483. if (str.GetAt(0) == 'm')continue;
  484. m_photoarray1.Add(AryLoadExtImgpath.ElementAt(i));
  485. }
  486. }
  487. }
  488. if ( m_photoarray1.GetSize() == 0 )
  489. {// 精修片目录没有相片,查找初修片目录,以初修代替精修;
  490. m_nImgType = EImgtype;
  491. AfxMessageBox(_T("没有找到精修片,将用初修片替代!"));
  492. AryLoadExtImgpath.RemoveAll();
  493. AryWithExtImgpath.RemoveAll();
  494. AryOrderDirectory.RemoveAll();
  495. if ( GetOrderImgpathEx(EImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) )
  496. {
  497. INT nSize = AryLoadExtImgpath.GetSize();
  498. for ( i = 0; i < nSize; i++ )
  499. {
  500. str = AryLoadExtImgpath.ElementAt(i);
  501. nIndex = str.ReverseFind(_T('\\'));
  502. if ( nIndex != -1)
  503. {
  504. str = str.Mid(nIndex+1);
  505. if (str.ReverseFind(_T('.')) == -1) continue;
  506. if (str.GetAt(0) == 's')continue;
  507. if (str.GetAt(0) == 'm')continue;
  508. // 判断初修片是否是选中的相片;
  509. if ( FindArray(&m_noarray, GetFileNameFromPath(str)) != -1)
  510. m_photoarray1.Add(AryLoadExtImgpath.ElementAt(i));
  511. }
  512. }
  513. }
  514. }
  515. if ( m_photoarray1.GetSize() == 0 )
  516. {// 初修片目录没有相片,查找原片目录,以原片代替精修;
  517. m_nImgType = OImgtype;
  518. AfxMessageBox(_T("没有找到初修片,将用原片替代!"));
  519. AryLoadExtImgpath.RemoveAll();
  520. AryWithExtImgpath.RemoveAll();
  521. AryOrderDirectory.RemoveAll();
  522. if ( GetOrderImgpathEx(OImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) )
  523. {
  524. INT nSize = AryLoadExtImgpath.GetSize();
  525. for ( i = 0; i < nSize; i++ )
  526. {
  527. str = AryLoadExtImgpath.ElementAt(i);
  528. nIndex = str.ReverseFind(_T('\\'));
  529. if ( nIndex != -1)
  530. {
  531. str = str.Mid(nIndex+1);
  532. if (str.ReverseFind(_T('.')) == -1) continue;
  533. if (str.GetAt(0) == 's')continue;
  534. if (str.GetAt(0) == 'm')continue;
  535. // 判断原片是否是选中的相片;
  536. if ( FindArray(&m_noarray, GetFileNameFromPath(str)) != -1)
  537. m_photoarray1.Add(AryLoadExtImgpath.ElementAt(i));
  538. }
  539. }
  540. }
  541. }
  542. #else
  543. CString path;
  544. path = g_path4 + "\\"; // 精修好的片;
  545. path += m_strOrderNum;
  546. path += "\\";
  547. m_realpath = g_path4;
  548. CStringArray dirarray;
  549. CString str;
  550. using namespace helper_coffs;
  551. ffsco o;
  552. o.dirs(1);
  553. o.find(LPCSTR(path), LPCSTR("*.*"));
  554. ffsco::typeT coo;
  555. ffsco::typeT::iterator it;
  556. coo = o.co_dir();
  557. for (it = coo.begin(); coo.end() != it; it++)
  558. {
  559. str = (*it).c_str();
  560. if (FindArray(&dirarray, str) == -1)
  561. {
  562. dirarray.Add(str);
  563. }
  564. }
  565. for ( i = 0; i < dirarray.GetSize(); i++)
  566. {
  567. using namespace helper_coffs;
  568. ffsco o;
  569. o.dirs(0);
  570. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
  571. ffsco::typeT coo;
  572. ffsco::typeT::iterator it;
  573. coo = o.co_file();
  574. for (it = coo.begin(); coo.end() != it; it++)
  575. {
  576. str = (*it).c_str();
  577. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  578. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  579. m_photoarray1.Add(str);
  580. }
  581. }
  582. if (m_photoarray1.GetSize() == 0)
  583. {
  584. AfxMessageBox("没有找到精修片,将用初修片替代!");
  585. path = g_path2 + "\\";
  586. path += m_strOrderNum;
  587. path += "\\";
  588. m_realpath = g_path2;
  589. CStringArray dirarray;
  590. CString str, temp;
  591. using namespace helper_coffs;
  592. ffsco o;
  593. o.dirs(1);
  594. o.find(LPCSTR(path), LPCSTR("*.*"));
  595. ffsco::typeT coo;
  596. ffsco::typeT::iterator it;
  597. coo = o.co_dir();
  598. for (it = coo.begin(); coo.end() != it; it++)
  599. {
  600. str = (*it).c_str();
  601. if (FindArray(&dirarray, str) == -1)
  602. {
  603. dirarray.Add(str);
  604. }
  605. }
  606. for ( i = 0; i < dirarray.GetSize(); i++)
  607. {
  608. using namespace helper_coffs;
  609. ffsco o;
  610. o.dirs(0);
  611. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
  612. ffsco::typeT coo;
  613. ffsco::typeT::iterator it;
  614. coo = o.co_file();
  615. for (it = coo.begin(); coo.end() != it; it++)
  616. {
  617. str = (*it).c_str();
  618. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  619. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  620. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  621. continue;
  622. m_photoarray1.Add(str);
  623. }
  624. }
  625. }
  626. if (m_photoarray1.GetSize() == 0)
  627. {
  628. AfxMessageBox("没有找到初修片,将用原片替代!");
  629. path = g_path1 + "\\";
  630. path += m_strOrderNum;
  631. path += "\\";
  632. m_realpath = g_path1;
  633. CStringArray dirarray;
  634. CString str, temp;
  635. using namespace helper_coffs;
  636. ffsco o;
  637. o.dirs(1);
  638. o.find(LPCSTR(path), LPCSTR("*.*"));
  639. ffsco::typeT coo;
  640. ffsco::typeT::iterator it;
  641. coo = o.co_dir();
  642. for (it = coo.begin(); coo.end() != it; it++)
  643. {
  644. str = (*it).c_str();
  645. if (FindArray(&dirarray, str) == -1)
  646. {
  647. dirarray.Add(str);
  648. }
  649. }
  650. for ( i = 0; i < dirarray.GetSize(); i++)
  651. {
  652. using namespace helper_coffs;
  653. ffsco o;
  654. o.dirs(0);
  655. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.*"));
  656. ffsco::typeT coo;
  657. ffsco::typeT::iterator it;
  658. coo = o.co_file();
  659. for (it = coo.begin(); coo.end() != it; it++)
  660. {
  661. str = (*it).c_str();
  662. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  663. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  664. CString strFileName = GetFileNameFromPath(str);
  665. if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
  666. continue;
  667. m_photoarray1.Add(str);
  668. }
  669. }
  670. }
  671. #endif
  672. // 相片张数;
  673. m_nphotos1 = m_photoarray1.GetSize();
  674. // 相片容量大小;
  675. m_nspase1 = 0;
  676. for (i = 0; i < m_photoarray1.GetSize(); i++)
  677. {
  678. CFile fp;
  679. if (fp.Open(m_photoarray1.ElementAt(i), CFile::modeRead))
  680. {
  681. m_nspase1 += fp.GetLength();
  682. fp.Close();
  683. }
  684. }
  685. m_nspase1temp = m_nspase1;
  686. }
  687. else
  688. {
  689. m_nphotos1 = m_photoarray1.GetSize();
  690. m_nspase1 = m_nspase1temp;
  691. }
  692. }
  693. else
  694. {
  695. m_nphotos1 = 0;
  696. m_nspase1 = 0;
  697. }
  698. CString str;
  699. str.Format(_T("照片:%d 占用空间:%dM"), m_nphotos1, m_nspase1 / (1024 * 1024));
  700. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  701. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  702. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  703. }
  704. void CNeroDlg::OnCheck2() // 顾客选中的相片(初修片)
  705. {
  706. UpdateData();
  707. if (m_checkphoto2)
  708. {
  709. if (m_checkphoto5)
  710. m_checkphoto5 = 0;
  711. UpdateData(false);
  712. OnCheck5();
  713. if (m_photoarray2.GetSize() == 0)
  714. {
  715. CString path;
  716. path = g_path2 + "\\";
  717. path += m_strOrderNum;
  718. path += "\\";
  719. CString str;
  720. if (m_noarray.GetSize() == 0)
  721. {
  722. AfxMessageBox("此单未选片!", MB_ICONINFORMATION);
  723. return;
  724. }
  725. int i = 0;
  726. for ( i = 0; i < m_noarray.GetSize(); i++)
  727. {
  728. str.Format("%s%s.jpg", path, m_noarray.ElementAt(i));
  729. if (PathFileExists(str))
  730. {
  731. m_photoarray2.Add(str);
  732. }
  733. }
  734. if (m_photoarray2.GetSize() == 0)
  735. {
  736. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  737. }
  738. m_nphotos2 = m_photoarray2.GetSize();
  739. m_nspase2 = 0;
  740. for (i = 0; i < m_photoarray2.GetSize(); i++)
  741. {
  742. CFile fp;
  743. if (fp.Open(m_photoarray2.ElementAt(i), CFile::modeRead))
  744. {
  745. m_nspase2 += fp.GetLength();
  746. fp.Close();
  747. }
  748. }
  749. m_nspase2temp = m_nspase2;
  750. }
  751. else
  752. {
  753. m_nphotos2 = m_photoarray2.GetSize();
  754. m_nspase2 = m_nspase2temp;
  755. }
  756. }
  757. else
  758. {
  759. m_nphotos2 = 0;
  760. m_nspase2 = 0;
  761. }
  762. CString str;
  763. str.Format("照片:%d 占用空间:%dM", m_nphotos2, m_nspase2 / (1024 * 1024));
  764. GetDlgItem(IDC_STATIC2)->SetWindowText(str);
  765. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  766. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  767. }
  768. void CNeroDlg::OnCheck3() // 顾客选中的相片(原片)
  769. {
  770. }
  771. /************************************************************************/
  772. /*
  773. CheckBox:全部原片;
  774. */
  775. /************************************************************************/
  776. void CNeroDlg::OnCheck4() // 全部原片;
  777. {
  778. UpdateData();
  779. if (m_checkphoto4)
  780. {
  781. if (m_photoarray4.GetSize() == 0)
  782. {
  783. INT i = 0;
  784. #ifdef USE_KERNEL_DLL
  785. CString str;
  786. INT nIndex = 0;
  787. DWORD dwReturnSize = 0;
  788. CStringArray AryLoadExtImgpath;
  789. CStringArray AryWithExtImgpath;
  790. CStringArray AryOrderDirectory;
  791. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  792. // 查找原片目录;
  793. if ( GetOrderImgpathEx(OImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) )
  794. {
  795. INT nSize = AryLoadExtImgpath.GetSize();
  796. for ( i = 0; i < nSize; i++ )
  797. {
  798. str = AryLoadExtImgpath.ElementAt(i);
  799. nIndex = str.ReverseFind(_T('\\'));
  800. if ( nIndex != -1)
  801. {
  802. str = str.Mid(nIndex+1);
  803. if (str.ReverseFind(_T('.')) == -1) continue;
  804. if (str.GetAt(0) == 's')continue;
  805. if (str.GetAt(0) == 'm')continue;
  806. m_photoarray4.Add(AryLoadExtImgpath.ElementAt(i));
  807. }
  808. }
  809. }
  810. #else
  811. CString path;
  812. path = g_path1 + "\\";
  813. path += m_strOrderNum;
  814. path += "\\";
  815. CStringArray dirarray;
  816. CString str;
  817. using namespace helper_coffs;
  818. ffsco o;
  819. o.dirs(1);
  820. o.find(LPCSTR(path), LPCSTR("*.*"));
  821. ffsco::typeT coo;
  822. ffsco::typeT::iterator it;
  823. coo = o.co_dir();
  824. for (it = coo.begin(); coo.end() != it; it++)
  825. {
  826. str = (*it).c_str();
  827. if (FindArray(&dirarray, str) == -1)
  828. {
  829. dirarray.Add(str);
  830. }
  831. }
  832. for ( i = 0; i < dirarray.GetSize(); i++)
  833. {
  834. using namespace helper_coffs;
  835. ffsco o;
  836. o.dirs(0);
  837. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  838. ffsco::typeT coo;
  839. ffsco::typeT::iterator it;
  840. coo = o.co_file();
  841. for (it = coo.begin(); coo.end() != it; it++)
  842. {
  843. str = (*it).c_str();
  844. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  845. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  846. m_photoarray4.Add(str);
  847. }
  848. }
  849. #endif
  850. if (m_photoarray4.GetSize() == 0)
  851. {
  852. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  853. }
  854. m_nphotos4 = m_photoarray4.GetSize();
  855. m_nspase4 = 0;
  856. for (i = 0; i < m_photoarray4.GetSize(); i++)
  857. {
  858. CFile fp;
  859. if (fp.Open(m_photoarray4.ElementAt(i), CFile::modeRead))
  860. {
  861. m_nspase4 += fp.GetLength();
  862. fp.Close();
  863. }
  864. }
  865. m_nspase4temp = m_nspase4;
  866. }
  867. else
  868. {
  869. m_nphotos4 = m_photoarray4.GetSize();
  870. m_nspase4 = m_nspase4temp;
  871. }
  872. }
  873. else
  874. {
  875. m_nphotos4 = 0;
  876. m_nspase4 = 0;
  877. }
  878. CString str;
  879. str.Format("照片:%d 占用空间:%dM", m_nphotos4, m_nspase4 / (1024 * 1024));
  880. GetDlgItem(IDC_STATIC4)->SetWindowText(str);
  881. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  882. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  883. }
  884. /************************************************************************/
  885. /*
  886. CheckBox:全部初修片;
  887. */
  888. /************************************************************************/
  889. void CNeroDlg::OnCheck5() // 全部初修片;
  890. {
  891. UpdateData();
  892. if (m_checkphoto5)
  893. {
  894. if (m_photoarray5.GetSize() == 0)
  895. {
  896. INT i = 0;
  897. #ifdef USE_KERNEL_DLL
  898. CString str;
  899. INT nIndex = 0;
  900. DWORD dwReturnSize = 0;
  901. CStringArray AryLoadExtImgpath;
  902. CStringArray AryWithExtImgpath;
  903. CStringArray AryOrderDirectory;
  904. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  905. // 查找初修片目录;
  906. if ( GetOrderImgpathEx(EImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) )
  907. {
  908. INT nSize = AryLoadExtImgpath.GetSize();
  909. for ( i = 0; i < nSize; i++ )
  910. {
  911. str = AryLoadExtImgpath.ElementAt(i);
  912. nIndex = str.ReverseFind(_T('\\'));
  913. if ( nIndex != -1)
  914. {
  915. str = str.Mid(nIndex+1);
  916. if (str.ReverseFind(_T('.')) == -1) continue;
  917. if (str.GetAt(0) == 's')continue;
  918. if (str.GetAt(0) == 'm')continue;
  919. m_photoarray5.Add(AryLoadExtImgpath.ElementAt(i));
  920. }
  921. }
  922. }
  923. #else
  924. CString path;
  925. path = g_path2 + "\\";
  926. path += m_strOrderNum;
  927. path += "\\";
  928. CStringArray dirarray;
  929. CString str;
  930. using namespace helper_coffs;
  931. ffsco o;
  932. o.dirs(1);
  933. o.find(LPCSTR(path), LPCSTR("*.*"));
  934. ffsco::typeT coo;
  935. ffsco::typeT::iterator it;
  936. coo = o.co_dir();
  937. for (it = coo.begin(); coo.end() != it; it++)
  938. {
  939. str = (*it).c_str();
  940. if (FindArray(&dirarray, str) == -1)
  941. {
  942. dirarray.Add(str);
  943. }
  944. }
  945. for ( i = 0; i < dirarray.GetSize(); i++)
  946. {
  947. using namespace helper_coffs;
  948. ffsco o;
  949. o.dirs(0);
  950. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  951. ffsco::typeT coo;
  952. ffsco::typeT::iterator it;
  953. coo = o.co_file();
  954. for (it = coo.begin(); coo.end() != it; it++)
  955. {
  956. str = (*it).c_str();
  957. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  958. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  959. m_photoarray5.Add(str);
  960. }
  961. }
  962. #endif
  963. if (m_photoarray5.GetSize() == 0)
  964. {
  965. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  966. }
  967. m_nphotos5 = m_photoarray5.GetSize();
  968. m_nspase5 = 0;
  969. for (i = 0; i < m_photoarray5.GetSize(); i++)
  970. {
  971. CFile fp;
  972. if (fp.Open(m_photoarray5.ElementAt(i), CFile::modeRead))
  973. {
  974. m_nspase5 += fp.GetLength();
  975. fp.Close();
  976. }
  977. }
  978. m_nspase5temp = m_nspase5;
  979. }
  980. else
  981. {
  982. m_nphotos5 = m_photoarray5.GetSize();
  983. m_nspase5 = m_nspase5temp;
  984. }
  985. }
  986. else
  987. {
  988. m_nphotos5 = 0;
  989. m_nspase5 = 0;
  990. }
  991. CString str;
  992. str.Format("照片:%d 占用空间:%dM", m_nphotos5, m_nspase5 / (1024 * 1024));
  993. GetDlgItem(IDC_STATIC5)->SetWindowText(str);
  994. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  995. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  996. }
  997. /************************************************************************/
  998. /*
  999. CheckBox:全部设计片;
  1000. */
  1001. /************************************************************************/
  1002. void CNeroDlg::OnCheck6() // 全部设计片;
  1003. {
  1004. UpdateData();
  1005. if (m_checkphoto6)
  1006. {
  1007. if (m_photoarray6.GetSize() == 0)
  1008. {
  1009. INT i = 0;
  1010. #ifdef USE_KERNEL_DLL
  1011. CString str;
  1012. INT nIndex = 0;
  1013. DWORD dwReturnSize = 0;
  1014. CStringArray AryLoadExtImgpath;
  1015. CStringArray AryWithExtImgpath;
  1016. CStringArray AryOrderDirectory;
  1017. CString strBranchId = g_branchname.IsEmpty() ? g_domain : GetDomainFromBranch(g_branchname);
  1018. // 查找初修片目录;
  1019. if ( GetOrderImgpathEx(DImgtype, strBranchId, m_strOrderNum, TRUE, _T("*.*"), _T(""), AryLoadExtImgpath, AryWithExtImgpath, AryOrderDirectory) )
  1020. {
  1021. INT nSize = AryLoadExtImgpath.GetSize();
  1022. for ( i = 0; i < nSize; i++ )
  1023. {
  1024. str = AryLoadExtImgpath.ElementAt(i);
  1025. nIndex = str.ReverseFind(_T('\\'));
  1026. if ( nIndex != -1)
  1027. {
  1028. str = str.Mid(nIndex+1);
  1029. if (str.ReverseFind(_T('.')) == -1) continue;
  1030. if (str.GetAt(0) == 's')continue;
  1031. if (str.GetAt(0) == 'm')continue;
  1032. m_photoarray6.Add(AryLoadExtImgpath.ElementAt(i));
  1033. }
  1034. }
  1035. }
  1036. #else
  1037. CString path;
  1038. path = g_path3 + "\\";
  1039. path += m_strOrderNum;
  1040. path += "\\";
  1041. CStringArray dirarray;
  1042. CString str;
  1043. using namespace helper_coffs;
  1044. ffsco o;
  1045. o.dirs(1);
  1046. o.find(LPCSTR(path), LPCSTR("*.*"));
  1047. ffsco::typeT coo;
  1048. ffsco::typeT::iterator it;
  1049. coo = o.co_dir();
  1050. for (it = coo.begin(); coo.end() != it; it++)
  1051. {
  1052. str = (*it).c_str();
  1053. if (FindArray(&dirarray, str) == -1)
  1054. {
  1055. dirarray.Add(str);
  1056. }
  1057. }
  1058. for ( i = 0; i < dirarray.GetSize(); i++)
  1059. {
  1060. using namespace helper_coffs;
  1061. ffsco o;
  1062. o.dirs(0);
  1063. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  1064. ffsco::typeT coo;
  1065. ffsco::typeT::iterator it;
  1066. coo = o.co_file();
  1067. for (it = coo.begin(); coo.end() != it; it++)
  1068. {
  1069. str = (*it).c_str();
  1070. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  1071. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  1072. m_photoarray6.Add(str);
  1073. }
  1074. }
  1075. #endif
  1076. if (m_photoarray6.GetSize() == 0)
  1077. {
  1078. AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
  1079. }
  1080. m_nphotos6 = m_photoarray6.GetSize();
  1081. m_nspase6 = 0;
  1082. for (i = 0; i < m_photoarray6.GetSize(); i++)
  1083. {
  1084. CFile fp;
  1085. if (fp.Open(m_photoarray6.ElementAt(i), CFile::modeRead))
  1086. {
  1087. m_nspase6 += fp.GetLength();
  1088. fp.Close();
  1089. }
  1090. }
  1091. m_nspase6temp = m_nspase6;
  1092. }
  1093. else
  1094. {
  1095. m_nphotos6 = m_photoarray6.GetSize();
  1096. m_nspase6 = m_nspase6temp;
  1097. }
  1098. }
  1099. else
  1100. {
  1101. m_nphotos6 = 0;
  1102. m_nspase6 = 0;
  1103. }
  1104. CString str;
  1105. str.Format("照片:%d 占用空间:%dM", m_nphotos6, m_nspase6 / (1024 * 1024));
  1106. GetDlgItem(IDC_STATIC6)->SetWindowText(str);
  1107. m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
  1108. m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
  1109. }
  1110. //-----------------------------------------------------------------
  1111. // remark by Jeff 2014-12-12
  1112. // 函数:GetNo
  1113. // 描述:从str中解析出每个相片名,然后存入空的CStringArray中;
  1114. // 参数:
  1115. // str:选好的相片名串,如:"001,002,003" 后分隔符改为"|",结果应是"001|002|003"
  1116. // array:空的数组,用来存放解析后的相片名;
  1117. // 返回:
  1118. // 注意:更换分隔符造成的问题,在该函数已解决;
  1119. //-----------------------------------------------------------------
  1120. void CNeroDlg::GetNo(CString str, CStringArray &array)
  1121. {
  1122. if (!str.IsEmpty())
  1123. {
  1124. #ifdef USE_SEP_VEB
  1125. int pos = str.Find(SEPS_VEB);
  1126. #else
  1127. int pos = str.Find(",");
  1128. #endif
  1129. while (pos != -1)
  1130. {
  1131. if (FindArray(&array, str.Left(pos)) == -1)
  1132. array.Add(str.Left(pos));
  1133. str = str.Right(str.GetLength() - pos - 1);
  1134. #ifdef USE_SEP_VEB
  1135. pos = str.Find(SEPS_VEB);
  1136. #else
  1137. pos = str.Find(",");
  1138. #endif
  1139. }
  1140. if (FindArray(&array, str) == -1)
  1141. array.Add(str);
  1142. }
  1143. }
  1144. extern bool SleepEx(DWORD dwMilliseconds);
  1145. void CNeroDlg::OnOK() // 开始刻录;
  1146. {
  1147. #ifdef USE_KERNEL_DLL
  1148. UpdateData();
  1149. // 刻录原片权限判断;
  1150. if ( m_checkphoto4 ){
  1151. if ( !IsHasRights2new(54) ){
  1152. AfxMessageBox(_T("没有刻录原片权限,请联系管理员!"));
  1153. return;
  1154. }
  1155. }
  1156. // 刻录初修片权限判断;
  1157. if ( m_checkphoto5 ){
  1158. if ( !IsHasRights2new(55) ){
  1159. AfxMessageBox(_T("没有刻录初修片权限,请联系管理员!"));
  1160. return;
  1161. }
  1162. }
  1163. // 如果是压缩图片,需要创建temp目录,且g_mainpath需要有足够的空间;
  1164. if ( m_bScale ){
  1165. // 删除DBServer.exe目录下的temp目录;
  1166. DeleteDirectory(g_mainpath + _T("\\temp"));
  1167. if ( !CheckDiskSpase() )
  1168. return;
  1169. CreateDirectory(g_mainpath + _T("\\temp"), NULL);
  1170. }
  1171. if (m_nphotos == 0){
  1172. AfxMessageBox(_T("未选中照片!"), MB_ICONSTOP);
  1173. return;
  1174. }
  1175. if (m_nspase > 650 && m_bDvd == 0 && m_bScale == 0){
  1176. AfxMessageBox(_T("光盘空间不足!"), MB_ICONSTOP);
  1177. return;
  1178. }
  1179. GetDlgItem(IDOK)->SetWindowText(_T("刻录中, 请稍候..."));
  1180. GetDlgItem(IDOK)->EnableWindow(0);
  1181. if (NowDoingBurn){
  1182. OutputDebugString(_T("正在刻录!\n"));
  1183. return;
  1184. }
  1185. m_Burn.m_strCustomerInfo = m_strCustomerInfo;
  1186. if ( m_bFromDir ){// 由本机目录刻录,且相片从不压缩;
  1187. CString strdir;
  1188. GetDlgItemText(IDC_EDIT1, strdir);
  1189. strdir.TrimRight(_T('\\'));
  1190. // 获取该目录所有相片;
  1191. using namespace helper_coffs;
  1192. ffsco o;
  1193. o.dirs(1);
  1194. o.find(LPCSTR(strdir), LPCSTR("*.*"));
  1195. ffsco::typeT coo;
  1196. ffsco::typeT::iterator it;
  1197. coo = o.co_file();
  1198. NERO_ISO_ITEM *pItem = NULL;
  1199. CString strName = strdir.Mid(strdir.ReverseFind(_T('\\')) + 1);
  1200. if ( coo.size() )
  1201. {
  1202. if( m_Burn.GetDiscItem() == NULL)
  1203. {
  1204. pItem = m_Burn.AddSiblingRootItem(strName, TRUE);
  1205. }
  1206. }
  1207. CString strfile;
  1208. CString strLast = _T("");
  1209. strName = strdir.Left(strdir.ReverseFind(_T('\\')));
  1210. for ( it = coo.begin(); it != coo.end(); it++ )
  1211. {
  1212. // 获取文件目录;
  1213. strfile = it->c_str();
  1214. // 去除根目录;
  1215. strfile.Delete(0, strName.GetLength() + 1);
  1216. strfile = strfile.Left(strfile.ReverseFind(_T('\\')));
  1217. if ( strfile == strLast )
  1218. {
  1219. m_Burn.AddFile2SiblingItem(pItem, it->c_str());
  1220. }
  1221. else
  1222. {
  1223. strLast = strfile;
  1224. pItem = m_Burn.AddFile2Path(strfile, it->c_str());
  1225. }
  1226. }
  1227. }
  1228. else{// 服务器的订单目录;
  1229. INT nIndex = 0;
  1230. NERO_ISO_ITEM* pItem = NULL;
  1231. CString strLastName = _T("");
  1232. CString strFilePath = _T("");
  1233. if ( m_checkphoto1 ){// 如果勾选了精修,且相片从不压缩;
  1234. if ( m_photoarray1.GetSize() ){
  1235. pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("精修"), TRUE);
  1236. if ( pItem )
  1237. {// 成功添加根目录后,开始添加子文件;
  1238. for ( INT i = 0; i < m_photoarray1.GetSize(); i++ )
  1239. {
  1240. strFilePath = m_photoarray1.ElementAt(i);
  1241. nIndex = strFilePath.Find(m_strOrderNum);
  1242. if ( nIndex != -1 )
  1243. {
  1244. strFilePath = strFilePath.Mid(nIndex + m_strOrderNum.GetLength() + 1); // 不安全的隐患;
  1245. nIndex = strFilePath.ReverseFind(_T('\\'));
  1246. if ( nIndex != -1 )
  1247. {// 修片不进入,因无景点名;
  1248. strFilePath = m_strOrderNum + _T("精修\\") + strFilePath.Left(nIndex);
  1249. }
  1250. else
  1251. {
  1252. strFilePath = m_strOrderNum + _T("精修\\");
  1253. }
  1254. if ( strLastName == strFilePath )
  1255. {
  1256. pItem = m_Burn.AddFile2SiblingItem(pItem, m_photoarray1.ElementAt(i));
  1257. }
  1258. else
  1259. {
  1260. pItem = m_Burn.AddFile2Path(strFilePath, m_photoarray1.ElementAt(i));
  1261. strLastName = strFilePath;
  1262. }
  1263. }
  1264. }
  1265. }
  1266. }
  1267. }
  1268. if ( m_checkphoto4 ){// 如果勾选了原片;(勾选压缩未选的片,作用)
  1269. if ( m_photoarray4.GetSize() ){
  1270. pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("原片"), TRUE);
  1271. if ( pItem )
  1272. {// 成功添加根目录后,开始添加子文件;
  1273. for ( INT i = 0; i < m_photoarray4.GetSize(); i++ )
  1274. {
  1275. strFilePath = m_photoarray4.ElementAt(i);
  1276. nIndex = strFilePath.Find(m_strOrderNum);
  1277. if ( nIndex != -1 )
  1278. {
  1279. strFilePath = strFilePath.Mid(nIndex + m_strOrderNum.GetLength() + 1); // 不安全的隐患;
  1280. nIndex = strFilePath.ReverseFind(_T('\\'));
  1281. if ( nIndex != -1 )
  1282. {// 修片不进入,因无景点名;
  1283. strFilePath = m_strOrderNum + _T("原片\\") + strFilePath.Left(nIndex);
  1284. }
  1285. else
  1286. {
  1287. strFilePath = m_strOrderNum + _T("原片\\");
  1288. }
  1289. if ( strLastName == strFilePath )
  1290. {
  1291. pItem = m_Burn.AddFile2SiblingItem(pItem, m_photoarray4.ElementAt(i));
  1292. }
  1293. else
  1294. {
  1295. pItem = m_Burn.AddFile2Path(strFilePath, m_photoarray4.ElementAt(i));
  1296. strLastName = strFilePath;
  1297. }
  1298. }
  1299. }
  1300. }
  1301. }
  1302. }
  1303. if ( m_checkphoto5 ){// 如果勾选了初修;(勾选压缩未选的片,作用)
  1304. if ( m_photoarray5.GetSize() ){
  1305. pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("初修"), TRUE);
  1306. if ( pItem )
  1307. {// 成功添加根目录后,开始添加子文件;
  1308. for ( INT i = 0; i < m_photoarray5.GetSize(); i++ )
  1309. {
  1310. strFilePath = m_photoarray5.ElementAt(i);
  1311. nIndex = strFilePath.Find(m_strOrderNum);
  1312. if ( nIndex != -1 )
  1313. {
  1314. strFilePath = strFilePath.Mid(nIndex + m_strOrderNum.GetLength() + 1); // 不安全的隐患;
  1315. nIndex = strFilePath.ReverseFind(_T('\\'));
  1316. if ( nIndex != -1 )
  1317. {// 修片不进入,因无景点名;
  1318. strFilePath = m_strOrderNum + _T("初修\\") + strFilePath.Left(nIndex);
  1319. }
  1320. else
  1321. {
  1322. strFilePath = m_strOrderNum + _T("初修\\");
  1323. }
  1324. if ( strLastName == strFilePath )
  1325. {
  1326. pItem = m_Burn.AddFile2SiblingItem(pItem, m_photoarray5.ElementAt(i));
  1327. }
  1328. else
  1329. {
  1330. pItem = m_Burn.AddFile2Path(strFilePath, m_photoarray5.ElementAt(i));
  1331. strLastName = strFilePath;
  1332. }
  1333. }
  1334. }
  1335. }
  1336. }
  1337. }
  1338. if ( m_checkphoto6 ){// 如果勾选了设计;(勾选压缩未选的片,不起作用)
  1339. if ( m_photoarray6.GetSize() ){
  1340. pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("设计"), TRUE);
  1341. if ( pItem )
  1342. {// 成功添加根目录后,开始添加子文件;
  1343. for ( INT i = 0; i < m_photoarray6.GetSize(); i++ )
  1344. {
  1345. strFilePath = m_photoarray6.ElementAt(i);
  1346. nIndex = strFilePath.Find(m_strOrderNum);
  1347. if ( nIndex != -1 )
  1348. {
  1349. strFilePath = strFilePath.Mid(nIndex + m_strOrderNum.GetLength() + 1); // 不安全的隐患;
  1350. nIndex = strFilePath.ReverseFind(_T('\\'));
  1351. if ( nIndex != -1 )
  1352. {// 修片不进入,因无景点名;
  1353. strFilePath = m_strOrderNum + _T("设计\\") + strFilePath.Left(nIndex);
  1354. }
  1355. else
  1356. {
  1357. strFilePath = m_strOrderNum + _T("设计\\");
  1358. }
  1359. if ( strLastName == strFilePath )
  1360. {
  1361. pItem = m_Burn.AddFile2SiblingItem(pItem, m_photoarray6.ElementAt(i));
  1362. }
  1363. else
  1364. {
  1365. pItem = m_Burn.AddFile2Path(strFilePath, m_photoarray6.ElementAt(i));
  1366. strLastName = strFilePath;
  1367. }
  1368. }
  1369. }
  1370. }
  1371. }
  1372. }
  1373. if ( m_bScale )
  1374. {// 压缩未选的原片和初修片;若原片与初修有相同相片,以初修为主;
  1375. // 获取m_photoarray5和m_photoarray4中公共未选的相片,压缩出来并重新添加;
  1376. ImgCopyInterface *pCopyImg = NULL;
  1377. g_pIMGProcess->QueryInterface(IID_ImgCopyInterface, (void**)&pCopyImg);
  1378. if ( pCopyImg )
  1379. {
  1380. pCopyImg->Release();
  1381. DWORD dwCopyPIX = 0;
  1382. int pos=m_combo1.GetCurSel();
  1383. if(pos==0)
  1384. {
  1385. dwCopyPIX = SET_PIX(1200, 1600);
  1386. }
  1387. else if(pos==1)
  1388. {
  1389. dwCopyPIX = SET_PIX(768, 1024);
  1390. }
  1391. else if(pos==2)
  1392. {
  1393. dwCopyPIX = SET_PIX(600, 800);
  1394. }
  1395. else
  1396. {
  1397. dwCopyPIX = SET_PIX(480, 640);
  1398. }
  1399. INT i = 0;
  1400. INT nSize = m_photoarray4.GetSize();
  1401. for ( i = 0; i < nSize; i++ )
  1402. {
  1403. if ( FindArray(&m_noarray, GetFileNameFromPath(m_photoarray4.ElementAt(i))) == -1 )
  1404. {
  1405. m_photoarray8.Add(m_photoarray4.ElementAt(i));
  1406. }
  1407. }
  1408. nSize = m_photoarray5.GetSize();
  1409. for ( i = 0; i < nSize; i++ )
  1410. {
  1411. if ( FindArray(&m_noarray, GetFileNameFromPath(m_photoarray5.ElementAt(i))) == -1 )
  1412. {
  1413. m_photoarray8.Add(m_photoarray5.ElementAt(i));
  1414. }
  1415. }
  1416. pCopyImg->CopyImg2Specifiedpath(m_photoarray8, g_mainpath + _T("\\temp\\"), _T(""), dwCopyPIX, FALSE, m_strOrderNum, FALSE);
  1417. }
  1418. CString strdir = g_mainpath + _T("\\temp");
  1419. // 获取该目录所有相片;
  1420. using namespace helper_coffs;
  1421. ffsco o;
  1422. o.dirs(1);
  1423. o.find(LPCSTR(strdir), LPCSTR("*.*"));
  1424. ffsco::typeT coo;
  1425. ffsco::typeT::iterator it;
  1426. coo = o.co_file();
  1427. if (coo.size())
  1428. {
  1429. pItem = m_Burn.AddSiblingRootItem(m_strOrderNum + _T("未选的相片"), TRUE);
  1430. if ( pItem )
  1431. {
  1432. for ( it = coo.begin(); it != coo.end(); it++ )
  1433. {
  1434. // 获取文件目录;
  1435. strFilePath = it->c_str();
  1436. // 去除根目录;
  1437. strFilePath.Delete(0, strdir.GetLength() + 1);
  1438. strFilePath = m_strOrderNum + _T("未选的相片\\") + strFilePath.Left(strFilePath.ReverseFind(_T('\\')));
  1439. if ( strFilePath == strLastName )
  1440. {
  1441. m_Burn.AddFile2SiblingItem(pItem, it->c_str());
  1442. }
  1443. else
  1444. {
  1445. strLastName = strFilePath;
  1446. pItem = m_Burn.AddFile2Path(strFilePath, it->c_str());
  1447. }
  1448. }
  1449. }
  1450. }
  1451. }
  1452. }
  1453. if (m_Burn.NeroAPIInit() == 0)
  1454. {
  1455. m_Burn.NeroWorkError = 1;
  1456. m_Burn.RemoveRootItem();
  1457. return;
  1458. }
  1459. m_Burn.m_strCustomerInfo = m_strCustomerInfo;
  1460. m_Burn.m_bDvd = m_bDvd;
  1461. m_Burn.NeroAPIBurn();
  1462. m_Burn.RemoveRootItem();
  1463. NowDoingBurn = true;
  1464. #else
  1465. // 2015-07-23 刻录原片和初修片需要权限;
  1466. if ( m_checkphoto4 )
  1467. {
  1468. if ( !IsHasRights2new(54) )
  1469. {
  1470. AfxMessageBox(_T("没有刻录原片权限,请联系管理员!"));
  1471. return;
  1472. }
  1473. }
  1474. if ( m_checkphoto5 )
  1475. {
  1476. if ( !IsHasRights2new(55) )
  1477. {
  1478. AfxMessageBox(_T("没有刻录初修片权限,请联系管理员!"));
  1479. return;
  1480. }
  1481. }
  1482. ::DeleteDirectory(g_mainpath + "\\temp"); // 递归删除temp目录;
  1483. ::CreateDirectory(g_mainpath + "\\temp", NULL);
  1484. UpdateData();
  1485. if (m_bScale)
  1486. {
  1487. if (!CheckDiskSpase())return;
  1488. }
  1489. if (m_nphotos == 0)
  1490. {
  1491. AfxMessageBox("未选中照片!", MB_ICONSTOP);
  1492. return;
  1493. }
  1494. if (m_nspase > 650 && m_bDvd == 0 && m_bScale == 0)
  1495. {
  1496. AfxMessageBox("光盘空间不足!", MB_ICONSTOP);
  1497. return;
  1498. }
  1499. GetDlgItem(IDOK)->SetWindowText("刻录中, 请稍候...");
  1500. GetDlgItem(IDOK)->EnableWindow(0);
  1501. if (NowDoingBurn)
  1502. return;
  1503. m_Burn.m_DirArray.RemoveAll();
  1504. m_Burn.m_DirRealNameArray.RemoveAll();
  1505. // CheckBox选中的相片类型与实际返回的相片路径的相片类型是否一致;
  1506. CArray<BOOL, BOOL>bIsSelectDirArray;
  1507. int i = 0;
  1508. CStringArray dirarray;
  1509. using namespace helper_coffs;
  1510. CStringArray srcarray;
  1511. if (m_bFromDir)
  1512. {
  1513. CString strdir;
  1514. GetDlgItemText(IDC_EDIT1, strdir);
  1515. strdir.TrimRight('\\');
  1516. m_Burn.m_DirArray.Add(strdir);
  1517. m_Burn.m_DirRealNameArray.Add(strdir);
  1518. bIsSelectDirArray.Add(0);
  1519. }
  1520. else
  1521. {
  1522. if (m_checkphoto1)
  1523. {// 精修片;
  1524. if (m_realpath == g_path1 && m_checkphoto4)
  1525. {// 没有找到精修,使用原片代替,将原片复制到temp目录中;
  1526. SetDlgItemText(IDC_STATICTip, "照片复制中...");
  1527. m_Progress.SetRange(0, m_photoarray1.GetSize());
  1528. CString path = g_mainpath + "\\temp\\" + m_strOrderNum + "(精修)";
  1529. ::CreateDirectory(path, NULL);
  1530. CString str;
  1531. for ( i = 0; i < m_photoarray1.GetSize(); i++)
  1532. {
  1533. str = m_photoarray1.ElementAt(i);
  1534. ::CopyFile(str, path + str.Right(str.GetLength() - str.ReverseFind('\\')), 0);
  1535. m_Progress.SetPos(i);
  1536. }
  1537. // 将原片的temp目录添加到m_DirArray;
  1538. m_Burn.m_DirArray.Add(path);
  1539. m_Burn.m_DirRealNameArray.Add(path);
  1540. bIsSelectDirArray.Add(0);
  1541. }
  1542. else
  1543. {
  1544. // 将精修片目录添加到m_DirArray;
  1545. m_Burn.m_DirArray.Add(m_realpath + "\\" + m_strOrderNum);
  1546. m_Burn.m_DirRealNameArray.Add(m_realpath + "\\" + m_strOrderNum + "(精修)");
  1547. // 如果选中的目录与精修相同,设置为FALSE;
  1548. if (m_realpath == g_path4)
  1549. bIsSelectDirArray.Add(0);
  1550. else // 初修片或原片,但没有选取原片;
  1551. bIsSelectDirArray.Add(1);
  1552. }
  1553. }
  1554. if (m_checkphoto5)
  1555. {// 初修片;
  1556. m_Burn.m_DirArray.Add(g_path2 + "\\" + m_strOrderNum);
  1557. m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_strOrderNum + "(初修)");
  1558. bIsSelectDirArray.Add(0);
  1559. }
  1560. if (m_checkphoto4)
  1561. {// 原片;
  1562. m_Burn.m_DirArray.Add(g_path1 + "\\" + m_strOrderNum);
  1563. m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_strOrderNum + "(原片)");
  1564. bIsSelectDirArray.Add(0);
  1565. }
  1566. if (m_checkphoto6)
  1567. {// 设计片;
  1568. m_Burn.m_DirArray.Add(g_path3 + "\\" + m_strOrderNum);
  1569. m_Burn.m_DirRealNameArray.Add(g_path3 + "\\" + m_strOrderNum + "(设计片)");
  1570. bIsSelectDirArray.Add(0);
  1571. }
  1572. }
  1573. DWORD nNeedSpase = 0;
  1574. if (m_bScale)
  1575. {// 是否压缩相片后再刻录;
  1576. SetDlgItemText(IDC_STATICTip, "照片裁切中...");
  1577. int pos = m_combo1.GetCurSel();
  1578. CStringArray needsaclearray;
  1579. CStringArray dirarray;
  1580. for ( i = 0; i < m_Burn.m_DirArray.GetSize(); i++)
  1581. {
  1582. // GenSPhoto:参数1:相片根目录,参数2:相片类型,参数3:返回的相片全路径;参数4:返回的相片新的保存路径;
  1583. // GenSPhoto,将m_DirArray目录的相片放入needsaclearray中,再创建新的目录dirarray用来存放压缩后的相片。
  1584. GenSPhoto(m_Burn.m_DirArray.ElementAt(i), m_Burn.m_DirRealNameArray.ElementAt(i).Right(6), needsaclearray, dirarray);
  1585. }
  1586. m_Progress.SetRange(0, needsaclearray.GetSize());
  1587. for (i = 0; i < needsaclearray.GetSize(); i++)
  1588. {// 压缩needscalearray相片到dirarray;
  1589. CString str = needsaclearray.ElementAt(i);
  1590. CString dir;
  1591. dir = dirarray.ElementAt(i);
  1592. Image *img = NULL;
  1593. ::LoadImageFromBuf(&img, str);
  1594. if (img->GetWidth())
  1595. {
  1596. CRect rc(0, 0, 800, 800);
  1597. if (pos == 0)
  1598. {
  1599. rc.right = 1600;
  1600. rc.bottom = 1600;
  1601. }
  1602. else if (pos == 1)
  1603. {
  1604. rc.right = 1024;
  1605. rc.bottom = 1024;
  1606. }
  1607. else if (pos == 2)
  1608. {
  1609. rc.right = 800;
  1610. rc.bottom = 800;
  1611. }
  1612. else
  1613. {
  1614. rc.right = 640;
  1615. rc.bottom = 640;
  1616. }
  1617. RectFitDes(img->GetWidth(), img->GetHeight(), rc);
  1618. Image *simg = img->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
  1619. Graphics graphic(simg);//防止GetThumbnailImage影响质量
  1620. graphic.DrawImage(img, 0, 0, simg->GetWidth(), simg->GetHeight());
  1621. delete img;
  1622. CString savepath = dir + "\\" + ::GetFileNameFromPath(str) + ".jpg";
  1623. ::SaveImageToFile(simg, savepath);
  1624. delete simg;
  1625. CFile fp;
  1626. if (fp.Open(savepath, CFile::modeRead))
  1627. {
  1628. nNeedSpase += fp.GetLength();
  1629. fp.Close();
  1630. }
  1631. else
  1632. {
  1633. str.Format("原片%s裁剪失败, 请查看此照片是否损坏。", savepath.Right(savepath.GetLength() - savepath.ReverseFind('\\') - 1));
  1634. AfxMessageBox(str);
  1635. }
  1636. }
  1637. m_Progress.SetPos(i + 1);
  1638. ::SleepEx(10);
  1639. }
  1640. if (::CheckFolderFileExist(g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)"))
  1641. {// 将压缩后的相片目录放到m_DirArray中;
  1642. m_Burn.m_DirArray.Add(g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)");
  1643. m_Burn.m_DirRealNameArray.Add(g_mainpath + "\\temp\\" + m_strOrderNum + "(未选的照片)");
  1644. bIsSelectDirArray.Add(0);
  1645. }
  1646. }
  1647. SetDlgItemText(IDC_STATICTip, "光盘刻录中...");
  1648. // dirarray的保存着最后全部相片的子目录;
  1649. // 查找m_DirArray中的所有子目录并保存;
  1650. CString str;
  1651. CArray<BOOL, BOOL>bIsSelectDirArray2;
  1652. for ( i = 0; i < m_Burn.m_DirArray.GetSize(); i++)
  1653. {
  1654. ffsco o;
  1655. o.dirs(1);
  1656. o.find(LPCSTR(m_Burn.m_DirArray.ElementAt(i)), LPCSTR("*.*"));
  1657. ffsco::typeT coo;
  1658. ffsco::typeT::iterator it;
  1659. coo = o.co_dir();
  1660. for (it = coo.begin(); coo.end() != it; it++)
  1661. {
  1662. str = (*it).c_str();
  1663. str.TrimRight("\\");
  1664. if (FindArray(&dirarray, str) == -1)
  1665. {
  1666. dirarray.Add(str);
  1667. // 所有子目录都设置成与根目录一样的属性;
  1668. bIsSelectDirArray2.Add(bIsSelectDirArray.ElementAt(i));
  1669. }
  1670. }
  1671. }
  1672. int addcount = 0;
  1673. if (m_bFromDir == 0)
  1674. {
  1675. if (m_checkphoto2)addcount++;
  1676. if (m_checkphoto3)addcount++;
  1677. }
  1678. if ((dirarray.GetSize() + addcount) == 0)return;
  1679. // photosarray保存着每一个dirarray目录中的全部相片;
  1680. CStringArray *photosarray = new CStringArray[dirarray.GetSize() + addcount];
  1681. for (i = 0; i < dirarray.GetSize(); i++)
  1682. {
  1683. GenSPhoto(dirarray.ElementAt(i), photosarray[i], nNeedSpase, bIsSelectDirArray2.ElementAt(i));
  1684. }
  1685. if (m_bFromDir == 0)
  1686. {
  1687. int pos = dirarray.GetSize();
  1688. if (m_checkphoto2)
  1689. {
  1690. m_Burn.m_DirArray.Add(g_path2 + "\\" + m_strOrderNum);
  1691. m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_strOrderNum + "(初修)");
  1692. dirarray.Add(g_path2 + "\\" + m_strOrderNum);
  1693. photosarray[pos].Copy(m_photoarray2);
  1694. pos++;
  1695. nNeedSpase += m_nspase1;
  1696. }
  1697. if (m_checkphoto3)
  1698. {
  1699. m_Burn.m_DirArray.Add(g_path1 + "\\" + m_strOrderNum);
  1700. m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_strOrderNum + "(原片)");
  1701. dirarray.Add(g_path1 + "\\" + m_strOrderNum);
  1702. photosarray[pos].Copy(m_photoarray3);
  1703. nNeedSpase += m_nspase2;
  1704. }
  1705. }
  1706. if (m_bScale)
  1707. {
  1708. nNeedSpase /= 1024 * 1024;
  1709. if (nNeedSpase > 650 && m_bDvd == 0)
  1710. {
  1711. AfxMessageBox("光盘空间不足!", MB_ICONSTOP); delete[]photosarray;
  1712. return;
  1713. }
  1714. }
  1715. m_Burn.m_pDir = &dirarray;
  1716. m_Burn.m_pPhotoArray = photosarray;
  1717. if (m_Burn.NeroAPIInit() == 0)
  1718. {
  1719. m_Burn.NeroWorkError = 1;
  1720. delete[]photosarray;
  1721. return;
  1722. }
  1723. m_Burn.m_strCustomerInfo = m_strCustomerInfo;
  1724. m_Burn.m_bDvd = m_bDvd;
  1725. m_Burn.NeroAPIBurn();
  1726. NowDoingBurn = true;
  1727. delete[]photosarray;
  1728. ::DeleteDirectory(g_mainpath + "\\temp"); // 递归删除temp目录;
  1729. if (m_Burn.NeroWorkError == 0)
  1730. {
  1731. CDialog::OnOK();
  1732. }
  1733. else
  1734. CDialog::OnCancel();
  1735. #endif
  1736. }
  1737. /************************************************************************/
  1738. /*
  1739. CheckBox:缩小客人未选的相片;
  1740. */
  1741. /************************************************************************/
  1742. void CNeroDlg::OnCheck7()
  1743. {
  1744. // TODO: Add your control notification handler code here
  1745. UpdateData();
  1746. AfxGetApp()->WriteProfileInt(LYFZVERSION, "cutphoto", m_bScale);
  1747. }
  1748. BOOL CNeroDlg::CheckDiskSpase()
  1749. {
  1750. CString sDrive = g_mainpath.Left(2);
  1751. DWORD dwTotalDiskSpace, dwFreeDiskSpace, dwUsedDiskSpace;
  1752. ULARGE_INTEGER uiFreeBytesAvailableToCaller;
  1753. ULARGE_INTEGER uiTotalNumberOfBytes;
  1754. ULARGE_INTEGER uiTotalNumberOfFreeBytes;
  1755. if (GetDiskFreeSpaceEx(sDrive, &uiFreeBytesAvailableToCaller,
  1756. &uiTotalNumberOfBytes,
  1757. &uiTotalNumberOfFreeBytes))
  1758. {
  1759. dwTotalDiskSpace = (DWORD)(uiTotalNumberOfBytes.QuadPart / 1024 / 1024);
  1760. dwFreeDiskSpace = (DWORD)(uiFreeBytesAvailableToCaller.QuadPart >> 20);
  1761. dwUsedDiskSpace = dwTotalDiskSpace - dwFreeDiskSpace;
  1762. }
  1763. if (dwFreeDiskSpace > 600)return 1;
  1764. AfxMessageBox("磁盘空间不足!", MB_ICONSTOP);
  1765. return 0;
  1766. }
  1767. void CNeroDlg::OnCloseupCombo1()
  1768. {
  1769. // TODO: Add your control notification handler code here
  1770. int pos = m_combo1.GetCurSel();
  1771. if (pos != -1)
  1772. {
  1773. AfxGetApp()->WriteProfileInt(LYFZVERSION, "cutphotosize", pos);
  1774. }
  1775. }
  1776. /************************************************************************/
  1777. /*
  1778. CheckBox:光盘类型cd;
  1779. */
  1780. /************************************************************************/
  1781. void CNeroDlg::OnRadio1()
  1782. {
  1783. // TODO: Add your control notification handler code here
  1784. OnRadio2();
  1785. }
  1786. /************************************************************************/
  1787. /*
  1788. CheckBox:光盘类型dvd;
  1789. */
  1790. /************************************************************************/
  1791. void CNeroDlg::OnRadio2()
  1792. {
  1793. // TODO: Add your control notification handler code here
  1794. UpdateData();
  1795. AfxGetApp()->WriteProfileInt(LYFZVERSION, "bDvd", m_bDvd);
  1796. }
  1797. void CNeroDlg::OnDestroy()
  1798. {
  1799. UpdateData();
  1800. AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto1", m_checkphoto1);
  1801. AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto2", m_checkphoto2);
  1802. AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto3", m_checkphoto3);
  1803. AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto4", m_checkphoto4);
  1804. AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto5", m_checkphoto5);
  1805. AfxGetApp()->WriteProfileInt(LYFZVERSION, "m_checkphoto6", m_checkphoto6);
  1806. // TODO: Add your message handler code here
  1807. CDialog::OnDestroy();
  1808. }
  1809. //---------------------------------------------------------------------------------------------------
  1810. //---------------------------------------------------------------------------------------------------
  1811. /************************************************************************/
  1812. /*
  1813. Jeff add 2014.09.03
  1814. */
  1815. /************************************************************************/
  1816. BOOL CopyFolder(CString strSrcPath, CString strDstPath)
  1817. {
  1818. // 创建目标文件夹;
  1819. if (strSrcPath.Right(1) == "\\")
  1820. {
  1821. strSrcPath = strSrcPath.Left(strSrcPath.GetLength() - 1);
  1822. }
  1823. if (strDstPath.Right(1) == "\\")
  1824. {
  1825. strDstPath = strDstPath.Left(strDstPath.GetLength() - 1);
  1826. }
  1827. CreateDirectory(strDstPath, NULL);
  1828. CFileFind finder;
  1829. // 打开指定的文件夹进行搜索;
  1830. BOOL bWorking = finder.FindFile(strSrcPath + "\\" + "*.*");
  1831. while (bWorking)
  1832. {
  1833. // 从当前目录搜索文件;
  1834. bWorking = finder.FindNextFile();
  1835. CString strFileName = finder.GetFileName();
  1836. CString strSrc = strSrcPath + "\\" + strFileName;
  1837. CString strDst = strDstPath + "\\" + strFileName;
  1838. // 判断搜索到的是不是"."和".."目录;
  1839. if (!finder.IsDots())
  1840. {
  1841. // 判断搜索到的目录是否是文件夹;
  1842. if (finder.IsDirectory())
  1843. {
  1844. // 如果是文件夹的话,进行递归;
  1845. if (!CopyFolder(strSrc, strDst))
  1846. {
  1847. return false;
  1848. }
  1849. }
  1850. else
  1851. {
  1852. // 如果是文件,进行复制;
  1853. if (!CopyFile(strSrc, strDst, FALSE))
  1854. {
  1855. return false;
  1856. }
  1857. }
  1858. }
  1859. }
  1860. return true;
  1861. }
  1862. void CNeroDlg::OnBnClickedExporttou()
  1863. {
  1864. #if 1 // 2015-07-23 刻录原片和初修片需要权限;
  1865. if ( m_checkphoto4 )
  1866. {
  1867. if ( !IsHasRights2new(54) )
  1868. {
  1869. AfxMessageBox(_T("没有刻录原片权限,请联系管理员!"));
  1870. return;
  1871. }
  1872. }
  1873. if ( m_checkphoto5 )
  1874. {
  1875. if ( !IsHasRights2new(55) )
  1876. {
  1877. AfxMessageBox(_T("没有刻录初修片权限,请联系管理员!"));
  1878. return;
  1879. }
  1880. }
  1881. #endif
  1882. // 1.浏览文件U盘文件夹;
  1883. EndofThread();
  1884. //CString sFolderPath;
  1885. BROWSEINFO bi;
  1886. char Buffer[MAX_PATH];
  1887. //初始化入口参数bi开始;
  1888. bi.hwndOwner = NULL;
  1889. bi.pidlRoot = NULL;//初始化制定的root目录很不容易,
  1890. bi.pszDisplayName = Buffer;//此参数如为NULL则不能显示对话框;
  1891. bi.lpszTitle = "修改接收路径";
  1892. //bi.ulFlags = BIF_BROWSEINCLUDEFILES;//包括文件;
  1893. bi.ulFlags = BIF_EDITBOX | BIF_USENEWUI;//包括文件;
  1894. bi.lpfn = NULL;
  1895. bi.iImage = IDR_MAINFRAME;
  1896. //初始化入口参数bi结束;
  1897. LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);//调用显示选择对话框;
  1898. if (pIDList)
  1899. {
  1900. if (!SHGetPathFromIDList(pIDList, Buffer))
  1901. return;
  1902. //取得文件夹路径到Buffer里;
  1903. //sFolderPath = Buffer;//将文件夹路径保存在一个CString对象里;
  1904. m_strUFolder = Buffer;
  1905. }
  1906. else
  1907. return;
  1908. LPMALLOC lpMalloc;
  1909. if (FAILED(SHGetMalloc(&lpMalloc)))
  1910. return;
  1911. lpMalloc->Free(pIDList);
  1912. lpMalloc->Release();
  1913. // MessageBox(sFolderPath,"Title",MB_OK);
  1914. // 1.2.获取盘符;
  1915. BYTE bAlpha = m_strUFolder.GetAt(0);
  1916. if (m_strUFolder.GetLength() != m_strUFolder.ReverseFind('\\'))
  1917. {
  1918. m_strUFolder += "\\";
  1919. }
  1920. //printf("Jeff:保存目录 %s\n\n",m_strUFolder);
  1921. // 2.获取U盘的大小等信息;
  1922. CString strResult = _T("");
  1923. #if 1
  1924. __int64 iVolumeSize = 0, iVolumeFreeSize = 0;
  1925. #else
  1926. double iVolumeSize = 0.0, iVolumeFreeSize = 0.0;
  1927. #endif
  1928. if (!::IsCharAlpha((TCHAR)bAlpha))
  1929. {
  1930. strResult = _T("驱动器参数无效!");
  1931. //return strResult;
  1932. AfxMessageBox(strResult);
  1933. return;
  1934. }
  1935. else
  1936. {
  1937. /**********获取驱动器名字、序列号和文件系统部分**********/
  1938. CString strRootPathName;
  1939. strRootPathName.Format(_T("%c:\\"), bAlpha);
  1940. LPCTSTR lpRootPathName = strRootPathName;
  1941. LPTSTR lpVolumeNameBuffer = new char[_MAX_FNAME];
  1942. DWORD nVolumeNameSize = _MAX_FNAME;
  1943. DWORD nVolumeSerialNumber = 0;//便于驱动器无效时做判断 ;
  1944. DWORD nMaximumComponentLength;
  1945. DWORD nFileSystemFlags;
  1946. LPTSTR lpFileSystemNameBuffer = new char[20];//文件系统(NTFS,FAT)多大有定义好的宏吗 ;
  1947. DWORD nFileSystemNameSize = 20;
  1948. GetVolumeInformation(
  1949. lpRootPathName,
  1950. lpVolumeNameBuffer,
  1951. nVolumeNameSize,
  1952. &nVolumeSerialNumber,
  1953. &nMaximumComponentLength,
  1954. &nFileSystemFlags,
  1955. lpFileSystemNameBuffer,
  1956. nFileSystemNameSize);
  1957. /**********获取驱动器类型部分**********/
  1958. CString strDriveType;
  1959. /**********获取驱动器总大小和剩余大小部分**********/
  1960. LPCTSTR lpDirectoryName = new char[2];
  1961. lpDirectoryName = (LPCTSTR)strRootPathName.Mid(0, 2);
  1962. _ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
  1963. GetDiskFreeSpaceEx(strRootPathName.Mid(0, 2), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes);
  1964. #if 0
  1965. iVolumeSize = (double)TotalNumberOfBytes.QuadPart / 1024 / 1024;
  1966. iVolumeFreeSize = (double)FreeBytesAvailable.QuadPart / 1024 / 1024;
  1967. #else
  1968. iVolumeSize = TotalNumberOfBytes.QuadPart;
  1969. iVolumeFreeSize = FreeBytesAvailable.QuadPart;
  1970. #endif
  1971. }
  1972. // 3.对比大小;
  1973. DWORD64 dwTotalSize = m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6;
  1974. if ((iVolumeFreeSize <= dwTotalSize) || (iVolumeFreeSize - dwTotalSize < 1024 * 10)) // 相差10K,认为容量不足;
  1975. {
  1976. AfxMessageBox("U盘容量不足!");
  1977. return;
  1978. }
  1979. // 4.拷贝文件 精修片 原片 初修片 设计片;
  1980. // m_strOrderNum; // 订单号;
  1981. CString strOrderFolder = _T("");
  1982. // 设置进度条;
  1983. DWORD nTotalFiles = m_photoarray1.GetSize() + m_photoarray6.GetSize() + m_photoarray5.GetSize() + m_photoarray4.GetSize();
  1984. m_Progress.SetRange(0, nTotalFiles);
  1985. // 5.由线程处理U盘的拷贝工作;
  1986. StartThread();
  1987. GetDlgItem(Btn_ExportToU)->EnableWindow(FALSE);
  1988. }
  1989. DWORD WINAPI CNeroDlg::ExportImageThread(LPVOID lpParam)
  1990. {
  1991. CNeroDlg *pExportImageImpl = (CNeroDlg*)lpParam;
  1992. int nIndexOfProcess = 0;
  1993. CString strImageName = _T("");
  1994. CString strOrderFolder = _T("");
  1995. strOrderFolder.Format("%s%s\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  1996. ::CreateDirectory(strOrderFolder, NULL);
  1997. if (pExportImageImpl->m_bScale)
  1998. {
  1999. int nX = 0, nY = 0;
  2000. int nPos = pExportImageImpl->m_combo1.GetCurSel();
  2001. if (nPos == 0)
  2002. {
  2003. nY = 1200;
  2004. nX = 1600;
  2005. }
  2006. else if (nPos == 1)
  2007. {
  2008. nY = 768;
  2009. nX = 1024;
  2010. }
  2011. else if (nPos = 2)
  2012. {
  2013. nY = 600;
  2014. nX = 800;
  2015. }
  2016. else if (nPos == 3)
  2017. {
  2018. nY = 480;
  2019. nX = 640;
  2020. }
  2021. //printf("Jeff:%s,%s\n\n",pExportImageImpl->m_strUFolder,pExportImageImpl->m_strOrderNum);
  2022. if (pExportImageImpl->m_checkphoto1) // 精修目录;
  2023. {
  2024. strOrderFolder.Format("%s%s\\选好的片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  2025. ::CreateDirectory(strOrderFolder, NULL);
  2026. //printf("Jeff:1.%s\n\n",strOrderFolder);
  2027. int nSize = pExportImageImpl->m_photoarray1.GetSize();//printf("Jeff:1.%d\n\n",nSize);
  2028. for (int i = 0; i < nSize; i++)
  2029. {
  2030. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1));
  2031. //printf("Jeff:1.%s\n\n",strImageName);
  2032. ToCompressImage(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, nX, nY);
  2033. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  2034. }
  2035. }
  2036. if (pExportImageImpl->m_checkphoto6) // 设计目录;
  2037. {
  2038. strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  2039. ::CreateDirectory(strOrderFolder, NULL);
  2040. int nSize = pExportImageImpl->m_photoarray6.GetSize();
  2041. for (int i = 0; i < nSize; i++)
  2042. {
  2043. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1));
  2044. //printf("Jeff:6.%s,%s\n\n",pExportImageImpl->m_photoarray1.ElementAt(i),strImageName);
  2045. ToCompressImage(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, nX, nY);
  2046. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  2047. }
  2048. }
  2049. if (pExportImageImpl->m_checkphoto5) // 初修目录;
  2050. {
  2051. strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  2052. ::CreateDirectory(strOrderFolder, NULL);
  2053. //printf("Jeff:5.%s\n\n",strOrderFolder);
  2054. int nSize = pExportImageImpl->m_photoarray5.GetSize();
  2055. for (int i = 0; i < nSize; i++)
  2056. {
  2057. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1));
  2058. ToCompressImage(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, nX, nY);
  2059. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  2060. }
  2061. }
  2062. if (pExportImageImpl->m_checkphoto4) // 原片目录;
  2063. {
  2064. strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  2065. ::CreateDirectory(strOrderFolder, NULL);
  2066. //printf("Jeff:4.%s\n\n",strOrderFolder);
  2067. int nSize = pExportImageImpl->m_photoarray4.GetSize();
  2068. for (int i = 0; i < nSize; i++)
  2069. {
  2070. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1));
  2071. ToCompressImage(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, nX, nY);
  2072. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  2073. }
  2074. }
  2075. }
  2076. else
  2077. {
  2078. if (pExportImageImpl->m_checkphoto1) // 精修目录;
  2079. {
  2080. strOrderFolder.Format("%s%s\\选好的片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  2081. ::CreateDirectory(strOrderFolder, NULL);
  2082. int nSize = pExportImageImpl->m_photoarray1.GetSize();
  2083. for (int i = 0; i < nSize; i++)
  2084. {
  2085. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1));
  2086. ::CopyFile(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, 0);
  2087. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  2088. }
  2089. }
  2090. if (pExportImageImpl->m_checkphoto6) // 设计目录;
  2091. {
  2092. strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  2093. ::CreateDirectory(strOrderFolder, NULL);
  2094. int nSize = pExportImageImpl->m_photoarray6.GetSize();
  2095. for (int i = 0; i < nSize; i++)
  2096. {
  2097. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1));
  2098. ::CopyFile(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, 0);
  2099. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  2100. }
  2101. }
  2102. if (pExportImageImpl->m_checkphoto5) // 初修目录;
  2103. {
  2104. strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  2105. ::CreateDirectory(strOrderFolder, NULL);
  2106. int nSize = pExportImageImpl->m_photoarray5.GetSize();
  2107. for (int i = 0; i < nSize; i++)
  2108. {
  2109. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1));
  2110. ::CopyFile(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, 0);
  2111. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  2112. }
  2113. }
  2114. if (pExportImageImpl->m_checkphoto4) // 原片目录;
  2115. {
  2116. strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_strOrderNum);
  2117. ::CreateDirectory(strOrderFolder, NULL);
  2118. int nSize = pExportImageImpl->m_photoarray4.GetSize();
  2119. for (int i = 0; i < nSize; i++)
  2120. {
  2121. strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1));
  2122. ::CopyFile(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, 0);
  2123. pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
  2124. }
  2125. }
  2126. }
  2127. Sleep(1000);
  2128. AfxMessageBox("导出完毕!");
  2129. pExportImageImpl->GetDlgItem(Btn_ExportToU)->EnableWindow(TRUE);
  2130. pExportImageImpl->m_Progress.SetRange(0, 0);
  2131. //pExportImageImpl->m_Progress.SetPos(0);
  2132. return 0;
  2133. }
  2134. int CNeroDlg::StartThread()
  2135. {
  2136. m_hCtrl = CreateEvent(NULL, TRUE, FALSE, NULL); // 无信号事件;
  2137. if (m_hCtrl == NULL)
  2138. {
  2139. //LOG4C((LOG_NOTICE,"创建事件失败"));
  2140. //PostMessage(g_hwnd,MSG_SHOWPROMPTING,0,0);
  2141. return -1;
  2142. }
  2143. //_hThread = CreateThread(NULL,0,ThreadProc,this,CREATE_SUSPENDED,NULL);
  2144. m_hThread = CreateThread(NULL, 0, ExportImageThread, this, 0, NULL);
  2145. if (m_hThread == NULL)
  2146. {
  2147. //LOG4C((LOG_NOTICE,"创建线程失败"));
  2148. return -1;
  2149. }
  2150. //m_bThreadRuning = FALSE;
  2151. m_bThreadRuning = TRUE;
  2152. return 0;
  2153. }
  2154. int CNeroDlg::EndofThread()
  2155. {
  2156. // 1.关闭线程------------------------;;
  2157. if (m_hCtrl)
  2158. {
  2159. SetEvent(m_hCtrl);
  2160. }
  2161. if (m_hThread)
  2162. {
  2163. if (WaitForSingleObject(m_hThread, INFINITE) != WAIT_TIMEOUT)
  2164. {
  2165. CloseHandle(m_hThread);
  2166. m_hThread = NULL;
  2167. }
  2168. }
  2169. m_bThreadRuning = FALSE;
  2170. CloseHandle(m_hCtrl);
  2171. m_hCtrl = NULL;
  2172. return 0;
  2173. }
  2174. void CNeroDlg::ToCompressImage(__in const TCHAR *pImageSource, __in const TCHAR *pImageDest, __in const int &nXPiexel, __in const int &nYPiexel)
  2175. {
  2176. //printf("Jeff:%s,%s,%d,%d\n\n",pImageSource,pImageDest,nXPiexel,nYPiexel);
  2177. #if 1
  2178. Image *pImage = NULL;
  2179. #else
  2180. Bitmap *pImage = NULL;
  2181. #endif
  2182. // 1.从文件中以读的方式加载图片到Image中;
  2183. CFile cf;
  2184. if (cf.Open(pImageSource, CFile::modeRead))
  2185. {
  2186. DWORD dwLength = cf.GetLength();
  2187. BYTE *pData = new BYTE[dwLength];
  2188. if (pData == NULL)// 创建内存失败;
  2189. {
  2190. //printf("Jeff:1.创建内存失败\n\n");
  2191. return;
  2192. }
  2193. cf.Read(pData, dwLength);
  2194. cf.Close();
  2195. // 1.1.将文件数据加载到内存数据中;
  2196. HGLOBAL taghMem = GlobalAlloc(GMEM_MOVEABLE, dwLength);
  2197. if (taghMem == NULL) // 创建内存失败;
  2198. {
  2199. //printf("Jeff:2.创建内存失败\n\n");
  2200. return;
  2201. }
  2202. BYTE *pMem = (BYTE*)GlobalLock(taghMem);
  2203. memcpy(pMem, pData, dwLength);
  2204. // 1.2.创建二进制流对象;
  2205. IStream *pStream;
  2206. CreateStreamOnHGlobal(taghMem, TRUE, &pStream);
  2207. #if 1
  2208. pImage = Gdiplus::Image::FromStream(pStream);
  2209. #else
  2210. pImage = Gdiplus::Bitmap::FromStream(pStream);
  2211. #endif
  2212. GlobalUnlock(taghMem);
  2213. pStream->Release();
  2214. delete[]pData;
  2215. }
  2216. else
  2217. {
  2218. //printf("Jeff:打开文件失败\n\n");
  2219. }
  2220. // 2.加载后……
  2221. if (pImage == NULL) // 加载失败;
  2222. {
  2223. //printf("Jeff:加载图片失败\n\n");
  2224. return;
  2225. }
  2226. // 2.1.当图片的像素大于要设定的像素时,进行处理;
  2227. if (pImage->GetWidth() > nXPiexel || pImage->GetHeight() > nYPiexel)
  2228. {
  2229. CRect tagRect(0, 0, nXPiexel, nYPiexel);
  2230. RectFitDes_01(pImage->GetWidth(), pImage->GetHeight(), tagRect);
  2231. Image *RtImage = pImage->GetThumbnailImage(tagRect.Width(), tagRect.Height(), NULL, NULL);
  2232. Graphics graphic(RtImage); // 防止GetThumbnailImage影响图片质量;
  2233. delete pImage;
  2234. SaveImageToFile(RtImage, pImageDest);
  2235. delete RtImage;
  2236. }
  2237. else // 直接用原片,不压缩;
  2238. {
  2239. ::CopyFile(pImageSource, pImageDest, 0);
  2240. }
  2241. }
  2242. void CNeroDlg::RectFitDes_01(__in const int &nWidth, __in const int &nHeight, __inout CRect &rc)
  2243. {
  2244. try
  2245. {
  2246. if (nWidth == 0 || nHeight == 0)return;
  2247. // 图片长宽比例;
  2248. float fscale = (float)nWidth / (float)nHeight;
  2249. // 设备长宽比例;
  2250. float rcscale = ((float)rc.Width()) / ((float)rc.Height());
  2251. int rcwid = rc.Width();
  2252. int rchei = rc.Height();
  2253. int dt = 0;
  2254. // Jeff.如果设备长宽比例 < 图片长宽比例;(即相同长度下,高越大比例值越小,所以此时图片尺寸 与 显示设备的尺寸相比,要显得更长)
  2255. if (rcscale < fscale)
  2256. {
  2257. // Jeff.remarks
  2258. // 调整显示设备的大小,以使之能容纳图片尺寸;(即长宽比例上,要大于或等于图片的长宽比例)
  2259. // 所以有两种方法使得 rcscale >= fscale 表达式成立:
  2260. // -----------------------------------------------
  2261. // 方法1:显示设备宽加x值,计算出下面表达式x的值即可
  2262. // (rc.Width()+x) / rc.Height() >= width/height;
  2263. // 方法2:显示设备高减x值,计算出下面表达式x的值即可
  2264. // (rc.Width()) / (rc.Height()-x) >= width/height;
  2265. //------------------------------------------------
  2266. // 两种方法的最后表达式为:
  2267. // x >= rc.Height() - rcWidth()*(height/width);
  2268. // 即 x >= rc.Height() - rcWidth()/fscale;
  2269. //------------------------------------------------
  2270. dt = (rcwid - rchei*fscale) / 2;
  2271. rc.left += dt;
  2272. rc.right -= dt;
  2273. }
  2274. else
  2275. {
  2276. dt = (rchei - rcwid / fscale) / 2;
  2277. rc.top += dt;
  2278. rc.bottom -= dt;
  2279. }
  2280. }
  2281. catch (...)
  2282. {
  2283. }
  2284. }
  2285. void CNeroDlg::SaveImageToFile(__in Image *img, __in CString path)
  2286. {
  2287. try
  2288. {
  2289. if (img == NULL)
  2290. {
  2291. //printf("Jeff:img == NULL \n\n");
  2292. return;
  2293. }
  2294. CLSID encoderClsid;
  2295. BSTR bstr = path.AllocSysString();
  2296. path.MakeLower();
  2297. if (path.Right(3) == "bmp")
  2298. {
  2299. GetEncoderClsid(L"image/bmp", &encoderClsid);
  2300. img->Save(bstr, &encoderClsid, NULL);
  2301. }
  2302. else if (path.Right(3) == "png")
  2303. {
  2304. GetEncoderClsid(L"image/png", &encoderClsid);
  2305. img->Save(bstr, &encoderClsid, NULL);
  2306. }
  2307. else// if(path.Right (3)=="jpg")
  2308. {
  2309. GetEncoderClsid(L"image/jpeg", &encoderClsid);
  2310. EncoderParameters encoderParameters;
  2311. ULONG quality;
  2312. encoderParameters.Count = 1;
  2313. encoderParameters.Parameter[0].Guid = EncoderQuality;
  2314. encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
  2315. encoderParameters.Parameter[0].NumberOfValues = 1;
  2316. // Save the image as a JPEG with quality level 100.
  2317. quality = 100;
  2318. encoderParameters.Parameter[0].Value = &quality;
  2319. img->Save(bstr, &encoderClsid, &encoderParameters);
  2320. }
  2321. SysFreeString(bstr);
  2322. }
  2323. catch (...)
  2324. {
  2325. }
  2326. }
  2327. int CNeroDlg::GetEncoderClsid(__in const WCHAR* format, __inout CLSID* pClsid)
  2328. {
  2329. UINT num = 0; // number of image encoders
  2330. UINT size = 0; // size of the image encoder array in bytes
  2331. ImageCodecInfo* pImageCodecInfo = NULL;
  2332. GetImageEncodersSize(&num, &size);
  2333. if (size == 0)
  2334. return -1; // Failure
  2335. pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
  2336. if (pImageCodecInfo == NULL)
  2337. return -1; // Failure
  2338. GetImageEncoders(num, size, pImageCodecInfo);
  2339. for (UINT j = 0; j < num; ++j)
  2340. {
  2341. if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
  2342. {
  2343. *pClsid = pImageCodecInfo[j].Clsid;
  2344. free(pImageCodecInfo);
  2345. return j; // Success
  2346. }
  2347. }
  2348. free(pImageCodecInfo);
  2349. return -1; // FailureFailure
  2350. }