ShowPic3.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. // ShowPic3.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "dbserver.h"
  5. #include "ShowPic3.h"
  6. #include "./helper/ffsco.h"
  7. #include "DelPhotoSet.h"
  8. #include <process.h>
  9. #include "Lzari.h"
  10. #include "mysqldata.h"
  11. #define THUMBNAIL_WIDTH 100
  12. #define THUMBNAIL_HEIGHT 90
  13. #include "ConnectThread.h"
  14. #include "ShowPhoto.h"
  15. /////////////////////////////////////////////////////////////////////////////
  16. // ShowPic3 dialog IDC_BU IDC_COMBO2
  17. ShowPic3::ShowPic3(CWnd* pParent /*=NULL*/)
  18. : CDialog(ShowPic3::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(ShowPic3)
  21. m_check1 = 1;
  22. //}}AFX_DATA_INIT
  23. m_bTerminate = false;
  24. m_bRunning = false;
  25. m_hThread = NULL;
  26. }
  27. void ShowPic3::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(ShowPic3)
  31. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  32. DDX_Control(pDX, IDC_LIST2, m_List2);
  33. DDX_Control(pDX, IDC_LIST1, m_List1);
  34. DDX_Check(pDX, IDC_CHECK1, m_check1);
  35. //}}AFX_DATA_MAP
  36. }
  37. BEGIN_MESSAGE_MAP(ShowPic3, CDialog)
  38. //{{AFX_MSG_MAP(ShowPic3)
  39. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  40. ON_WM_DESTROY()
  41. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  42. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  43. ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
  44. ON_BN_CLICKED(IDC_BTNshow1, OnBTNshow1)
  45. ON_BN_CLICKED(IDC_BTNshow2, OnBTNshow2)
  46. ON_BN_CLICKED(IDC_BTNshow3, OnBTNshow3)
  47. ON_BN_CLICKED(IDC_BTNshow4, OnBTNshow4)
  48. ON_BN_CLICKED(IDC_BUTdel1, OnBUTdel1)
  49. ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
  50. ON_BN_CLICKED(IDC_BUTdel3, OnBUTdel3)
  51. ON_BN_CLICKED(IDC_BUTdel4, OnBUTdel4)
  52. ON_WM_CTLCOLOR()
  53. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /*
  57. void DataToArray(CArray<CStringArray, CStringArray>*List1array, BYTE code, BYTE *g_pData, int g_nLeng)
  58. {
  59. try
  60. {
  61. List1array->RemoveAll ();
  62. if(g_nLeng==0)return;
  63. if(code)
  64. {
  65. BYTE *lpszOut = NULL;
  66. int nOutSize = 0;
  67. LZARI Lzari;
  68. Lzari.UnCompress(g_pData,g_nLeng,lpszOut,nOutSize);
  69. CMemFile memfile;
  70. memfile.Attach (lpszOut,nOutSize);
  71. Lzari.Release();
  72. CArchive ar(&memfile, CArchive::load);
  73. List1array->SetSize(g_sendhead.count[0]);
  74. for(int ii=0; ii<List1array->GetSize (); ii++)
  75. {
  76. List1array->ElementAt (ii).Serialize (ar);
  77. }
  78. ar.Close();
  79. memfile.Detach ();
  80. }
  81. else
  82. {
  83. CMemFile memfile;
  84. memfile.Attach (g_pData,g_nLeng);
  85. CArchive ar(&memfile, CArchive::load);
  86. List1array->SetSize(g_sendhead.count[0]);
  87. for(int ii=0; ii<List1array->GetSize (); ii++)
  88. {
  89. List1array->ElementAt (ii).Serialize (ar);
  90. }
  91. ar.Close();
  92. memfile.Detach ();
  93. }
  94. }
  95. catch(...)
  96. {
  97. }
  98. }*/
  99. /////////////////////////////////////////////////////////////////////////////
  100. // ShowPic3 message handlers
  101. extern int FindArray(CStringArray *pArray, CString Str);
  102. extern void GetPathFromNetShareName(CString name, CString &sRet);
  103. BOOL ShowPic3::OnInitDialog()
  104. {
  105. CDialog::OnInitDialog();
  106. CString str = "\r\n 1. 备份硬盘要与原保存硬盘要为2块独立硬盘(保存在同一块硬盘起不到保护作用)。\r\n\
  107. 2. 备份硬盘满后可以更换一块新的备份硬盘(如需帮助,请与利亚方舟技术联系)\r\n\
  108. 3. 备份硬盘满后可以按文件夹修改日期从前往后的顺序刻进光盘后删除\r\n\
  109. 4. 如不需要保存备份,可以在管理备份照片中手工删除备份";
  110. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  111. m_combo1.AddString("全部");
  112. m_combo1.AddString("取完件1个月");
  113. m_combo1.AddString("取完件2个月");
  114. m_combo1.AddString("取完件3个月");
  115. m_combo1.AddString("取完件6个月");
  116. m_combo1.AddString("取完件9个月");
  117. m_combo1.AddString("取完件12个月");
  118. m_combo1.AddString("取完件18个月");
  119. m_combo1.AddString("取完件24个月");
  120. m_combo1.AddString("取完件36个月");
  121. m_combo1.SetCurSel(0);
  122. CRect rc, rc2;
  123. GetWindowRect(rc2);
  124. DEVMODE g_dm;
  125. g_dm.dmSize = sizeof(DEVMODE);
  126. EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &g_dm);
  127. int wid = g_dm.dmPelsWidth * 3 / 4;
  128. int hei = g_dm.dmPelsHeight * 3 / 4;
  129. ::MoveWindow(m_hWnd, 0, 0, wid, hei, TRUE);
  130. CenterWindow();
  131. GetClientRect(rc);
  132. GetDlgItem(IDC_STATIC1)->GetWindowRect(rc2);
  133. ScreenToClient(rc2);
  134. rc2.left = 0;
  135. rc2.right = rc.right;
  136. GetDlgItem(IDC_STATIC1)->MoveWindow(rc2);
  137. GetDlgItem(IDC_STATIC2)->MoveWindow(rc2);
  138. m_List2.GetWindowRect(rc2);
  139. ScreenToClient(rc2);
  140. int dt = rc2.left;
  141. rc2.bottom = rc.bottom - dt;
  142. m_List2.MoveWindow(rc2);
  143. m_List1.GetWindowRect(rc2);
  144. ScreenToClient(rc2);
  145. rc2.bottom = rc.bottom - dt;
  146. rc2.right = rc.right - dt;
  147. m_List1.MoveWindow(rc2);
  148. /* CConnectSocket consock;
  149. consock.m_pConndb =&g_db;
  150. BYTE code=217;
  151. DWORD length,arraysize;
  152. BYTE *pReturn=NULL;
  153. consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
  154. DataToArray(&m_List1array, code, pReturn, length);delete []pReturn;*/
  155. {
  156. m_List1array.RemoveAll();
  157. CArray<CDatabase*, CDatabase*>dbarraytemp;
  158. dbarraytemp.Copy(g_dbHistoryArray);
  159. dbarraytemp.InsertAt(0, &g_db);
  160. for (int a = dbarraytemp.GetSize() - 1; a >= 0; a--)
  161. {
  162. CString filter = "status3='OK'";
  163. CDatabase *m_pConndb = dbarraytemp.ElementAt(a);
  164. CRecordset myset(m_pConndb);
  165. CString sql = "select count(*) as cot from dindan"; if (!filter.IsEmpty())sql += " where " + filter;
  166. myset.Open(CRecordset::forwardOnly, sql);
  167. myset.GetFieldValue("cot", sql);
  168. myset.Close();
  169. int count = atol(sql);
  170. sql.Format("%d", a - 1);
  171. // if(a==0)sql="-1";
  172. int oldsize = m_List1array.GetSize();
  173. m_List1array.SetSize(oldsize + count, 1);
  174. CRstDindanForm rsSt; rsSt.m_pDatabase = m_pConndb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  175. rsSt.m_strSort = "id";
  176. rsSt.Open();
  177. int ii = 0;
  178. while (!rsSt.IsEOF())
  179. {
  180. m_List1array.ElementAt(oldsize + ii).RemoveAll();
  181. m_List1array.ElementAt(oldsize + ii).Add(rsSt.id);
  182. m_List1array.ElementAt(oldsize + ii).Add(rsSt.name1);
  183. m_List1array.ElementAt(oldsize + ii).Add(rsSt.name2);
  184. /* m_List1array.ElementAt (oldsize+ii).Add(rsSt.txtype) ;
  185. m_List1array.ElementAt (oldsize+ii).Add(rsSt.discount) ;
  186. m_List1array.ElementAt (oldsize+ii).Add(rsSt.authorize) ;
  187. m_List1array.ElementAt (oldsize+ii).Add(rsSt.discount2) ;
  188. m_List1array.ElementAt (oldsize+ii).Add(rsSt.authorize2) ;
  189. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status) ;
  190. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status4) ;
  191. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status2) ;
  192. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status6) ;
  193. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status5) ;
  194. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status8) ;
  195. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status3) ;
  196. m_List1array.ElementAt (oldsize+ii).Add(rsSt.time1) ;
  197. m_List1array.ElementAt (oldsize+ii).Add(rsSt.time2) ;
  198. m_List1array.ElementAt (oldsize+ii).Add(rsSt.time4) ;
  199. m_List1array.ElementAt (oldsize+ii).Add(rsSt.time6) ;*/
  200. m_List1array.ElementAt(oldsize + ii).Add(rsSt.time5);
  201. /* m_List1array.ElementAt (oldsize+ii).Add(rsSt.ren) ;
  202. m_List1array.ElementAt (oldsize+ii).Add(rsSt.taoxiname) ;
  203. m_List1array.ElementAt (oldsize+ii).Add(rsSt.taoxijiage) ;
  204. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter1) ;
  205. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter2) ;
  206. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter5) ;
  207. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter3) ;
  208. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter7) ;
  209. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter4) ;
  210. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter8) ;
  211. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter6) ;
  212. m_List1array.ElementAt (oldsize+ii).Add(rsSt.phone1) ;
  213. m_List1array.ElementAt (oldsize+ii).Add(rsSt.phone2) ;
  214. m_List1array.ElementAt (oldsize+ii).Add(rsSt.pinyin1) ;
  215. m_List1array.ElementAt (oldsize+ii).Add(rsSt.pinyin2) ;
  216. m_List1array.ElementAt (oldsize+ii).Add(sql) ;*/
  217. ii++;
  218. rsSt.MoveNext(); if (m_List1array.GetSize() <= (oldsize + ii))break;
  219. }
  220. rsSt.Close(); m_List1array.SetSize(oldsize + ii, 1);
  221. }
  222. }
  223. {
  224. CRstversion rsSt; rsSt.m_pDatabase = &g_db;
  225. rsSt.Open();
  226. if (!rsSt.IsEOF())
  227. {
  228. g_path1 = rsSt.m_bakserver1;
  229. g_path2 = rsSt.m_bakserver2;
  230. g_path4 = rsSt.m_bakserver3;
  231. g_path3 = rsSt.m_bakserver4;
  232. }
  233. rsSt.Close();
  234. }
  235. #ifdef CHILD_VERSION
  236. if(g_path1.Find(":")==-1&& g_path1!="")
  237. g_path1="\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$";
  238. if(1)//(localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$"))
  239. GetPathFromNetShareName("客户原片备份(儿童管理软件)$", g_path1);
  240. if(g_path2.Find(":")==-1&& g_path2!="")
  241. g_path2="\\\\"+g_path2+"\\修好的片备份(儿童管理软件)$";
  242. if(1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(儿童管理软件)$"))
  243. GetPathFromNetShareName("修好的片备份(儿童管理软件)$", g_path2);
  244. if(g_path4.Find(":")==-1&& g_path4!="")
  245. g_path4="\\\\"+g_path4+"\\精修好的片备份(儿童管理软件)$";
  246. if(1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(儿童管理软件)$"))
  247. GetPathFromNetShareName("精修好的片备份(儿童管理软件)$", g_path4);
  248. if(g_path3.Find(":")==-1&& g_path3!="")
  249. g_path3="\\\\"+g_path3+"\\设计好的片备份(儿童管理软件)$";
  250. if(1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(儿童管理软件)$"))
  251. GetPathFromNetShareName("设计好的片备份(儿童管理软件)$", g_path3);
  252. #else
  253. if (g_path1.Find(":") == -1 && g_path1 != "")
  254. g_path1 = "\\\\" + g_path1 + "\\客户原片备份(管理软件)$";
  255. if (1)//((localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(管理软件)$"))
  256. GetPathFromNetShareName("客户原片备份(管理软件)$", g_path1);
  257. if (g_path2.Find(":") == -1 && g_path2 != "")
  258. g_path2 = "\\\\" + g_path2 + "\\修好的片备份(管理软件)$";
  259. if (1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(管理软件)$"))
  260. GetPathFromNetShareName("修好的片备份(管理软件)$", g_path2);
  261. if (g_path4.Find(":") == -1 && g_path4 != "")
  262. g_path4 = "\\\\" + g_path4 + "\\精修好的片备份(管理软件)$";
  263. if (1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(管理软件)$"))
  264. GetPathFromNetShareName("精修好的片备份(管理软件)$", g_path4);
  265. if (g_path3.Find(":") == -1 && g_path3 != "")
  266. g_path3 = "\\\\" + g_path3 + "\\设计好的片备份(管理软件)$";
  267. if (1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(管理软件)$"))
  268. GetPathFromNetShareName("设计好的片备份(管理软件)$", g_path3);
  269. #endif
  270. LoadPhotos();
  271. for (int i = 0; i < m_List1array.GetSize(); i++)
  272. {
  273. str = m_List1array.ElementAt(i).ElementAt(0);
  274. if (FindArray(&m_dirarray1, str) == -1)
  275. {
  276. if (FindArray(&m_dirarray2, str) == -1)
  277. {
  278. if (FindArray(&m_dirarray3, str) == -1)
  279. {
  280. if (FindArray(&m_dirarray4, str) == -1)
  281. {
  282. continue;
  283. }
  284. }
  285. }
  286. }
  287. str += "\r\n";
  288. str += m_List1array.ElementAt(i).ElementAt(1);
  289. str += m_List1array.ElementAt(i).ElementAt(2);
  290. if (m_List2.GetCount() % 2)
  291. m_List2.AddEntry(str, RGB(204, 204, 204), m_List2.GetCount());
  292. else
  293. m_List2.AddEntry(str, RGB(190, 190, 190), m_List2.GetCount());
  294. m_idarray.Add(str);
  295. m_datearray.Add(m_List1array.ElementAt(i).ElementAt(3));
  296. }
  297. m_List2.Invalidate();
  298. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  299. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  300. return TRUE; // return TRUE unless you set the focus to a control
  301. // EXCEPTION: OCX Property Pages should return FALSE
  302. }
  303. extern void LoadImageFromFile(Image **img, CString path);
  304. extern void LoadImageFromBuf(Image **img, CString path);
  305. int GetOrientation(Image *image)
  306. {
  307. try
  308. {
  309. if (image)
  310. {
  311. UINT totalBufferSize;
  312. UINT numProperties;
  313. image->GetPropertySize(&totalBufferSize, &numProperties);
  314. // Allocate the buffer that will receive the property items.
  315. PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
  316. // Fill the buffer.
  317. image->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
  318. // Print the id data member of each property item.
  319. for (UINT j = 0; j < numProperties; ++j)
  320. {
  321. if (PropertyTagOrientation == pAllItems[j].id)
  322. {
  323. short* ptrLong = (short*)(pAllItems[j].value);
  324. int ret = (int)*ptrLong;
  325. free(pAllItems);
  326. return ret;
  327. }
  328. }
  329. free(pAllItems);
  330. }
  331. }
  332. catch (...)
  333. {
  334. }
  335. return 1;
  336. }
  337. unsigned __stdcall LoadThumbNail20(LPVOID lpParam)
  338. {
  339. try
  340. {
  341. ShowPic3 *pDlg = (ShowPic3*)lpParam;
  342. CListCtrl *ListCtrl = &pDlg->m_List1;
  343. CImageList* pImgList = &pDlg->m_ImageListThumb;
  344. // reset our image list
  345. for (int i = 0; i < pImgList->GetImageCount(); i++)
  346. pImgList->Remove(i);
  347. // remove all items from list view
  348. ListCtrl->DeleteAllItems();
  349. pImgList->SetImageCount(pDlg->m_vFileName.size());
  350. TCHAR path[MAX_PATH];
  351. vector<CString>::iterator iter;
  352. // Set redraw to FALSE to avoid flickering during adding new items
  353. ListCtrl->SetRedraw(FALSE);
  354. int nIndex = 0;
  355. CString str, spath;
  356. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  357. {
  358. str = *iter;
  359. spath.Empty();
  360. if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
  361. {
  362. spath = str.Left(str.ReverseFind('\\') + 1);
  363. spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
  364. }
  365. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  366. str = spath + str.Left(str.GetLength() - 4);
  367. ListCtrl->InsertItem(nIndex, str, nIndex);
  368. }
  369. ListCtrl->SetRedraw(TRUE);
  370. ListCtrl->Invalidate();
  371. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  372. int XDest, YDest, nDestWidth, nDestHeight;
  373. nIndex = 0;
  374. SolidBrush whitebrush(Color(255, 255, 255, 255));
  375. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  376. {
  377. // Load Image File
  378. Image *image = NULL;
  379. Bitmap *pBmp = NULL;
  380. str = *iter;
  381. spath = str.Left(str.ReverseFind('\\') + 1);
  382. spath += "s";
  383. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  384. if (::CheckFileExist(spath))
  385. ::LoadImageFromBuf(&image, spath);
  386. else
  387. {
  388. str.MakeLower();
  389. if (str.Right(3) != "jpg")continue;
  390. ::LoadImageFromBuf(&image, str);
  391. }
  392. if (image == NULL)continue;
  393. int orientation = GetOrientation(image);
  394. if (orientation == 8)
  395. image->RotateFlip(Rotate270FlipNone);
  396. else if (orientation == 6)
  397. image->RotateFlip(Rotate90FlipNone);
  398. if (image->GetWidth() == 0)
  399. continue;
  400. // Calculate Rect to fit to canvas
  401. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  402. if (fImgRatio > fRatio)
  403. {
  404. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  405. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  406. YDest = 0;
  407. nDestHeight = THUMBNAIL_HEIGHT;
  408. }
  409. else
  410. {
  411. XDest = 0;
  412. nDestWidth = THUMBNAIL_WIDTH;
  413. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  414. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  415. }
  416. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  417. Graphics graph2(pBmp);
  418. graph2.Clear(Color(255, 192, 192, 192));
  419. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  420. Graphics graph(pBmp);
  421. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  422. // Draw Image
  423. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  424. delete image;
  425. // Attach to Bitmap and Replace image in CImageList
  426. CBitmap bitmap;
  427. HBITMAP hbmp;
  428. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  429. bitmap.Attach(hbmp);
  430. pImgList->Replace(nIndex, &bitmap, NULL);
  431. delete pBmp;
  432. // Redraw only a current item for removing flickering and fast speed.
  433. ListCtrl->RedrawItems(nIndex, nIndex);
  434. // Release used DC and Object
  435. }
  436. ListCtrl->Invalidate();
  437. pDlg->m_bRunning = false;
  438. pDlg->m_bTerminate = false;
  439. _endthreadex(0);
  440. return 0;
  441. }
  442. catch (...)
  443. {
  444. }
  445. }
  446. void ShowPic3::LoadThumbImages()
  447. {
  448. TerminateThread();
  449. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail20, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  450. m_bRunning = true;
  451. }
  452. BOOL ShowPic3::TerminateThread()
  453. {
  454. if (!m_bRunning)
  455. return TRUE;
  456. m_bTerminate = true;
  457. for (;;)
  458. {
  459. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  460. break;
  461. MSG msg;
  462. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  463. {
  464. if (!AfxGetApp()->PumpMessage())
  465. break;
  466. }
  467. }
  468. ::CloseHandle(m_hThread);
  469. return TRUE;
  470. }
  471. extern void LoadImageFromBuf(Image **img, CString path);
  472. void ShowPic3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  473. {
  474. // TODO: Add your control notification handler code here
  475. POSITION pos;
  476. pos = m_List1.GetFirstSelectedItemPosition();
  477. if (pos == NULL)
  478. {
  479. return;
  480. }
  481. int iItem = m_List1.GetNextSelectedItem(pos);
  482. Image *m_pImg = NULL;
  483. ::LoadImageFromBuf(&m_pImg, m_patharray1.ElementAt(iItem));
  484. ShowPhoto dlg;
  485. dlg.m_pImg = m_pImg;
  486. dlg.DoModal();
  487. delete m_pImg;
  488. /* ShowPic22 dlg;
  489. dlg.m_pos=iItem;
  490. dlg.m_pPathArray=&m_patharray1;
  491. dlg.DoModal ();*/
  492. *pResult = 0;
  493. }
  494. void ShowPic3::OnDestroy()
  495. {
  496. TerminateThread();
  497. CDialog::OnDestroy();
  498. // TODO: Add your message handler code here
  499. }
  500. extern BOOL myisdigit(CString str);
  501. void ShowPic3::LoadPhotos()
  502. {
  503. if (g_path1 == "")return;
  504. CString str;
  505. if (1)
  506. {
  507. using namespace helper_coffs;
  508. ffsco o;
  509. o.dirs(0);
  510. o.find(LPCSTR(g_path1), LPCSTR("*.*"));
  511. ffsco::typeT coo;
  512. ffsco::typeT::iterator it;
  513. coo = o.co_dir();
  514. for (it = coo.begin(); coo.end() != it; it++)
  515. {
  516. str = (*it).c_str();
  517. if (str == g_path1 + "\\")continue;
  518. str.TrimRight("\\");
  519. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  520. m_dirarray1.Add(str);
  521. }
  522. }
  523. }
  524. void ShowPic3::OnBUTdel()
  525. {
  526. DelPhotoSet dlg;
  527. dlg.DoModal();
  528. }
  529. void ShowPic3::OnSelchangeList2()
  530. {
  531. // TODO: Add your control notification handler code here
  532. UpdateData();
  533. int pos = m_List2.GetCurSel();
  534. if (pos == -1)return;
  535. CString str;
  536. m_List2.GetText(pos, str);
  537. pos = str.Find("\r\n");
  538. if (pos == -1)return;;
  539. m_id = str.Left(pos);
  540. ShowPhoto1();
  541. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  542. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  543. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  544. }
  545. void ShowPic3::ShowPhoto1()
  546. {
  547. if (m_id == "")
  548. {
  549. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  550. }
  551. CString str;
  552. m_path = g_path1 + "\\" + m_id + "\\";
  553. m_patharray1.RemoveAll();
  554. if (1)
  555. {
  556. using namespace helper_coffs;
  557. ffsco o;
  558. o.dirs(1);
  559. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  560. ffsco::typeT coo;
  561. ffsco::typeT::iterator it;
  562. coo = o.co_file();
  563. for (it = coo.begin();
  564. coo.end() != it;
  565. it++)
  566. {
  567. str = (*it).c_str();
  568. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  569. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  570. str.MakeLower();
  571. m_patharray1.Add(str);
  572. }
  573. }
  574. if (m_bRunning)return;
  575. CStringArray *pArray = &m_patharray1;
  576. m_vFileName.clear();
  577. for (int i = 0; i < pArray->GetSize(); i++)
  578. {
  579. CString filePath = pArray->ElementAt(i);
  580. filePath.MakeLower();
  581. m_vFileName.push_back(filePath);
  582. }
  583. LoadThumbImages();
  584. }
  585. void ShowPic3::ShowPhoto2()
  586. {
  587. if (m_id == "")
  588. {
  589. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  590. }
  591. CString str;
  592. m_path = g_path2 + "\\" + m_id + "\\";
  593. m_patharray1.RemoveAll();
  594. if (1)
  595. {
  596. using namespace helper_coffs;
  597. ffsco o;
  598. o.dirs(1);
  599. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  600. ffsco::typeT coo;
  601. ffsco::typeT::iterator it;
  602. coo = o.co_file();
  603. for (it = coo.begin();
  604. coo.end() != it;
  605. it++)
  606. {
  607. str = (*it).c_str();
  608. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  609. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  610. str.MakeLower();
  611. m_patharray1.Add(str);
  612. }
  613. }
  614. if (m_bRunning)return;
  615. CStringArray *pArray = &m_patharray1;
  616. m_vFileName.clear();
  617. for (int i = 0; i < pArray->GetSize(); i++)
  618. {
  619. CString filePath = pArray->ElementAt(i);
  620. filePath.MakeLower();
  621. m_vFileName.push_back(filePath);
  622. }
  623. LoadThumbImages();
  624. }
  625. void ShowPic3::ShowPhoto3()
  626. {
  627. if (m_id == "")
  628. {
  629. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  630. }
  631. CString str;
  632. m_path = g_path3 + "\\" + m_id + "\\";
  633. m_patharray1.RemoveAll();
  634. if (1)
  635. {
  636. using namespace helper_coffs;
  637. ffsco o;
  638. o.dirs(1);
  639. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  640. ffsco::typeT coo;
  641. ffsco::typeT::iterator it;
  642. coo = o.co_file();
  643. for (it = coo.begin();
  644. coo.end() != it;
  645. it++)
  646. {
  647. str = (*it).c_str();
  648. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  649. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  650. str.MakeLower();
  651. m_patharray1.Add(str);
  652. }
  653. }
  654. if (m_bRunning)return;
  655. CStringArray *pArray = &m_patharray1;
  656. m_vFileName.clear();
  657. for (int i = 0; i < pArray->GetSize(); i++)
  658. {
  659. CString filePath = pArray->ElementAt(i);
  660. filePath.MakeLower();
  661. m_vFileName.push_back(filePath);
  662. }
  663. LoadThumbImages();
  664. }
  665. void ShowPic3::ShowPhoto4()
  666. {
  667. if (m_id == "")
  668. {
  669. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  670. }
  671. CString str;
  672. m_path = g_path4 + "\\" + m_id + "\\";
  673. m_patharray1.RemoveAll();
  674. if (1)
  675. {
  676. using namespace helper_coffs;
  677. ffsco o;
  678. o.dirs(1);
  679. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  680. ffsco::typeT coo;
  681. ffsco::typeT::iterator it;
  682. coo = o.co_file();
  683. for (it = coo.begin();
  684. coo.end() != it;
  685. it++)
  686. {
  687. str = (*it).c_str();
  688. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  689. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  690. str.MakeLower();
  691. m_patharray1.Add(str);
  692. }
  693. }
  694. if (m_bRunning)return;
  695. CStringArray *pArray = &m_patharray1;
  696. m_vFileName.clear();
  697. for (int i = 0; i < pArray->GetSize(); i++)
  698. {
  699. CString filePath = pArray->ElementAt(i);
  700. filePath.MakeLower();
  701. m_vFileName.push_back(filePath);
  702. }
  703. LoadThumbImages();
  704. }
  705. void ShowPic3::OnBTNshow1()
  706. {
  707. // TODO: Add your control notification handler code here
  708. ShowPhoto1();
  709. }
  710. void ShowPic3::OnBTNshow2()
  711. {
  712. // TODO: Add your control notification handler code here
  713. ShowPhoto2();
  714. }
  715. void ShowPic3::OnBTNshow3()
  716. {
  717. // TODO: Add your control notification handler code here
  718. ShowPhoto4();
  719. }
  720. void ShowPic3::OnBTNshow4()
  721. {
  722. // TODO: Add your control notification handler code here
  723. ShowPhoto3();
  724. }
  725. void ShowPic3::OnBUTdelall()
  726. {
  727. // TODO: Add your control notification handler code here
  728. if (m_id == "")
  729. {
  730. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  731. }
  732. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  733. DeleteDirectory(g_path1 + "\\" + m_id + "\\");
  734. DeleteDirectory(g_path2 + "\\" + m_id + "\\");
  735. DeleteDirectory(g_path3 + "\\" + m_id + "\\");
  736. DeleteDirectory(g_path4 + "\\" + m_id + "\\");
  737. OnBTNshow1();
  738. }
  739. void ShowPic3::OnBUTdel1()
  740. {
  741. // TODO: Add your control notification handler code here
  742. if (m_id == "")
  743. {
  744. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  745. }
  746. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  747. DeleteDirectory(g_path1 + "\\" + m_id + "\\"); OnBTNshow1();
  748. }
  749. void ShowPic3::OnBUTdel2()
  750. {
  751. // TODO: Add your control notification handler code here
  752. if (m_id == "")
  753. {
  754. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  755. }
  756. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  757. DeleteDirectory(g_path2 + "\\" + m_id + "\\"); OnBTNshow2();
  758. }
  759. void ShowPic3::OnBUTdel3()
  760. {
  761. // TODO: Add your control notification handler code here
  762. if (m_id == "")
  763. {
  764. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  765. }
  766. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  767. DeleteDirectory(g_path4 + "\\" + m_id + "\\"); OnBTNshow3();
  768. }
  769. void ShowPic3::OnBUTdel4()
  770. {
  771. // TODO: Add your control notification handler code here
  772. if (m_id == "")
  773. {
  774. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  775. }
  776. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  777. DeleteDirectory(g_path3 + "\\" + m_id + "\\"); OnBTNshow4();
  778. }
  779. HBRUSH ShowPic3::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  780. {
  781. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  782. // TODO: Change any attributes of the DC here
  783. if (nCtlColor == CTLCOLOR_STATIC && pWnd->GetDlgCtrlID() == IDC_STATIC1)
  784. {
  785. pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明
  786. return (HBRUSH)::GetStockObject(WHITE_BRUSH); // 设置背景色
  787. }
  788. // TODO: Return a different brush if the default is not desired
  789. return hbr;
  790. }
  791. void ShowPic3::OnSelchangeCombo1()
  792. {
  793. // TODO: Add your control notification handler code here
  794. int pos = m_combo1.GetCurSel();
  795. if (pos != -1)
  796. {
  797. CString str;
  798. m_combo1.GetLBText(pos, str);
  799. int days = -1;
  800. if (str == "全部")days = -1;
  801. else if (str == "取完件1个月")days = 31;
  802. else if (str == "取完件2个月")days = 31 + 30;
  803. else if (str == "取完件3个月")days = 31 * 2 + 30;
  804. else if (str == "取完件6个月")days = 31 * 3 + 30 * 3;
  805. else if (str == "取完件9个月")days = 31 * 5 + 30 * 4;
  806. else if (str == "取完件12个月")days = 365;
  807. else if (str == "取完件18个月")days = 365 + 31 * 3 + 30 * 3;
  808. else if (str == "取完件24个月")days = 365 * 2;
  809. else if (str == "取完件36个月")days = 365 * 3;
  810. m_List2.ResetContent();
  811. CString date;
  812. CTime today = CTime::GetCurrentTime();
  813. CTimeSpan dt;
  814. for (int i = 0; i < m_datearray.GetSize(); i++)
  815. {
  816. date = m_datearray.ElementAt(i);
  817. // MessageBox(date);
  818. CTime tm = GetTmFromStr(date);
  819. dt = today - tm;
  820. // str.Format("%d", dt.GetDays());
  821. // MessageBox(str);
  822. if (days != -1 && dt.GetDays() < days)continue;
  823. str = m_idarray.ElementAt(i);
  824. if (m_List2.GetCount() % 2)
  825. m_List2.AddEntry(str, RGB(204, 204, 204), m_List2.GetCount());
  826. else
  827. m_List2.AddEntry(str, RGB(190, 190, 190), m_List2.GetCount());
  828. }
  829. m_List2.Invalidate();
  830. }
  831. }