void CPLViewerDoc::OnFileSave() { CFileDialog SaveDlg (false, ".jpg", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "JPEG File (*.jpg)|*.jpg|Windows Bitmap (*.bmp)|*.bmp|TIFF File (*.tif)|*.tif|PNG File (*.png)|*.png|", AfxGetMainWnd()); if (SaveDlg.DoModal() == IDOK) { CString sFName = SaveDlg.GetPathName(); CString sExt = SaveDlg.GetFileExt(); sExt.MakeLower(); try { if (sExt == "jpg") { PLJPEGEncoder Encoder; Encoder.MakeFileFromBmp(sFName, m_pDib); } else if (sExt == "tif") { PLTIFFEncoder Encoder; Encoder.MakeFileFromBmp(sFName, m_pDib); } else if (sExt == "png") { PLPNGEncoder Encoder; Encoder.MakeFileFromBmp(sFName, m_pDib); } else if (sExt == "bmp") { PLBmpEncoder Encoder; Encoder.MakeFileFromBmp(sFName, m_pDib); } else { // Extension must be one of the supported types. If not, // something is wrong in the user interface code. ASSERT (false); } } catch(PLTextException e) { CString bmpEx; bmpEx.Format("Error saving the file: %s", (LPCTSTR) e, (LPCTSTR) e.GetCode()); AfxMessageBox(bmpEx); } } }
void CDialConfigDec::OnButton1() { CFile Fichier; // variable fichier BYTE compnbpar; CFileDialog * FileData = new CFileDialog (TRUE,"*.pmc",NomFichPMC,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Polytopes multi-classes (*.pmc)|*.pmc|",this); if (FileData->DoModal()==IDOK) { if(FileData->GetFileExt()!="pmc") { MessageBox("Le fichier selectionné n'est pas valide!","Erreur",MB_OK|MB_ICONSTOP); m_pmc.SetWindowText("*.pmc"); ValidPMC=FALSE; } else if (Fichier.Open(FileData->GetPathName(), CFile::modeRead)) { Fichier.Read(&NBclass,1); Fichier.Read(&compnbpar,1); Fichier.Close(); NomFichPMC=FileData->GetPathName(); m_pmc.SetWindowText(FileData->GetFileName()); ValidPMC=TRUE; if(compnbpar!=NBpar) { NBpar=compnbpar; m_param.SetWindowText("*.param"); ValidPARAM=FALSE; } m_classeaffect=0; m_spin.SetPos(0); m_spin.SetRange(0,NBclass-1); if(!m_check) m_edit1.SetWindowText(""); } else { MessageBox("Le fichier "+FileData->GetFileName()+" n'existe pas!","Erreur",MB_OK|MB_ICONSTOP); ValidPMC=FALSE; } } m_ok.EnableWindow(ValidPARAM&&ValidPMC); m_checkbox.EnableWindow(ValidPARAM&&ValidPMC); m_param.EnableWindow(ValidPMC); UpdateData(FALSE); delete FileData; }
void CDialConfigDec::OnButton2() { CFile Fichier; // variable fichier BYTE compnbpar; CFileDialog * FileData = new CFileDialog (TRUE,"*.param",NomFichParam,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"Paramètres (*.param)|*.param|",this); if (FileData->DoModal()==IDOK) { if(FileData->GetFileExt()!="param") { MessageBox("Le fichier selectionné n'est pas valide!","Erreur",MB_OK|MB_ICONSTOP); m_pmc.SetWindowText("*.param"); ValidPARAM=FALSE; } else if (Fichier.Open(FileData->GetPathName(), CFile::modeRead)) { Fichier.Read(&compnbpar,1); if(compnbpar!=NBpar) { MessageBox("Fichier "+Fichier.GetFileName()+" incompatible!","Nombre de paramètres",MB_OK|MB_ICONSTOP); m_param.SetWindowText("*.param"); ValidPARAM=FALSE; Fichier.Close(); } else { NomFichParam=FileData->GetPathName(); m_param.SetWindowText(FileData->GetFileName()); ValidPARAM=TRUE; Fichier.Close(); } } else { MessageBox("Le fichier "+FileData->GetFileName()+" n'existe pas!","Erreur",MB_OK|MB_ICONSTOP); ValidPARAM=FALSE; } } m_ok.EnableWindow(ValidPARAM&&ValidPMC); m_checkbox.EnableWindow(ValidPARAM&&ValidPMC); m_param.EnableWindow(ValidPMC); UpdateData(FALSE); delete FileData; }
void CdcmviewerView::OnFileSaveAs() { // save dicom as bmp/jpeg/png/gif/tif if(!m_pdib.get()) return; static char BASED_CODE szFilters[] = "Jpeg Files (*.jpg)|*.jpg|Bitmap Files (*.bmp)|*.bmp|Png Files (*.png)|*.png|GIF Files (*.gif)|*.gif|TIFF Files (*.tif)|*.tif||"; CFileDialog ofdlg (FALSE, ".bmp", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST |OFN_EXPLORER, szFilters, AfxGetMainWnd()); if(IDOK==ofdlg.DoModal()) { CString pathname = ofdlg.GetPathName(); CString fileext = ofdlg.GetFileExt(); DWORD index = ofdlg.m_ofn.nFilterIndex; if(index==2) { CFile fbmp; if(end_with((LPCTSTR)pathname,_T(".bmp"))==false) pathname += _T(".bmp"); if(fbmp.Open(pathname,CFile::modeCreate|CFile::modeWrite)) { m_pdib->Write(&fbmp); } fbmp.Close(); } else if( 3 == index) { save_dcm_as_image(pathname,".png",m_pdib.get()); } else if( 4 == index) { save_dcm_as_image(pathname,".gif",m_pdib.get()); } else if( 5 == index) { save_dcm_as_image(pathname,".tif",m_pdib.get()); } else { save_dcm_as_image(pathname,".jpg",m_pdib.get()); } } }
void CChildView::OnFileOpen() { CString szFilter = _T ("DICOM Files (*.dcm)|*.dcm|bitmap Files (*.bmp)|*.bmp|All Files (*.*)|*.*|"); CFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT, szFilter, this); if(dlg.DoModal () == IDCANCEL) return; CString ext = dlg.GetFileExt(); ext.MakeUpper(); //capital character if(ext == L"BMP") OpenBITMAPFile(dlg.GetPathName()); else if(ext == L"DCM") OpenDICOMFile(dlg.GetPathName()); Invalidate(FALSE); }
void CDlgDefineModel::OnBnClickedBrowseModelName() { CFileDialog fileDlg (FALSE, _T(""), _T("*.*"), OFN_HIDEREADONLY, _T(""), this); OPENFILENAME& ofn = fileDlg.GetOFN(); CString strDlg("Specify model root name"); ofn.lpstrTitle = strDlg; if( fileDlg.DoModal() == IDOK ) { CString strExt = fileDlg.GetFileExt(); CString strName = fileDlg.GetFileName(); m_strFilePathModel = fileDlg.GetPathName(); if( !strExt.IsEmpty()) { m_strFilePathModel.Replace( _T(".")+strExt, _T("")); } if( !strName.IsEmpty()) { m_strFilePathTmp.Replace( _T("\\")+strName, _T("")); } m_pInvFcs->SetFileRoot( m_strFilePathModel ); m_pInvFcs->SetPathTmp( m_strFilePathModel ); SetDlgItemText(IDC_MODEL_NAME, m_strFilePathModel); SetDlgItemText(IDC_TEMP_DIR, m_strFilePathModel); } }
void CDlgExportDownloads::ExportDownloads(int iWhich, BOOL bNoDone, BOOL bAppend) { DLDS_LIST vpDlds; switch (iWhich) { case 0: { _DldsMgr.LockList (true); size_t nCount = _DldsMgr.GetCount (); for (size_t i = 0; i < nCount; i++) { vmsDownloadSmartPtr dld = _DldsMgr.GetDownload (i); if (bNoDone && dld->pMgr->IsDone ()) continue; vpDlds.push_back (dld); } _DldsMgr.UnlockList (true); } break; case 1: { CDownloads_Tasks* list = &_pwndDownloads->m_wndDownloads.m_tasks; int cItems = list->GetItemCount (); for (int i = 0; i < cItems; i++) { vmsDownloadSmartPtr dld; try { dld = (fsDownload*) list->GetItemData (i); if (bNoDone && dld->pMgr->IsDone ()) dld = NULL; } catch (const std::exception& ex) { ASSERT (FALSE); vmsLogger::WriteLog("CDlgExportDownloads::ExportDownloads " + tstring(ex.what())); dld = NULL; } catch (...) { ASSERT (FALSE); vmsLogger::WriteLog("CDlgExportDownloads::ExportDownloads unknown exception"); dld = NULL; } if (dld) vpDlds.push_back (dld); } } break; case 2: { CDownloads_Tasks* list = &_pwndDownloads->m_wndDownloads.m_tasks; POSITION pos = list->GetFirstSelectedItemPosition (); while (pos) { int iItem = list->GetNextSelectedItem (pos); vmsDownloadSmartPtr dld; try { dld = (fsDownload*) list->GetItemData (iItem); if (bNoDone && dld->pMgr->IsDone ()) dld = NULL; } catch (const std::exception& ex) { ASSERT (FALSE); vmsLogger::WriteLog("CDlgExportDownloads::ExportDownloads " + tstring(ex.what())); dld = NULL; } catch (...) { ASSERT (FALSE); vmsLogger::WriteLog("CDlgExportDownloads::ExportDownloads unknown exception"); dld = NULL; } if (dld) vpDlds.push_back (dld); } } break; } if (vpDlds.empty ()) { AfxGetApp ()->m_pMainWnd->MessageBox (LS (L_NODLDSTOEXPORT), NULL, MB_ICONEXCLAMATION); } else { CString strFilter; strFilter.Format ("%s (*.txt)|*.txt|%s (*.xml)|*.xml||", LS (L_URLLISTFILES), LS (L_DLINFOLISTFILES)); UINT flags = OFN_NOCHANGEDIR; if (bAppend == FALSE) flags |= OFN_OVERWRITEPROMPT; CFileDialog dlg (FALSE, "txt", NULL, flags, strFilter, NULL); if (_DlgMgr.DoModal (&dlg) == IDCANCEL) return; if (dlg.GetFileExt ().CollateNoCase ("txt") == 0) ExportDownloads_ToURLListFile (dlg.GetPathName (), &vpDlds, bAppend); else ExportDownloads_ToDLInfoListFile (dlg.GetPathName (), &vpDlds, bAppend); } }