BOOL CMUSHclientDoc::Save_Set (const int set_type, CWnd * parent_window) { CString suggested_name = m_mush_name, filter, title, suggested_extension; CFile * f = NULL; CArchive * ar = NULL; BOOL error = TRUE; CString sig; CString filename; if (Set_Up_Set_Strings (set_type, suggested_name, filter, title, suggested_extension)) return TRUE; // bad set_type CFileDialog filedlg (FALSE, // saving the file suggested_extension, // default extension "", // suggested name OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, // filter parent_window); // parent window // fix up name to remove characters that are invalid int i; while ((i = suggested_name.FindOneOf ("<>\"|?:#%;/\\")) != -1) suggested_name = suggested_name.Left (i) + suggested_name.Mid (i + 1); filedlg.m_ofn.lpstrTitle = title; filedlg.m_ofn.lpstrFile = filename.GetBuffer (_MAX_PATH); // needed!! (for Win32s) if (App.platform == VER_PLATFORM_WIN32s) strcpy (filedlg.m_ofn.lpstrFile, ""); else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ChangeToFileBrowsingDirectory (); int nResult = filedlg.DoModal(); ChangeToStartupDirectory (); if (nResult != IDOK) return TRUE; // cancelled dialog CPlugin * pSavedPlugin = m_CurrentPlugin; m_CurrentPlugin = NULL; // make sure we save main triggers etc. try { f = new CFile (filedlg.GetPathName (), CFile::modeCreate | CFile::modeReadWrite); ar = new CArchive(f, CArchive::store); switch (set_type) { case TRIGGER: Save_World_XML (*ar, XML_TRIGGERS); break; case ALIAS: Save_World_XML (*ar, XML_ALIASES); break; case COLOUR: Save_World_XML (*ar, XML_COLOURS); break; case MACRO: Save_World_XML (*ar, XML_MACROS); break; case TIMER: Save_World_XML (*ar, XML_TIMERS); break; } // end of switch error = FALSE; } // end of try block catch (CFileException * e) { ::TMessageBox ("Unable to create the requested file", MB_ICONEXCLAMATION); e->Delete (); } // end of catching a file exception catch (CMemoryException * e) { ::TMessageBox ("Insufficient memory to do this operation", MB_ICONEXCLAMATION); e->Delete (); } // end of catching a memory exception catch (CArchiveException * e) { ::TMessageBox ("There was a problem in the data format", MB_ICONEXCLAMATION); e->Delete (); } // end of catching an archive exception m_CurrentPlugin = pSavedPlugin; delete ar; // delete archive delete f; // delete file return error; // OK return } // end of CMUSHclientDoc::save_set
void CDfuFileMgrDlgExtract::OnButtonopen() { TCHAR szFilters[]= "Dfu Files (*.dfu)|*.dfu|All Files (*.*)|*.*||"; char Path[MAX_PATH]; char Tmp[MAX_PATH]; char *pTmp; GetModuleFileName(NULL, Path, MAX_PATH); strrev(Path); pTmp = strchr(Path, '\\'); strrev(pTmp); lstrcpy(Tmp, pTmp); lstrcpy(Path, Tmp); lstrcat(Path, "*.dfu"); CFileDialog* dlg; dlg = new CFileDialog(TRUE, _T("dfu"), _T("*.dfu"), OFN_FILEMUSTEXIST, szFilters, this); UpdateData(TRUE); m_ListFiles.ResetContent(); if (dlg->DoModal()==IDOK) { BYTE Alts; WORD Vid; WORD Pid; WORD Bcd; if (m_hFile!=0) STDFUFILES_CloseDFUFile(m_hFile); if (STDFUFILES_OpenExistingDFUFile((LPSTR)(LPCSTR)dlg->GetPathName(), &m_hFile, &Vid, &Pid, &Bcd, &Alts) == STDFUFILES_NOERROR) { BYTE Alt; CString Tmp, Tmp1; m_Pid.Format("%04X", Pid); m_Vid.Format("%04X", Vid); m_Bcd.Format("%04X", Bcd); m_FileBaseName=dlg->GetPathName().Left(dlg->GetPathName().GetLength()-4); m_DfuFile = dlg->GetPathName(); UpdateData(FALSE); for (BYTE i=0;i<Alts;i++) { HANDLE Image; CString Tmp; if (STDFUFILES_ReadImageFromDFUFile(m_hFile, i, &Image)==STDFUFILES_NOERROR) { char Name[512]; STDFUFILES_GetImageAlternate(Image, &Alt); STDFUFILES_GetImageName(Image, Name); STDFUFILES_DestroyImage(&Image); Tmp.Format("Image for Target ID %02i", Alt); if (Name[0]!='\0') { Tmp+=" ("; Tmp+=Name; Tmp+=")"; } m_ListFiles.AddString(Tmp); } else { AfxMessageBox("Unable to read images in file..."); break; } if(m_ListFiles.GetCount()>0) m_ListFiles.SetCurSel(0); } } else AfxMessageBox("Error... Maybe bad or old file format"); } }
BOOL CMUSHclientDoc::Load_Set (const int set_type, CString strFileName, CWnd * parent_window) { BOOL replace = TRUE; if (strFileName.IsEmpty ()) { CString suggested_name = m_mush_name, filter, title, suggested_extension; CString filename; if (Set_Up_Set_Strings (set_type, suggested_name, filter, title, suggested_extension)) return TRUE; // bad set_type CFileDialog filedlg (TRUE, // loading the file suggested_extension, // default extension "", // suggested name OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, filter, // filter parent_window); // parent window filedlg.m_ofn.lpstrTitle = title; filedlg.m_ofn.lpstrFile = filename.GetBuffer (_MAX_PATH); // needed!! (for Win32s) if (App.platform == VER_PLATFORM_WIN32s) strcpy (filedlg.m_ofn.lpstrFile, ""); else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ChangeToFileBrowsingDirectory (); int nResult = filedlg.DoModal(); ChangeToStartupDirectory (); if (nResult!= IDOK) return TRUE; // cancelled dialog // since they can have any number of triggers, aliases and timers, ask them // whether they want to add this file to an existing list (if any) if (set_type == TRIGGER && !m_TriggerMap.IsEmpty ()) { if (::TMessageBox ("Replace existing triggers?\n" "If you reply \"No\", then triggers from the file" " will be added to existing triggers", MB_YESNO | MB_ICONQUESTION) == IDNO) replace = FALSE; } else if (set_type == ALIAS && !m_AliasMap.IsEmpty ()) { if (::TMessageBox ("Replace existing aliases?\n" "If you reply \"No\", then aliases from the file" " will be added to existing aliases", MB_YESNO | MB_ICONQUESTION) == IDNO) replace = FALSE; } else if (set_type == TIMER && !m_TimerMap.IsEmpty ()) { if (::TMessageBox ("Replace existing timers?\n" "If you reply \"No\", then timers from the file" " will be added to existing timers", MB_YESNO | MB_ICONQUESTION) == IDNO) replace = FALSE; } strFileName = filedlg.GetPathName (); } // end of no filename suppliedl CFile * f = NULL; CArchive * ar = NULL; try { f = new CFile (strFileName, CFile::modeRead | CFile::shareDenyWrite); ar = new CArchive(f, CArchive::load); if (IsArchiveXML (*ar)) { switch (set_type) { case TRIGGER: if (replace) DELETE_MAP (m_TriggerMap, CTrigger); Load_World_XML (*ar, XML_TRIGGERS | XML_NO_PLUGINS); break; case ALIAS: if (replace) DELETE_MAP (m_AliasMap, CAlias); Load_World_XML (*ar, XML_ALIASES | XML_NO_PLUGINS); break; case COLOUR: Load_World_XML (*ar, XML_COLOURS | XML_NO_PLUGINS); break; case MACRO: Load_World_XML (*ar, XML_MACROS | XML_NO_PLUGINS); break; case TIMER: if (replace) DELETE_MAP (m_TimerMap, CTimer); Load_World_XML (*ar, XML_TIMERS | XML_NO_PLUGINS); break; } // end of switch } // end of XML load else { ::TMessageBox ("File does not have a valid MUSHclient XML signature.", MB_ICONSTOP); AfxThrowArchiveException (CArchiveException::badSchema); } // end of not XML } // end of try block // even on an exception we will return a "good" status, because the triggers etc. // may well have been deleted by now, so we need to redraw the lists catch (CFileException * e) { ::UMessageBox (TFormat ("Unable to open or read %s", (LPCTSTR) strFileName), MB_ICONEXCLAMATION); e->Delete (); } // end of catching a file exception catch (CMemoryException * e) { ::TMessageBox ("Insufficient memory to do this operation", MB_ICONEXCLAMATION); e->Delete (); } // end of catching a memory exception catch (CArchiveException * e) { ::UMessageBox (TFormat ("The file %s is not in the correct format", (LPCTSTR) strFileName), MB_ICONEXCLAMATION); e->Delete (); } // end of catching an archive exception delete ar; // delete archive delete f; // delete file SetModifiedFlag (TRUE); // document has now changed return false; // OK return } // end of CMUSHclientDoc::load_set
void CGUIFaceInVideoView::OnDraw(CDC* pDC) { CGUIFaceInVideoDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (pDoc == NULL) return; CIplImage *pImgIn; CvPoint *pPointL, *pPointR; int nNameTag, nBestMatch; char strMessage[200]; CPerceptualVisionSystem *pPVS = pDoc->getPVS(); bool bRes = pPVS->initializeNextFrame(); if (bRes == false) return; // if want to show it but not process it, change it. sprintf(strMessage, "%i msec", pPVS->m_tBetweenFrames); OnDraw_LogWindow(pDC, strMessage, set_window(0,0), 0); pDoc->m_gui.check_start = pDoc->m_gui.check_start; if (pDoc->m_gui.check_start == true) { int z; for (z=0; z < pPVS->m_pianoPlaying.m_nNumHands; z++) pPVS->m_pianoPlaying.m_Hand[z].destroy(); pPVS->m_pianoPlaying.m_nNumHands = 0; } ////////////AVI RECORDING////////////////// if (pDoc->m_recordCheck == true) // For saving video file made of video frames { pPVS->m_imgIn.draw(pDC->m_hDC, set_window(0,3), false, false); OnDraw_LogWindow(pDC, "Start recording..", set_window(0,3), 1); pPVS->m_bRecording = true; if (pPVS->m_bRecordingStarted == false) { // open a dialog box. TCHAR szFilter[] = _T ( "Movie Files (*.avi)" ); CFileDialog *dlg = new CFileDialog( FALSE, _T("avi"), _T("*.avi"), OFN_ENABLESIZING | OFN_OVERWRITEPROMPT, szFilter, (CWnd*)this); char strAviFullName[200], strAviLocalName[200]; if(dlg->DoModal() == IDOK) strcpy(strAviFullName, dlg->GetPathName()); pPVS->m_pCvVideoWriter = NULL; pPVS->m_pCvVideoWriter = cvCreateVideoWriter(strAviFullName, // Uncompressed CV_FOURCC('D','I','B',' '), 10.0, cvSize(160,120) ); pPVS->m_bRecordingStarted = true;// Open AVI file } //Add frame to AVI if (pPVS->m_pCvVideoWriter) cvWriteFrame( pPVS->m_pCvVideoWriter, pPVS->m_imgIn.getIplImage() ); return; } else { pPVS->m_bRecording = false; if (pPVS->m_bRecordingStarted == true) { pPVS->m_bRecordingStarted = false; // Close AVI if (pPVS->m_pCvVideoWriter) cvReleaseVideoWriter( &pPVS->m_pCvVideoWriter ); } } ////////////////END AVI RECORDING//////////////// /////////////////////// // return; //////// debuging..... /////////////////////// /***************************************************************************************/ /*** Grab data from MIDI **************************************************/ /***************************************************************************************/ int q, keyValue, octave; bool keyChange[200]; // bKeyChanged[nTotalPianoKeys] //To indicate Changes only //For printing Purposes if (m_bMidiCheck==false) { m_Midi->clearAllEvents(); } //DO MIDI INFORMATION if (USING_MIDI == 1 && m_bMidiCheck==true) { //Get MIDI Events m_Midi->getAllEvents(); //Update User Selected Offsets pPVS->m_pianoPlaying.m_Piano.UpdateOctave(m_nKeyOffset, m_nOctave); //No Changes to Start for (q=0; q < 200; q++) keyChange[q] = false; //Go Through All MIDI events for (q=0; q < m_Midi->numNotes; q++) { //If Key Has Been Pressed, set it as True if (keyDown[int(m_Midi->noteArray[q])] == true) { keyDown[int(m_Midi->noteArray[q])] = false; keyChange[int(m_Midi->noteArray[q])] = true; //Indicate Change } //Vice Versa else { keyDown[int(m_Midi->noteArray[q])] = true; keyChange[int(m_Midi->noteArray[q])] = true; //Indicate Change } } }//END MIDI /***************************************************************************************/ /*** Grab data from video camera / AVI **************************************************/ /***************************************************************************************/ sprintf(strMessage, "%i: %i (%i) msec ", pPVS->m_nFrame, pPVS->m_tBetweenFrames, pPVS->m_tBetweenFramesNow); // OnDraw_LogWindow(pDC, strMessage, set_window(0,2), 1); //Motion Channel Calculations pPVS->m_chanMotion.updateImages(&pPVS->m_imgIn); pPVS->m_chanMotion.compute_dI(); pPVS->m_chanMotion.compute_FG(3, 0); //////////////////////////PIANO PLAYING SECTION//////////////////////////// //Update Images pPVS->m_pianoPlaying.updateImages(&pPVS->m_imgIn); //Do Backgorund Initialization && Piano Key (width) Calibration if (runOnce == 0) { pPVS->m_pianoPlaying.setBackgroundImage(&pPVS->m_imgIn); runOnce++; } //Image Adjustment, based on Piano Orientation and Positioning pPVS->m_pianoPlaying.AdjustImages(); //Update Control Values from GUI UpdateControlValues(&(pPVS->m_pianoPlaying)); //Main Piano Playing Function pPVS->m_pianoPlaying.createHandsImage(); m_bDetectHands = false; //Reset Hand Detecting Flag /* // no Filter2D CIplImage img1; // , img2; img1.initializeAs(&pPVS->m_imgBW); // img2.initializeAs(&pPVS->m_imgBW); IplImage *ipl; ipl = cvCreateImage( cvGetSize(pPVS->m_imgBW.getIplImage()), IPL_DEPTH_16S , 1 ); cvAnd(pPVS->m_imgBW.getIplImage(), pPVS->m_pianoPlaying.m_imb_handsImage.getIplImage(), img1.getIplImage()); cvSobel(img1.getIplImage(), ipl, 1,0,3); cvConvert (&ipl, img1.getIplImage()); img1.draw(pDC->m_hDC, set_window(0,3)); img1.destroy(); cvReleaseImage(&ipl); // img2.destroy(); */ #if 1 //<< Clustering CIplImage imc, imcClusters; imc.initializeAs(&pPVS->m_imgIn); imcClusters.initializeAs(&pPVS->m_imgBW); cvZero( imc.getIplImage() ); pImgIn = & pPVS->m_pianoPlaying.m_imb_handsImage; // m_chanColour.m_imbSkinYCrCb; // ; CIplImage *pImgOut = & imcClusters; cvZero( pImgOut->getIplImage()); // pImgIn->draw(pDC->m_hDC, set_window(0,3)); int nClustersDetected, nMaxClusters; // a) PVI_BLOB *blobs = new PVI_BLOB[5]; nMaxClusters = 4; nClustersDetected = detectClusters_wKmeans( pImgIn, pImgOut, nMaxClusters, &nClustersDetected, &blobs); delete blobs; colourizeClusters(*pImgOut, imc, nClustersDetected); imc.draw(pDC->m_hDC, set_window(0,1)); sprintf(strMessage, "%i hands", nClustersDetected); OnDraw_LogWindow(pDC,strMessage, set_window(0,1), 0); /* // nClustersDetected = clusterize_wKmeans( pImgIn, pImgOut, 2, 1, &imc); // imc.draw(pDC->m_hDC, set_window(1,iActiveCamera+1)); // b) int nXclose=4, nYclose=4, nCosine=0; nClustersDetected = detectClusters_wProximity( pImgIn, pImgOut, nXclose, nYclose, nCosine, &imc); imc.draw(pDC->m_hDC, set_window(4,0)); sprintf(strMessage, "%i", nClustersDetected); OnDraw_LogWindow(pDC,strMessage, set_window(4,0), 0); imc.destroy(); imcClusters.destroy(); // if (nClustersDetected > pPVS->m_pianoPlaying.m_nNumHands) // m_bDetectHands = true; */ #endif //>> Clustering /***************************************************************************************/ /*** Use MIDI data do detect hand/finger **************************************************/ /***************************************************************************************/ CvFont cvFont; cvInitFont( &cvFont, CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0.0, 2 ); CvPoint ptBtmLeft; // To do : midi for hand blob detection //DO MIDI INFORMATION if (USING_MIDI == 1 && m_bMidiCheck==true) { char keyPressString[200]; //Printable String int i=0; //Print Counter numStrings=0; //FOR each possible MIDI Key for (q=0; q < 200; q++) { //Calculate Key and Octave Values keyValue = (q) % 12; octave = (q - keyValue)/12; //IF Key is ON if (keyDown[q] == true) { //Get Bounding Box of Key CvRect myRect = pPVS->m_pianoPlaying.m_Piano.ReturnKeyBounds(keyValue, octave); //Select Hand that this Key intersects with int selectedHand = pPVS->m_pianoPlaying.SelectHand(&myRect); //Highlight Selected Key pPVS->m_pianoPlaying.DrawBox(pPVS->m_pianoPlaying.m_imc_displayImage.getIplImage(), myRect.x, myRect.y, myRect.x + myRect.width, myRect.y + myRect.height, 3); //Put Information to String if (selectedHand != -1) { int selectedFinger = pPVS->m_pianoPlaying.m_Hand[selectedHand].SelectFinger(&myRect); if (selectedFinger == -1) sprintf(keyPressString, "MIDI: %d -> Octave: %d, Key: %d -> Hand: %d", q, octave, keyValue, selectedHand); else { sprintf(keyPressString, "MIDI: %d -> Octave: %d, Key: %d -> Hand: %d, Finger: %d", q, octave, keyValue, selectedHand, selectedFinger+1); sprintf(strMessage, "%i", selectedFinger); ptBtmLeft = cvPoint(myRect.x, myRect.y-5); cvPutText( pPVS->m_pianoPlaying.m_imc_displayImage.getIplImage(), strMessage, ptBtmLeft, &cvFont, CV_RGB(0, 200, 200)); } } else sprintf(keyPressString, "MIDI: %d -> Octave: %d, Key: %d", q, octave, keyValue); //IF Key Was JUST Pressed if (keyChange[q] == true) { //Write Information to File fprintf(pPVS->m_pianoPlaying.fDataFile, "%s\n", keyPressString); } //Add String To List if (numStrings < 200) { sprintf(MIDIString[numStrings], "%s", keyPressString); numStrings++; } }//END IF //IF Key is OFF else { //Put Information to String sprintf(keyPressString, "Key Value: %d -> Octave: %d, Key: %d - RELEASED", q, octave, keyValue); //IF Key Was JUST Released if (keyChange[q] == true) //Write Information to File fprintf(pPVS->m_pianoPlaying.fDataFile, "%s\n", keyPressString); }//END ELSE }//END FOR Each Key }//END MIDI /***************************************************************************************/ /*** Draw all **************************************************/ /***************************************************************************************/ //DRAW IMAGES pPVS->m_pianoPlaying.m_imc_displayImage.draw(pDC->m_hDC, set_window(1, 0)); pPVS->m_pianoPlaying.m_imc_backgroundImage.draw(pDC->m_hDC, set_window(2,0)); // pPVS->m_pianoPlaying.m_imb_handsImage.draw(pDC->m_hDC, set_window(3,0)); // pPVS->m_pianoPlaying.m_imb_edgeDetectedImage.draw(pDC->m_hDC, set_window(4,0)); /* pPVS->m_pianoPlaying.m_imb_fingerDetectedImage. draw(pDC->m_hDC, set_window(1,1)); pPVS->m_pianoPlaying.m_imc_displayImage. draw(pDC->m_hDC, set_window(2,1)); pPVS->m_pianoPlaying.m_imc_backgroundImage. draw(pDC->m_hDC, set_window(3,1)); */ pPVS->m_pianoPlaying.m_Piano.boxes.draw(pDC->m_hDC, set_window(1, 1)); pPVS->m_pianoPlaying.m_Piano.polarizedImage.draw(pDC->m_hDC, set_window(2, 1)); //pPVS->m_pianoPlaying.m_ORIMAGE.draw(pDC->m_hDC, set_window(3, 1)); //pPVS->m_pianoPlaying.m_Hand[0].m_edgeImage.draw(pDC->m_hDC, set_window(3, 1)); int f, h; if (pPVS->m_pianoPlaying.m_nNumHands > 0) { h=0; if (pPVS->m_pianoPlaying.m_Hand[h].ready == true) { // pPVS->m_pianoPlaying.m_Hand[h].m_fingImg[f].draw(pDC->m_hDC, set_window(f, h+2)); for (f=0; f < 5; f++) { pPVS->m_pianoPlaying.m_Hand[h].m_fingImg[f].draw(pDC->m_hDC, set_window(f, h+2)); //cvSet( (pPVS->m_imgOut.getIplImage()), CV_RGB(0, 100*h, f*50), // (pPVS->m_pianoPlaying.m_Hand[h].m_fingImg[f].getIplImage())); } } } char clearString[150]; int i; for (i=0; i < 150; i++) clearString[i] = ' '; //////////////////////////END ARJUN//////////////////////////// // // pPVS->m_imgIn.draw(pDC->m_hDC, set_window(0,0), false, false); pPVS->m_imgOut.draw(pDC->m_hDC, set_window(0,0), false, false); nNameTag = pDoc->m_gui.slider4;//-1; // ************************************************************************************************ if (!pDoc->m_gui.check_start) // It has to be checked to start the video processing return; // ************************************************************************************************ pDoc->m_bWorkWithFiles = false; if (m_bTraceMode == true && pDoc->m_gui.check2) // if scenario, wait to continue if (MessageBox("Proceed to next face?",NULL,MB_OKCANCEL) != IDOK) exit(1); }
void CCWArrangePage::OnExportHTML () { m_List.SaveEdit (); GetTracksInfo (); if (m_pTracks == NULL) return; CFileDialog dlg (FALSE, "html"); if (dlg.DoModal () == IDOK) { CStdioFile file (dlg.GetPathName (), CFile::modeCreate | CFile::modeWrite); file.WriteString ("<html>\r\n\t<head>\r\n\t\t<title>Exported Track Listing: " + m_pTracks->GetTitle () + "</title>\r\n\t</head>\r\n\r\n\t<body>\r\n"); if (m_pTracks->GetArtist ().IsEmpty ()) file.WriteString ("\t\t<h1>" + m_pTracks->GetTitle () + "</h1>\r\n"); else file.WriteString ("\t\t<h1>" + m_pTracks->GetArtist () + "</h1>\r\n\t\t<h2>" + m_pTracks->GetTitle () + "</h2>\r\n"); file.WriteString ("\t\t<table border=\"1\">\r\n\t\t\t<tr>\r\n"); file.WriteString ("\t\t\t\t<th>Track</th>\r\n"); file.WriteString ("\t\t\t\t<th>Track title</th>\r\n"); file.WriteString ("\t\t\t\t<th>Track remarks</th>\r\n"); file.WriteString ("\t\t\t\t<th>Track length</th>\r\n"); file.WriteString ("\t\t\t</tr>\r\n\r\n"); for (int i = 0; i < m_pTracks->GetNumTracks (); i++) { CTrack t = m_pTracks->GetTrack (i); file.WriteString ("\t\t\t<tr>\r\n"); CString s; s.Format ("%d.", i + 1); // s file.WriteString ("\t\t\t\t<td>"); if (s.IsEmpty ()) file.WriteString (" "); else file.WriteString (s); file.WriteString ("</td>\r\n"); // title file.WriteString ("\t\t\t\t<td>"); s = t.GetTitle (); if (s.IsEmpty ()) file.WriteString (" "); else file.WriteString (s); file.WriteString ("</td>\r\n"); // remarks file.WriteString ("\t\t\t\t<td>"); s = t.GetRemarks (); if (s.IsEmpty ()) file.WriteString (" "); else file.WriteString (s); file.WriteString ("</td>\r\n"); // length file.WriteString ("\t\t\t\t<td>"); s = t.GetNiceLength (); if (s.IsEmpty ()) file.WriteString (" "); else file.WriteString (s); file.WriteString ("</td>\r\n"); file.WriteString ("\t\t\t</tr>\r\n"); } file.WriteString ("\t\t</table>\r\n\t</body>\r\n</html>"); file.Close (); } }
void CDlgExportHistory::ExportHistory(int iWhich, BOOL bCompletedOnly, BOOL bAppend) { fs::list <fsDLHistoryRecord*> vpHist; switch (iWhich) { case 0: { _DldsMgr.m_histmgr.Lock (); for (int i = 0; i < _DldsMgr.m_histmgr.GetRecordCount (); i++) { fsDLHistoryRecord* rec = _DldsMgr.m_histmgr.GetRecord (i); if (bCompletedOnly && rec->dateDownloaded.dwHighDateTime == 0) continue; vpHist.add (rec); } _DldsMgr.m_histmgr.Unlock (); } break; case 1: { CDownloads_History* list = &_pwndDownloads->m_wndHistory; int cItems = list->GetItemCount (); for (int i = cItems-1; i >= 0; i--) { fsDLHistoryRecord* rec = (fsDLHistoryRecord*) list->GetItemData (i); if (bCompletedOnly && rec->dateDownloaded.dwHighDateTime == 0) continue; vpHist.add (rec); } } break; case 2: CDownloads_History* list = &_pwndDownloads->m_wndHistory; POSITION pos = list->GetFirstSelectedItemPosition (); while (pos) { int nItem = list->GetNextSelectedItem (pos); fsDLHistoryRecord* rec = (fsDLHistoryRecord*) list->GetItemData (nItem); if (bCompletedOnly && rec->dateDownloaded.dwHighDateTime == 0) continue; vpHist.add (rec); } } if (vpHist.size () == 0) { AfxGetApp ()->m_pMainWnd->MessageBox (LS (L_NOTHINGTOEXPORT), NULL, MB_ICONEXCLAMATION); return; } CString strFilter; strFilter.Format ("%s (*.html)|*.html||", LS (L_HTMLFILES)); UINT flags = OFN_NOCHANGEDIR; if (bAppend == FALSE) flags |= OFN_OVERWRITEPROMPT; CFileDialog dlg (FALSE, "html", NULL, flags, strFilter, NULL); if (_DlgMgr.DoModal (&dlg) == IDCANCEL) return; ExportHistory (dlg.GetPathName (), vpHist, bAppend); }
void CChildView::OnFileOpen() { CFileDialog* fd = new CFileDialog(true, _T("jfd"), _T("*.jfd")); wstring fileName; fd->m_ofn.lpstrTitle = TEXT("Open save file"); fd->m_ofn.lpstrFilter = TEXT("JFDraw Files (*.jfd)"); if (fd->DoModal() == IDOK) { fileName = fd->GetPathName(); ifstream file(fileName); string rawline; CChildView::Reset(); while (getline(file, rawline)) { if (!rawline.empty()) { stringstream line(rawline); string seg; vector<string> segs; while (getline(line, seg, ',')) { segs.push_back(seg); } if (segs.size() != 7) { continue; } CPoint startp(stoi(segs[1]), stoi(segs[2])); CPoint endp(stoi(segs[3]), stoi(segs[4])); int penWidth = stoi(segs[5]); string text = segs[6]; Fraint::Shape* shape; if (segs[0] == "Circle") { shape = new Fraint::Circle(startp, endp); } else if (segs[0] == "Rectangle") { shape = new Fraint::Rectangle(startp, endp); } else if (segs[0] == "Ellipse") { shape = new Fraint::Ellipse(startp, endp); } else if (segs[0] == "Square") { shape = new Fraint::Square(startp, endp); } else { continue; } shape->SetPenWidth(penWidth); shape->SetText(text); m_Shapes.push_back(shape); } } RedrawShapes(); file.close(); } }