NeroDlg.cpp 67 KB

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