1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035 |
- #include "stdafx.h"
- #include "ylgl.h"
- #include "NeroDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- CNeroDlg* pDlg;
- CNeroDlg::CNeroDlg(CWnd* pParent ) : CDialog(CNeroDlg::IDD, pParent)
- {
- m_bFromDir = 0;
- m_bDvd = 0;
- m_checkphoto1 = 1;
- m_checkphoto2 = FALSE;
- m_checkphoto3 = FALSE;
- m_checkphoto4 = FALSE;
- m_checkphoto5 = FALSE;
- m_checkphoto6 = FALSE;
- pDlg = this;
- NowDoingBurn = false;
- m_nphotos = 0;
- m_nspase = 0;
- m_nphotos1 = 0;
- m_nspase1 = 0;
- m_nphotos2 = 0;
- m_nspase2 = 0;
- m_nphotos3 = 0;
- m_nspase3 = 0;
- m_nphotos4 = 0;
- m_nspase4 = 0;
- m_nphotos5 = 0;
- m_nspase5 = 0;
- m_nphotos6 = 0;
- m_nspase6 = 0;
- CString version = _T("Version 1.0");
- m_bScale = AfxGetApp()->GetProfileInt(version, "cutphoto", 1);
- m_bDvd = AfxGetApp()->GetProfileInt(version, "bDvd", 0);
- m_checkphoto1 = AfxGetApp()->GetProfileInt(version, "m_checkphoto1", 1);
- m_checkphoto2 = 0;
- m_checkphoto3 = 0;
- m_checkphoto4 = AfxGetApp()->GetProfileInt(version, "m_checkphoto4", 0);
- m_checkphoto5 = AfxGetApp()->GetProfileInt(version, "m_checkphoto5", 0);
- m_checkphoto6 = AfxGetApp()->GetProfileInt(version, "m_checkphoto6", 0);
- }
- void CNeroDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
-
- DDX_Control(pDX, IDC_COMBO1, m_combo1);
- DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
- DDX_Radio(pDX, IDC_RADIO3, m_bFromDir);
- DDX_Radio(pDX, IDC_RADIO1, m_bDvd);
- DDX_Check(pDX, IDC_CHECK1, m_checkphoto1);
- DDX_Check(pDX, IDC_CHECK2, m_checkphoto2);
- DDX_Check(pDX, IDC_CHECK3, m_checkphoto3);
- DDX_Check(pDX, IDC_CHECK4, m_checkphoto4);
- DDX_Check(pDX, IDC_CHECK5, m_checkphoto5);
- DDX_Check(pDX, IDC_CHECK6, m_checkphoto6);
- DDX_Check(pDX, IDC_CHECK7, m_bScale);
-
- }
- BEGIN_MESSAGE_MAP(CNeroDlg, CDialog)
-
- ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
- ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
- ON_BN_CLICKED(IDC_BUTchoosedir, OnBUTchoosedir)
- ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
- ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
- ON_BN_CLICKED(IDC_CHECK3, OnCheck3)
- ON_BN_CLICKED(IDC_CHECK4, OnCheck4)
- ON_BN_CLICKED(IDC_CHECK5, OnCheck5)
- ON_BN_CLICKED(IDC_CHECK6, OnCheck6)
- ON_BN_CLICKED(IDC_CHECK7, OnCheck7)
- ON_CBN_CLOSEUP(IDC_COMBO1, OnCloseupCombo1)
- ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
- ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
- ON_WM_DESTROY()
-
- ON_BN_CLICKED(Btn_ExportToU, OnBnClickedExporttou)
- END_MESSAGE_MAP()
- BOOL CNeroDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- m_Progress.SetRange(0, 100);
- EnableCtrls();
- CString filter = "id='" + m_id + "'";
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 50;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if (g_bSendOK == 0)
- {
- return 1;
- }
- CArray<CStringArray, CStringArray>sparray;
- DataToArray(&sparray);
- CString str, spname;
- CStringArray spnamearray;
- for (int i = 0; i < sparray.GetSize(); i++)
- {
- str = sparray.ElementAt(i).ElementAt(6);
- spname = sparray.ElementAt(i).ElementAt(5);
- GetNo(str, m_noarray);
- }
- m_combo1.AddString("1200x1600");
- m_combo1.AddString("768x1024");
- m_combo1.AddString("600x800");
- m_combo1.AddString("480x640");
- CString version = _T("Version 1.0");
- int pos = AfxGetApp()->GetProfileInt(version, "cutphotosize", 2);
- m_combo1.SetCurSel(pos);
- if (m_checkphoto1)OnCheck1();
- if (m_checkphoto2)OnCheck2();
- if (m_checkphoto3)OnCheck3();
- if (m_checkphoto4)OnCheck4();
- if (m_checkphoto5)OnCheck5();
- if (m_checkphoto6)OnCheck6();
- CenterWindow();
- return TRUE;
- }
- bool NERO_CALLBACK_ATTR CNeroDlg::IdleCallback(void *pUserData)
- {
- static MSG msg;
- while (!::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE))
- {
- if (!AfxGetThread()->PumpMessage())
- {
- break;
- }
- }
- return false;
- }
- NeroUserDlgInOut NERO_CALLBACK_ATTR CNeroDlg::UserDialog(void *pUserData, NeroUserDlgInOut type, void *data)
- {
- switch (type)
- {
- case DLG_AUTO_INSERT:
- return DLG_RETURN_CONTINUE;
- break;
- case DLG_DISCONNECT_RESTART:
- return DLG_RETURN_ON_RESTART;
- break;
- case DLG_DISCONNECT:
- return DLG_RETURN_CONTINUE;
- break;
- case DLG_AUTO_INSERT_RESTART:
- return DLG_RETURN_EXIT;
- break;
- case DLG_RESTART:
- return DLG_RETURN_EXIT;
- break;
- case DLG_SETTINGS_RESTART:
- return DLG_RETURN_CONTINUE;
- break;
- case DLG_OVERBURN:
- return DLG_RETURN_TRUE;
- break;
- case DLG_AUDIO_PROBLEMS:
- return DLG_RETURN_EXIT;
- break;
- case DLG_FILESEL_IMAGE:
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
- return DLG_BURNIMAGE_CANCEL;
- }
- break;
- case DLG_WAITCD:
- {
- AfxMessageBox("光盘不为空或类型错误");
- return DLG_RETURN_EXIT;
- break;
- }
- default:
- break;
- }
-
- return DLG_RETURN_EXIT;
- }
- BOOL NERO_CALLBACK_ATTR CNeroDlg::ProgressCallback(void *pUserData, DWORD dwProgressInPercent)
- {
- ((CNeroDlg*)pUserData)->m_Progress.SetPos(dwProgressInPercent);
- return true;
- }
- BOOL NERO_CALLBACK_ATTR CNeroDlg::AbortedCallback(void *pUserData)
- {
- return false;
- return true;
- }
- void NERO_CALLBACK_ATTR CNeroDlg::AddLogLine(void *pUserData, NERO_TEXT_TYPE type, const char *text)
- {
-
- return;
- }
- void NERO_CALLBACK_ATTR CNeroDlg::SetPhaseCallback(void *pUserData, const char *text)
- {
- return;
- }
- CString GetFileNameFromPath(CString path)
- {
- path = path.Right(path.GetLength() - path.ReverseFind('\\') - 1);
- path = path.Left(path.Find('.'));
- return path;
- }
- void CNeroDlg::GenSPhoto(CString dir, CStringArray &array, DWORD &nNeedSpase, BOOL bCheckNo)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dir), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- CString str;
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- if (str.Right(2) == "ok")continue;
- if (bCheckNo)
- {
- if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
- continue;
- }
- if (m_bScale)
- {
- if (str.Find("客户原片") != -1 || str.Find("\\修好的片") != -1)
- {
- if (::FindArray(&m_noarray, GetFileNameFromPath(str)) != -1)
- {
- array.Add(str);
- CFile fp;
- fp.Open(str, CFile::modeRead);
- nNeedSpase += fp.GetLength();
- fp.Close();
- }
- }
- else
- {
- array.Add(str);
- CFile fp;
- fp.Open(str, CFile::modeRead);
- nNeedSpase += fp.GetLength();
- fp.Close();
- }
- }
- else
- array.Add(str);
- }
- }
- void CNeroDlg::GenSPhoto(CString dir, CString sType, CStringArray &array, CStringArray &dirarray)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(dir), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- CString str;
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- if (str.Right(2) == "ok")continue;
- if (m_bScale && (sType == "(初修)" || sType == "(原片)"))
- {
- if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
- {
- ::CreateDirectory(g_mainpath + "\\temp", NULL);
- ::CreateDirectory(g_mainpath + "\\temp\\" + m_id + "(未选的照片)", NULL);
- CString dir;
- dir = g_mainpath + "\\temp\\" + m_id + "(未选的照片)\\" + sType;
- ::CreateDirectory(dir, NULL);
- array.Add(str);
- dirarray.Add(dir);
-
- }
- }
- }
- }
- int GetChildCount(CString str, CStringArray &array)
- {
- CString dirname = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- int count = array.GetSize();
- CString temp;
- for (int i = 0; i < array.GetSize(); i++)
- {
- if (array.ElementAt(i) == str)
- count--;
- else if (array.ElementAt(i).Find(str) == -1)
- count--;
- else
- {
- temp = array.ElementAt(i);
- temp = temp.Left(temp.ReverseFind('\\'));
- if (temp != str)
- count--;
- }
- }
- return count;
- }
- void CNeroDlg::OnCancel()
- {
-
-
- EndofThread();
- if (NowDoingBurn)
- {
- if (m_Burn.NeroBurnOK)
- {
- CDialog::OnOK();
- return;
- }
- if (m_Burn.NeroWorkError)
- {
- CDialog::OnCancel();
- return;
- }
- AfxMessageBox("已经开始刻录了,不能中断");
- return;
- }
- CDialog::OnCancel();
- }
- void CNeroDlg::DoBurnOrNot()
- {
- m_Burn.NeroAPIInit();
- m_Burn.NeroAPIBurn();
- }
- BOOL CNeroDlg::PreTranslateMessage(MSG* pMsg)
- {
- return CDialog::PreTranslateMessage(pMsg);
- }
- void CNeroDlg::EnableCtrls()
- {
- GetDlgItem(IDC_CHECK1)->EnableWindow(!m_bFromDir);
- GetDlgItem(IDC_CHECK2)->EnableWindow(!m_bFromDir);
- GetDlgItem(IDC_CHECK3)->EnableWindow(!m_bFromDir);
- GetDlgItem(IDC_CHECK4)->EnableWindow(!m_bFromDir);
- GetDlgItem(IDC_CHECK5)->EnableWindow(!m_bFromDir);
- GetDlgItem(IDC_CHECK6)->EnableWindow(!m_bFromDir);
- GetDlgItem(IDC_BUTchoosedir)->EnableWindow(m_bFromDir);
- }
- void CNeroDlg::OnRadio3()
- {
- UpdateData();
- EnableCtrls();
- }
- void CNeroDlg::OnRadio4()
- {
- OnRadio3();
- }
- void CNeroDlg::OnBUTchoosedir()
- {
- CString dir;
- GetSavePath(dir);
- dir.IsEmpty();
- GetDlgItem(IDC_EDIT1)->SetWindowText(dir);
- m_photoarray7.RemoveAll();
- CString path;
- path = dir;
- CStringArray dirarray;
- CString str;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- m_photoarray7.Add(str);
- }
- }
- if (m_photoarray7.GetSize() == 0)
- {
- AfxMessageBox("警告:目录中无照片!", MB_ICONSTOP);
- }
- m_nphotos = m_photoarray7.GetSize();
- m_nspase = 0;
- for (i = 0; i < m_photoarray7.GetSize(); i++)
- {
- CFile fp;
- if (fp.Open(m_photoarray7.ElementAt(i), CFile::modeRead))
- {
- m_nspase += fp.GetLength();
- fp.Close();
- }
- }
- m_nspase /= (1024 * 1024);
- str.Format("照片:%d 占用空间:%dM", m_nphotos, m_nspase);
- GetDlgItem(IDC_STATIC7)->SetWindowText(str);
- }
- void CNeroDlg::OnCheck1()
- {
-
- UpdateData();
- if (m_checkphoto1)
- {
- if (m_photoarray1.GetSize() == 0)
- {
- CString path;
- path = g_path4 + "\\";
- path += m_id;
- path += "\\";
- m_realpath = g_path4;
- CStringArray dirarray;
- CString str;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- m_photoarray1.Add(str);
- }
- }
- if (m_photoarray1.GetSize() == 0)
- {
- AfxMessageBox("没有找到精修片,将用初修片替代!");
- path = g_path2 + "\\";
- path += m_id;
- path += "\\";
- m_realpath = g_path2;
- CStringArray dirarray;
- CString str, temp;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
-
- if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
- continue;
- m_photoarray1.Add(str);
- }
- }
- }
- if (m_photoarray1.GetSize() == 0)
- {
- AfxMessageBox("没有找到初修片,将用原片替代!");
- path = g_path1 + "\\";
- path += m_id;
- path += "\\";
- m_realpath = g_path1;
- CStringArray dirarray;
- CString str, temp;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
-
- if (::FindArray(&m_noarray, GetFileNameFromPath(str)) == -1)
- continue;
- m_photoarray1.Add(str);
- }
- }
- }
- m_nphotos1 = m_photoarray1.GetSize();
- m_nspase1 = 0;
- for (i = 0; i < m_photoarray1.GetSize(); i++)
- {
- CFile fp;
- if (fp.Open(m_photoarray1.ElementAt(i), CFile::modeRead))
- {
- m_nspase1 += fp.GetLength();
- fp.Close();
- }
- }
- m_nspase1temp = m_nspase1;
- }
- else
- {
- m_nphotos1 = m_photoarray1.GetSize();
- m_nspase1 = m_nspase1temp;
- }
- }
- else
- {
- m_nphotos1 = 0;
- m_nspase1 = 0;
- }
- CString str;
- str.Format("照片:%d 占用空间:%dM", m_nphotos1, m_nspase1 / (1024 * 1024));
- GetDlgItem(IDC_STATIC1)->SetWindowText(str);
- m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
- m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
- }
- void CNeroDlg::OnCheck2()
- {
- UpdateData();
- if (m_checkphoto2)
- {
- if (m_checkphoto5)
- m_checkphoto5 = 0;
- UpdateData(false);
- OnCheck5();
- if (m_photoarray2.GetSize() == 0)
- {
- CString path;
- path = g_path2 + "\\";
- path += m_id;
- path += "\\";
- CString str;
- if (m_noarray.GetSize() == 0)
- {
- AfxMessageBox("此单未选片!", MB_ICONINFORMATION);
- return;
- }
- for (int i = 0; i < m_noarray.GetSize(); i++)
- {
- str.Format("%s%s.jpg", path, m_noarray.ElementAt(i));
- if (PathFileExists(str))
- {
- m_photoarray2.Add(str);
- }
- }
- if (m_photoarray2.GetSize() == 0)
- {
- AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
- }
- m_nphotos2 = m_photoarray2.GetSize();
- m_nspase2 = 0;
- for (i = 0; i < m_photoarray2.GetSize(); i++)
- {
- CFile fp;
- if (fp.Open(m_photoarray2.ElementAt(i), CFile::modeRead))
- {
- m_nspase2 += fp.GetLength();
- fp.Close();
- }
- }
- m_nspase2temp = m_nspase2;
- }
- else
- {
- m_nphotos2 = m_photoarray2.GetSize();
- m_nspase2 = m_nspase2temp;
- }
- }
- else
- {
- m_nphotos2 = 0;
- m_nspase2 = 0;
- }
- CString str;
- str.Format("照片:%d 占用空间:%dM", m_nphotos2, m_nspase2 / (1024 * 1024));
- GetDlgItem(IDC_STATIC2)->SetWindowText(str);
- m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
- m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
- }
- void CNeroDlg::OnCheck3()
- {
-
-
- }
- void CNeroDlg::OnCheck4()
- {
- UpdateData();
- if (m_checkphoto4)
- {
-
- if (m_photoarray4.GetSize() == 0)
- {
- CString path;
- path = g_path1 + "\\";
- path += m_id;
- path += "\\";
- CStringArray dirarray;
- CString str;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- m_photoarray4.Add(str);
- }
- }
- if (m_photoarray4.GetSize() == 0)
- {
- AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
- }
- m_nphotos4 = m_photoarray4.GetSize();
- m_nspase4 = 0;
- for (i = 0; i < m_photoarray4.GetSize(); i++)
- {
- CFile fp;
- if (fp.Open(m_photoarray4.ElementAt(i), CFile::modeRead))
- {
- m_nspase4 += fp.GetLength();
- fp.Close();
- }
- }
- m_nspase4temp = m_nspase4;
- }
- else
- {
- m_nphotos4 = m_photoarray4.GetSize();
- m_nspase4 = m_nspase4temp;
- }
- }
- else
- {
- m_nphotos4 = 0;
- m_nspase4 = 0;
- }
- CString str;
- str.Format("照片:%d 占用空间:%dM", m_nphotos4, m_nspase4 / (1024 * 1024));
- GetDlgItem(IDC_STATIC4)->SetWindowText(str);
- m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
- m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
- }
- void CNeroDlg::OnCheck5()
- {
- UpdateData();
- if (m_checkphoto5)
- {
- if (m_checkphoto2)
- m_checkphoto2 = 0;
- UpdateData(false);
- OnCheck2();
- if (m_photoarray5.GetSize() == 0)
- {
- CString path;
- path = g_path2 + "\\";
- path += m_id;
- path += "\\";
- CStringArray dirarray;
- CString str;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- m_photoarray5.Add(str);
- }
- }
- if (m_photoarray5.GetSize() == 0)
- {
- AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
- }
- m_nphotos5 = m_photoarray5.GetSize();
- m_nspase5 = 0;
- for (i = 0; i < m_photoarray5.GetSize(); i++)
- {
- CFile fp;
- if (fp.Open(m_photoarray5.ElementAt(i), CFile::modeRead))
- {
- m_nspase5 += fp.GetLength();
- fp.Close();
- }
- }
- m_nspase5temp = m_nspase5;
- }
- else
- {
- m_nphotos5 = m_photoarray5.GetSize();
- m_nspase5 = m_nspase5temp;
- }
- }
- else
- {
- m_nphotos5 = 0;
- m_nspase5 = 0;
- }
- CString str;
- str.Format("照片:%d 占用空间:%dM", m_nphotos5, m_nspase5 / (1024 * 1024));
- GetDlgItem(IDC_STATIC5)->SetWindowText(str);
- m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
- m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
- }
- void CNeroDlg::OnCheck6()
- {
- UpdateData();
- if (m_checkphoto6)
- {
- if (m_photoarray6.GetSize() == 0)
- {
- CString path;
- path = g_path3 + "\\";
- path += m_id;
- path += "\\";
- CStringArray dirarray;
- CString str;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(path), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- }
- }
- for (int i = 0; i < dirarray.GetSize(); i++)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- m_photoarray6.Add(str);
- }
- }
- if (m_photoarray6.GetSize() == 0)
- {
- AfxMessageBox("警告:此单未导片!", MB_ICONSTOP);
- }
- m_nphotos6 = m_photoarray6.GetSize();
- m_nspase6 = 0;
- for (i = 0; i < m_photoarray6.GetSize(); i++)
- {
- CFile fp;
- if (fp.Open(m_photoarray6.ElementAt(i), CFile::modeRead))
- {
- m_nspase6 += fp.GetLength();
- fp.Close();
- }
- }
- m_nspase6temp = m_nspase6;
- }
- else
- {
- m_nphotos6 = m_photoarray6.GetSize();
- m_nspase6 = m_nspase6temp;
- }
- }
- else
- {
- m_nphotos6 = 0;
- m_nspase6 = 0;
- }
- CString str;
- str.Format("照片:%d 占用空间:%dM", m_nphotos6, m_nspase6 / (1024 * 1024));
- GetDlgItem(IDC_STATIC6)->SetWindowText(str);
- m_nphotos = m_nphotos1 + m_nphotos2 + m_nphotos3 + m_nphotos4 + m_nphotos5 + m_nphotos6;
- m_nspase = (m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6) / (1024 * 1024);
- }
- void CNeroDlg::GetNo(CString str, CStringArray &array)
- {
- if (!str.IsEmpty())
- {
- int pos = str.Find(",");
- while (pos != -1)
- {
- if (FindArray(&array, str.Left(pos)) == -1)
- array.Add(str.Left(pos));
- str = str.Right(str.GetLength() - pos - 1);
- pos = str.Find(",");
- }
- if (FindArray(&array, str) == -1)
- array.Add(str);
- }
- }
- extern bool SleepEx(DWORD dwMilliseconds);
- void CNeroDlg::OnOK()
- {
- ::DeleteDirectory(g_mainpath + "\\temp");
- ::CreateDirectory(g_mainpath + "\\temp", NULL);
- UpdateData();
- if (m_bScale)
- {
- if (!CheckDiskSpase())return;
- }
- if (m_nphotos == 0)
- {
- AfxMessageBox("未选中照片!", MB_ICONSTOP);
- return;
- }
- if (m_nspase > 650 && m_bDvd == 0 && m_bScale == 0)
- {
- AfxMessageBox("光盘空间不足!", MB_ICONSTOP);
- return;
- }
- m_Burn.m_DirArray.RemoveAll();
- m_Burn.m_DirRealNameArray.RemoveAll();
- CArray<BOOL, BOOL>bIsSelectDirArray;
- GetDlgItem(IDOK)->SetWindowText("刻录中, 请稍候...");
- GetDlgItem(IDOK)->EnableWindow(0);
- if (NowDoingBurn)
- return;
- CStringArray dirarray;
- using namespace helper_coffs;
- CStringArray srcarray;
- if (m_bFromDir)
- {
- CString str;
- GetDlgItemText(IDC_EDIT1, str);
- str.TrimRight('\\');
- m_Burn.m_DirArray.Add(str);
- m_Burn.m_DirRealNameArray.Add(str);
- bIsSelectDirArray.Add(0);
- }
- else
- {
- if (m_checkphoto1)
- {
- if (m_realpath == g_path1 && m_checkphoto4)
- {
- SetDlgItemText(IDC_STATICTip, "照片复制中...");
- m_Progress.SetRange(0, m_photoarray1.GetSize());
- CString path = g_mainpath + "\\temp\\" + m_id + "(精修)";
- ::CreateDirectory(path, NULL);
- CString str;
- for (int i = 0; i < m_photoarray1.GetSize(); i++)
- {
- str = m_photoarray1.ElementAt(i);
- ::CopyFile(str, path + str.Right(str.GetLength() - str.ReverseFind('\\')), 0);
- m_Progress.SetPos(i);
- }
- m_Burn.m_DirArray.Add(path);
- m_Burn.m_DirRealNameArray.Add(path);
- bIsSelectDirArray.Add(0);
- }
- else
- {
- m_Burn.m_DirArray.Add(m_realpath + "\\" + m_id);
- m_Burn.m_DirRealNameArray.Add(m_realpath + "\\" + m_id + "(精修)");
- if (m_realpath == g_path4)
- bIsSelectDirArray.Add(0);
- else
- bIsSelectDirArray.Add(1);
- }
- }
- if (m_checkphoto5)
- {
- m_Burn.m_DirArray.Add(g_path2 + "\\" + m_id);
- m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_id + "(初修)");
- bIsSelectDirArray.Add(0);
- }
- if (m_checkphoto4)
- {
- m_Burn.m_DirArray.Add(g_path1 + "\\" + m_id);
- m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_id + "(原片)");
- bIsSelectDirArray.Add(0);
- }
- if (m_checkphoto6)
- {
- m_Burn.m_DirArray.Add(g_path3 + "\\" + m_id);
- m_Burn.m_DirRealNameArray.Add(g_path3 + "\\" + m_id + "(设计片)");
- bIsSelectDirArray.Add(0);
- }
- }
- DWORD nNeedSpase = 0;
- if (m_bScale)
- {
- SetDlgItemText(IDC_STATICTip, "照片裁切中...");
- int pos = m_combo1.GetCurSel();
- CStringArray needsaclearray;
- CStringArray dirarray;
- for (int i = 0; i < m_Burn.m_DirArray.GetSize(); i++)
- {
- GenSPhoto(m_Burn.m_DirArray.ElementAt(i), m_Burn.m_DirRealNameArray.ElementAt(i).Right(6), needsaclearray, dirarray);
- }
- m_Progress.SetRange(0, needsaclearray.GetSize());
- for (i = 0; i < needsaclearray.GetSize(); i++)
- {
- CString str = needsaclearray.ElementAt(i);
- CString dir;
- dir = dirarray.ElementAt(i);
- Image *img = NULL;
- ::LoadImageFromBuf(&img, str);
- if (img->GetWidth())
- {
- CRect rc(0, 0, 800, 800);
- if (pos == 0)
- {
- rc.right = 1600;
- rc.bottom = 1600;
- }
- else if (pos == 1)
- {
- rc.right = 1024;
- rc.bottom = 1024;
- }
- else if (pos == 2)
- {
- rc.right = 800;
- rc.bottom = 800;
- }
- else
- {
- rc.right = 640;
- rc.bottom = 640;
- }
- RectFitDes(img->GetWidth(), img->GetHeight(), rc);
- Image *simg = img->GetThumbnailImage(rc.Width(), rc.Height(), NULL, NULL);
- Graphics graphic(simg);
- graphic.DrawImage(img, 0, 0, simg->GetWidth(), simg->GetHeight());
- delete img;
- CString savepath = dir + "\\" + ::GetFileNameFromPath(str) + ".jpg";
- ::SaveImageToFile(simg, savepath);
- delete simg;
- CFile fp;
- if (fp.Open(savepath, CFile::modeRead))
- {
- nNeedSpase += fp.GetLength();
- fp.Close();
- }
- else
- {
-
- str.Format("原片%s裁剪失败, 请查看此照片是否损坏。", savepath.Right(savepath.GetLength() - savepath.ReverseFind('\\') - 1));
- AfxMessageBox(str);
- }
- }
- m_Progress.SetPos(i + 1);
- ::SleepEx(10);
- }
- if (::CheckFolderFileExist(g_mainpath + "\\temp\\" + m_id + "(未选的照片)"))
- {
- m_Burn.m_DirArray.Add(g_mainpath + "\\temp\\" + m_id + "(未选的照片)");
- m_Burn.m_DirRealNameArray.Add(g_mainpath + "\\temp\\" + m_id + "(未选的照片)");
- bIsSelectDirArray.Add(0);
- }
- }
- SetDlgItemText(IDC_STATICTip, "光盘刻录中...");
- CString str;
- CArray<BOOL, BOOL>bIsSelectDirArray2;
- for (int i = 0; i < m_Burn.m_DirArray.GetSize(); i++)
- {
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_Burn.m_DirArray.ElementAt(i)), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- str.TrimRight("\\");
- if (FindArray(&dirarray, str) == -1)
- {
- dirarray.Add(str);
- bIsSelectDirArray2.Add(bIsSelectDirArray.ElementAt(i));
- }
- }
- }
- int addcount = 0;
- if (m_bFromDir == 0)
- {
- if (m_checkphoto2)addcount++;
- if (m_checkphoto3)addcount++;
- }
- if ((dirarray.GetSize() + addcount) == 0)return;
- CStringArray *photosarray = new CStringArray[dirarray.GetSize() + addcount];
- for (i = 0; i < dirarray.GetSize(); i++)
- {
- GenSPhoto(dirarray.ElementAt(i), photosarray[i], nNeedSpase, bIsSelectDirArray2.ElementAt(i));
- }
- if (m_bFromDir == 0)
- {
- int pos = dirarray.GetSize();
- if (m_checkphoto2)
- {
- m_Burn.m_DirArray.Add(g_path2 + "\\" + m_id);
- m_Burn.m_DirRealNameArray.Add(g_path2 + "\\" + m_id + "(初修)");
- dirarray.Add(g_path2 + "\\" + m_id);
- photosarray[pos].Copy(m_photoarray2);
- pos++;
- nNeedSpase += m_nspase1;
- }
- if (m_checkphoto3)
- {
- m_Burn.m_DirArray.Add(g_path1 + "\\" + m_id);
- m_Burn.m_DirRealNameArray.Add(g_path1 + "\\" + m_id + "(原片)");
- dirarray.Add(g_path1 + "\\" + m_id);
- photosarray[pos].Copy(m_photoarray3);
- nNeedSpase += m_nspase2;
- }
- }
- if (m_bScale)
- {
- nNeedSpase /= 1024 * 1024;
- if (nNeedSpase > 650 && m_bDvd == 0)
- {
- AfxMessageBox("光盘空间不足!", MB_ICONSTOP); delete[]photosarray;
- return;
- }
- }
- m_Burn.m_pDir = &dirarray;
- m_Burn.m_pPhotoArray = photosarray;
- if (m_Burn.NeroAPIInit() == 0)
- {
- m_Burn.NeroWorkError = 1;
- delete[]photosarray;
- return;
- }
- m_Burn.m_name = m_name;
- m_Burn.m_bDvd = m_bDvd;
- m_Burn.NeroAPIBurn();
- NowDoingBurn = true;
- delete[]photosarray;
- ::DeleteDirectory(g_mainpath + "\\temp");
- if (m_Burn.NeroWorkError == 0)
- {
- CDialog::OnOK();
- }
- else
- CDialog::OnCancel();
- }
- void CNeroDlg::OnCheck7()
- {
-
- UpdateData();
- CString version = _T("Version 1.0");
- AfxGetApp()->WriteProfileInt(version, "cutphoto", m_bScale);
- }
- BOOL CNeroDlg::CheckDiskSpase()
- {
- CString sDrive = g_mainpath.Left(2);
- DWORD dwTotalDiskSpace, dwFreeDiskSpace, dwUsedDiskSpace;
- ULARGE_INTEGER uiFreeBytesAvailableToCaller;
- ULARGE_INTEGER uiTotalNumberOfBytes;
- ULARGE_INTEGER uiTotalNumberOfFreeBytes;
- if (GetDiskFreeSpaceEx(sDrive, &uiFreeBytesAvailableToCaller,
- &uiTotalNumberOfBytes,
- &uiTotalNumberOfFreeBytes))
- {
- dwTotalDiskSpace = (DWORD)(uiTotalNumberOfBytes.QuadPart / 1024 / 1024);
- dwFreeDiskSpace = (DWORD)(uiFreeBytesAvailableToCaller.QuadPart >> 20);
- dwUsedDiskSpace = dwTotalDiskSpace - dwFreeDiskSpace;
- }
- if (dwFreeDiskSpace > 600)return 1;
- AfxMessageBox("磁盘空间不足!", MB_ICONSTOP);
- return 0;
- }
- void CNeroDlg::OnCloseupCombo1()
- {
-
- int pos = m_combo1.GetCurSel();
- if (pos != -1)
- {
- CString version = _T("Version 1.0");
- AfxGetApp()->WriteProfileInt(version, "cutphotosize", pos);
- }
- }
- void CNeroDlg::OnRadio1()
- {
-
- OnRadio2();
- }
- void CNeroDlg::OnRadio2()
- {
-
- UpdateData();
- CString version = _T("Version 1.0");
- AfxGetApp()->WriteProfileInt(version, "bDvd", m_bDvd);
- }
- void CNeroDlg::OnDestroy()
- {
- UpdateData();
- CString version = _T("Version 1.0");
- AfxGetApp()->WriteProfileInt(version, "m_checkphoto1", m_checkphoto1);
- AfxGetApp()->WriteProfileInt(version, "m_checkphoto2", m_checkphoto2);
- AfxGetApp()->WriteProfileInt(version, "m_checkphoto3", m_checkphoto3);
- AfxGetApp()->WriteProfileInt(version, "m_checkphoto4", m_checkphoto4);
- AfxGetApp()->WriteProfileInt(version, "m_checkphoto5", m_checkphoto5);
- AfxGetApp()->WriteProfileInt(version, "m_checkphoto6", m_checkphoto6);
-
- CDialog::OnDestroy();
- }
- BOOL CopyFolder(CString strSrcPath, CString strDstPath)
- {
-
- if (strSrcPath.Right(1) == "\\")
- {
- strSrcPath = strSrcPath.Left(strSrcPath.GetLength() - 1);
- }
- if (strDstPath.Right(1) == "\\")
- {
- strDstPath = strDstPath.Left(strDstPath.GetLength() - 1);
- }
- CreateDirectory(strDstPath, NULL);
- CFileFind finder;
-
- BOOL bWorking = finder.FindFile(strSrcPath + "\\" + "*.*");
- while (bWorking)
- {
-
- bWorking = finder.FindNextFile();
- CString strFileName = finder.GetFileName();
- CString strSrc = strSrcPath + "\\" + strFileName;
- CString strDst = strDstPath + "\\" + strFileName;
-
- if (!finder.IsDots())
- {
-
- if (finder.IsDirectory())
- {
-
- if (!CopyFolder(strSrc, strDst))
- {
- return false;
- }
- }
- else
- {
-
- if (!CopyFile(strSrc, strDst, FALSE))
- {
- return false;
- }
- }
- }
- }
- return true;
- }
- void CNeroDlg::OnBnClickedExporttou()
- {
-
- EndofThread();
-
- BROWSEINFO bi;
- char Buffer[MAX_PATH];
-
- bi.hwndOwner = NULL;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = Buffer;
- bi.lpszTitle = "修改接收路径";
-
- bi.ulFlags = BIF_EDITBOX | BIF_USENEWUI;
- bi.lpfn = NULL;
- bi.iImage = IDR_MAINFRAME;
-
- LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);
- if (pIDList)
- {
- if (!SHGetPathFromIDList(pIDList, Buffer))
- return;
-
-
- m_strUFolder = Buffer;
- }
- else
- return;
- LPMALLOC lpMalloc;
- if (FAILED(SHGetMalloc(&lpMalloc)))
- return;
- lpMalloc->Free(pIDList);
- lpMalloc->Release();
-
-
- BYTE bAlpha = m_strUFolder.GetAt(0);
- if (m_strUFolder.GetLength() != m_strUFolder.ReverseFind('\\'))
- {
- m_strUFolder += "\\";
- }
-
-
- CString strResult = _T("");
- #if 1
- __int64 iVolumeSize = 0, iVolumeFreeSize = 0;
- #else
- double iVolumeSize = 0.0, iVolumeFreeSize = 0.0;
- #endif
- if (!::IsCharAlpha((TCHAR)bAlpha))
- {
- strResult = _T("驱动器参数无效!");
-
- AfxMessageBox(strResult);
- return;
- }
- else
- {
-
- CString strRootPathName;
- strRootPathName.Format(_T("%c:\\"), bAlpha);
- LPCTSTR lpRootPathName = strRootPathName;
- LPTSTR lpVolumeNameBuffer = new char[_MAX_FNAME];
- DWORD nVolumeNameSize = _MAX_FNAME;
- DWORD nVolumeSerialNumber = 0;
- DWORD nMaximumComponentLength;
- DWORD nFileSystemFlags;
- LPTSTR lpFileSystemNameBuffer = new char[20];
- DWORD nFileSystemNameSize = 20;
- GetVolumeInformation(
- lpRootPathName,
- lpVolumeNameBuffer,
- nVolumeNameSize,
- &nVolumeSerialNumber,
- &nMaximumComponentLength,
- &nFileSystemFlags,
- lpFileSystemNameBuffer,
- nFileSystemNameSize);
-
- CString strDriveType;
-
- LPCTSTR lpDirectoryName = new char[2];
- lpDirectoryName = (LPCTSTR)strRootPathName.Mid(0, 2);
- _ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
- GetDiskFreeSpaceEx(strRootPathName.Mid(0, 2), &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes);
- #if 0
- iVolumeSize = (double)TotalNumberOfBytes.QuadPart / 1024 / 1024;
- iVolumeFreeSize = (double)FreeBytesAvailable.QuadPart / 1024 / 1024;
- #else
- iVolumeSize = TotalNumberOfBytes.QuadPart;
- iVolumeFreeSize = FreeBytesAvailable.QuadPart;
- #endif
- }
-
- DWORD64 dwTotalSize = m_nspase1 + m_nspase2 + m_nspase3 + m_nspase4 + m_nspase5 + m_nspase6;
- if ((iVolumeFreeSize <= dwTotalSize) || (iVolumeFreeSize - dwTotalSize < 1024 * 10))
- {
- AfxMessageBox("U盘容量不足!");
- return;
- }
-
-
- CString strOrderFolder = _T("");
-
- DWORD nTotalFiles = m_photoarray1.GetSize() + m_photoarray6.GetSize() + m_photoarray5.GetSize() + m_photoarray4.GetSize();
- m_Progress.SetRange(0, nTotalFiles);
-
- StartThread();
- GetDlgItem(Btn_ExportToU)->EnableWindow(FALSE);
- }
- DWORD WINAPI CNeroDlg::ExportImageThread(LPVOID lpParam)
- {
- CNeroDlg *pExportImageImpl = (CNeroDlg*)lpParam;
- int nIndexOfProcess = 0;
- CString strImageName = _T("");
- CString strOrderFolder = _T("");
- strOrderFolder.Format("%s%s\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
- if (pExportImageImpl->m_bScale)
- {
- int nX = 0, nY = 0;
- int nPos = pExportImageImpl->m_combo1.GetCurSel();
- if (nPos == 0)
- {
- nY = 1200;
- nX = 1600;
- }
- else if (nPos == 1)
- {
- nY = 768;
- nX = 1024;
- }
- else if (nPos = 2)
- {
- nY = 600;
- nX = 800;
- }
- else if (nPos == 3)
- {
- nY = 480;
- nX = 640;
- }
-
- if (pExportImageImpl->m_checkphoto1)
- {
- strOrderFolder.Format("%s%s\\精修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
-
- int nSize = pExportImageImpl->m_photoarray1.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1));
-
- ToCompressImage(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, nX, nY);
- pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
- }
- }
- if (pExportImageImpl->m_checkphoto6)
- {
- strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
- int nSize = pExportImageImpl->m_photoarray6.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1));
-
- ToCompressImage(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, nX, nY);
- pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
- }
- }
- if (pExportImageImpl->m_checkphoto5)
- {
- strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
-
- int nSize = pExportImageImpl->m_photoarray5.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1));
- ToCompressImage(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, nX, nY);
- pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
- }
- }
- if (pExportImageImpl->m_checkphoto4)
- {
- strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
-
- int nSize = pExportImageImpl->m_photoarray4.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1));
- ToCompressImage(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, nX, nY);
- pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
- }
- }
- }
- else
- {
- if (pExportImageImpl->m_checkphoto1)
- {
- strOrderFolder.Format("%s%s\\精修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
- int nSize = pExportImageImpl->m_photoarray1.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray1.ElementAt(i).Right(pExportImageImpl->m_photoarray1.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray1.ElementAt(i).ReverseFind('\\') - 1));
- ::CopyFile(pExportImageImpl->m_photoarray1.ElementAt(i), strImageName, 0);
- pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
- }
- }
- if (pExportImageImpl->m_checkphoto6)
- {
- strOrderFolder.Format("%s%s\\设计片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
- int nSize = pExportImageImpl->m_photoarray6.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray6.ElementAt(i).Right(pExportImageImpl->m_photoarray6.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray6.ElementAt(i).ReverseFind('\\') - 1));
- ::CopyFile(pExportImageImpl->m_photoarray6.ElementAt(i), strImageName, 0);
- pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
- }
- }
- if (pExportImageImpl->m_checkphoto5)
- {
- strOrderFolder.Format("%s%s\\初修片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
- int nSize = pExportImageImpl->m_photoarray5.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray5.ElementAt(i).Right(pExportImageImpl->m_photoarray5.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray5.ElementAt(i).ReverseFind('\\') - 1));
- ::CopyFile(pExportImageImpl->m_photoarray5.ElementAt(i), strImageName, 0);
- pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
- }
- }
- if (pExportImageImpl->m_checkphoto4)
- {
- strOrderFolder.Format("%s%s\\原片\\", pExportImageImpl->m_strUFolder, pExportImageImpl->m_id);
- ::CreateDirectory(strOrderFolder, NULL);
- int nSize = pExportImageImpl->m_photoarray4.GetSize();
- for (int i = 0; i < nSize; i++)
- {
- strImageName.Format("%s%s", strOrderFolder, pExportImageImpl->m_photoarray4.ElementAt(i).Right(pExportImageImpl->m_photoarray4.ElementAt(i).GetLength() - pExportImageImpl->m_photoarray4.ElementAt(i).ReverseFind('\\') - 1));
- ::CopyFile(pExportImageImpl->m_photoarray4.ElementAt(i), strImageName, 0);
- pExportImageImpl->m_Progress.SetPos(++nIndexOfProcess);
- }
- }
- }
- Sleep(1000);
- AfxMessageBox("导出完毕!");
- pExportImageImpl->GetDlgItem(Btn_ExportToU)->EnableWindow(TRUE);
- pExportImageImpl->m_Progress.SetRange(0, 0);
-
- return 0;
- }
- int CNeroDlg::StartThread()
- {
- m_hCtrl = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (m_hCtrl == NULL)
- {
-
-
- return -1;
- }
-
- m_hThread = CreateThread(NULL, 0, ExportImageThread, this, 0, NULL);
- if (m_hThread == NULL)
- {
-
- return -1;
- }
-
- m_bThreadRuning = TRUE;
- return 0;
- }
- int CNeroDlg::EndofThread()
- {
-
- if (m_hCtrl)
- {
- SetEvent(m_hCtrl);
- }
- if (m_hThread)
- {
- if (WaitForSingleObject(m_hThread, INFINITE) != WAIT_TIMEOUT)
- {
- CloseHandle(m_hThread);
- m_hThread = NULL;
- }
- }
- m_bThreadRuning = FALSE;
- CloseHandle(m_hCtrl);
- m_hCtrl = NULL;
- return 0;
- }
- void CNeroDlg::ToCompressImage(__in const TCHAR *pImageSource, __in const TCHAR *pImageDest, __in const int &nXPiexel, __in const int &nYPiexel)
- {
-
- #if 1
- Image *pImage = NULL;
- #else
- Bitmap *pImage = NULL;
- #endif
-
- CFile cf;
- if (cf.Open(pImageSource, CFile::modeRead))
- {
- DWORD dwLength = cf.GetLength();
- BYTE *pData = new BYTE[dwLength];
- if (pData == NULL)
- {
-
- return;
- }
- cf.Read(pData, dwLength);
- cf.Close();
-
- HGLOBAL taghMem = GlobalAlloc(GMEM_MOVEABLE, dwLength);
- if (taghMem == NULL)
- {
-
- return;
- }
- BYTE *pMem = (BYTE*)GlobalLock(taghMem);
- memcpy(pMem, pData, dwLength);
-
- IStream *pStream;
- CreateStreamOnHGlobal(taghMem, TRUE, &pStream);
- #if 1
- pImage = Gdiplus::Image::FromStream(pStream);
- #else
- pImage = Gdiplus::Bitmap::FromStream(pStream);
- #endif
- GlobalUnlock(taghMem);
- pStream->Release();
- delete[]pData;
- }
- else
- {
-
- }
-
- if (pImage == NULL)
- {
-
- return;
- }
-
- if (pImage->GetWidth() > nXPiexel || pImage->GetHeight() > nYPiexel)
- {
- CRect tagRect(0, 0, nXPiexel, nYPiexel);
- RectFitDes_01(pImage->GetWidth(), pImage->GetHeight(), tagRect);
- Image *RtImage = pImage->GetThumbnailImage(tagRect.Width(), tagRect.Height(), NULL, NULL);
- Graphics graphic(RtImage);
- delete pImage;
- SaveImageToFile(RtImage, pImageDest);
- delete RtImage;
- }
- else
- {
- ::CopyFile(pImageSource, pImageDest, 0);
- }
- }
- void CNeroDlg::RectFitDes_01(__in const int &nWidth, __in const int &nHeight, __inout CRect &rc)
- {
- try
- {
- if (nWidth == 0 || nHeight == 0)return;
-
- float fscale = (float)nWidth / (float)nHeight;
-
- float rcscale = ((float)rc.Width()) / ((float)rc.Height());
- int rcwid = rc.Width();
- int rchei = rc.Height();
- int dt = 0;
-
- if (rcscale < fscale)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
- dt = (rcwid - rchei*fscale) / 2;
- rc.left += dt;
- rc.right -= dt;
- }
- else
- {
- dt = (rchei - rcwid / fscale) / 2;
- rc.top += dt;
- rc.bottom -= dt;
- }
- }
- catch (...)
- {
- }
- }
- void CNeroDlg::SaveImageToFile(__in Image *img, __in CString path)
- {
- try
- {
- if (img == NULL)
- {
-
- return;
- }
- CLSID encoderClsid;
- BSTR bstr = path.AllocSysString();
- path.MakeLower();
- if (path.Right(3) == "bmp")
- {
- GetEncoderClsid(L"image/bmp", &encoderClsid);
- img->Save(bstr, &encoderClsid, NULL);
- }
- else if (path.Right(3) == "png")
- {
- GetEncoderClsid(L"image/png", &encoderClsid);
- img->Save(bstr, &encoderClsid, NULL);
- }
- else
- {
- GetEncoderClsid(L"image/jpeg", &encoderClsid);
- EncoderParameters encoderParameters;
- ULONG quality;
- encoderParameters.Count = 1;
- encoderParameters.Parameter[0].Guid = EncoderQuality;
- encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
- encoderParameters.Parameter[0].NumberOfValues = 1;
-
- quality = 100;
- encoderParameters.Parameter[0].Value = &quality;
- img->Save(bstr, &encoderClsid, &encoderParameters);
- }
- SysFreeString(bstr);
- }
- catch (...)
- {
- }
- }
- int CNeroDlg::GetEncoderClsid(__in const WCHAR* format, __inout CLSID* pClsid)
- {
- UINT num = 0;
- UINT size = 0;
- ImageCodecInfo* pImageCodecInfo = NULL;
- GetImageEncodersSize(&num, &size);
- if (size == 0)
- return -1;
- pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
- if (pImageCodecInfo == NULL)
- return -1;
- GetImageEncoders(num, size, pImageCodecInfo);
- for (UINT j = 0; j < num; ++j)
- {
- if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
- {
- *pClsid = pImageCodecInfo[j].Clsid;
- free(pImageCodecInfo);
- return j;
- }
- }
- free(pImageCodecInfo);
- return -1;
- }
|