void CPmwView::DoFileSaveAsGraphic() { BOOL fRet = FALSE; CPmwDoc *pDoc = GetDocument (); CString Filter; Filter.LoadString (IDS_SAVE_AS_GRAPHIC_FILT); // this array must match the order in the above string! SaveGraphicType graphicTypes[] = { None, Pmo, Bmp8, Bmp24, Jpeg, Png, Gif, Pcx, Tiff, WMeta }; CString InitialDir = pDoc->GetPathManager()->ExpandPath("[[P]]"); CString defExt = "*.pmo"; // This must match the first selection in the filter string CFileSaveAsGraphicDlg fileDlg(pDoc->something_selected(), Filter, defExt, InitialDir, this); PBOX WorldAll, WorldSel; pDoc->get_panel_world (&WorldAll, pDoc->get_current_panel()); if (pDoc->GetSelectBound (&WorldSel) != TRUE) WorldSel = WorldAll; CDC *pDC = GetDC(); if (!pDC) { return; // just bail... } int LogPixX = pDC->GetDeviceCaps (LOGPIXELSX); int LogPixY = pDC->GetDeviceCaps (LOGPIXELSY); fileDlg.SetDimensions(&WorldAll, &WorldSel, LogPixX, LogPixY); ReleaseDC (pDC); if (fileDlg.DoModal () == IDOK) { CString Filename = fileDlg.GetPathName (); CPoint cpDims; cpDims.x = fileDlg.m_Width; cpDims.y = fileDlg.m_Height; enum SaveGraphicType gt; gt = graphicTypes[fileDlg.GetGraphicTypeIndex ()]; ASSERT ((gt > None) && (gt < Invalid)); BOOL fSelected = fileDlg.IsSaveSelected(); ERRORCODE error = ERRORCODE_Memory; if (gt == Pmo) { // save as "PrintMaster Objects" file error = SavePMObjectsToFile(Filename, pDoc, fSelected); } else { CDibToGraphicFile pDibToGraphicFile(Filename); pDibToGraphicFile.CreateGraphicFile (pDoc, gt, cpDims, fSelected, NULL, LogPixX); error = pDibToGraphicFile.GetErrorCode(); } if (error != ERRORCODE_None) AfxMessageBox (IDS_ERROR_SAVING); else { if (fileDlg.AddToGallery() == TRUE) { CPMWCollection* pCollection = GetGlobalCollectionManager()->GetUserCollection(CPMWCollection::typeArt); if (pCollection != NULL) { int nResult = pCollection->ImportItem(Filename, NULL, NULL, fileDlg.m_strCategory, FALSE); if (nResult != ERRORCODE_None) AfxMessageBox (IDS_ERROR_SAVING); } } } } }
void CCardView::OnCardServer() { // Some configurations do not support online greetings ("card server"). if (!GetConfiguration()->SupportsCardServer()) { return; } // Get our document. CPmwDoc* pDoc = GetDocument(); if(GetGlobalContentManager()->CheckAccountStatus()) { CString strID = GetGlobalContentManager()->GetAccountID(); if(strID != "") { // Put up the card server dialog. CCardServerDialog Dialog(this); Dialog.m_ctTime = CTime::GetCurrentTime(); if (Dialog.DoModal() == IDOK) { // Put up the disclaimer dialog. CCardServerDisclaimer Disclaimer(this); if (Disclaimer.DoModal() == IDOK) { // Create the directory we want to use as our FTP source. CString csDir = pDoc->GetPathManager()->ExpandPath("[[U]]\\NETCARD"); if (!Util::MakeDirectory(csDir)) { // Not able to make the directory. // LPCSTR pFormat = "Can't create the directory\n%s"; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateDirectory); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csDir); AfxMessageBox(csMessage); return; } // Construct the text file. CString csTextFile; Util::ConstructPath(csTextFile, csDir, "INFO.INI"); CFile cfText; CString csVersion; CString csPPN; TRY { CFileException e; //if (!cfText.Open(csTextFile, // CFile::modeCreate // | CFile::modeWrite, // &e)) //{ // AfxThrowFileException(e.m_cause, e.m_lOsError); //} //do the time stuff //time zone difference from PST struct _timeb tstruct; _ftime( &tstruct ); int timecorrection = PacificTimeCorrection(tstruct.timezone); //get date of delivery - include current time struct tm when; CString strDate; CTime testtime = CTime::GetCurrentTime(); when = *testtime.GetLocalTm(NULL); SYSTEMTIME sysTime = *Dialog.GetTime(); if((when.tm_mday != sysTime.wDay) || (when.tm_mon != (sysTime.wMonth - 1))) { when.tm_mday = sysTime.wDay; when.tm_mon = sysTime.wMonth - 1; ConvertToPST(&when, timecorrection); CString str_ampm = "AM"; if( when.tm_hour > 12 ) /* Set up extension. */ str_ampm = "PM"; if( when.tm_hour > 12 ) /* Convert from 24-hour */ when.tm_hour -= 12; /* to 12-hour clock. */ if( when.tm_hour == 0 ) /*Set hour to 12 if midnight. */ when.tm_hour = 12; strDate.Format("%d/%d/%d %d:%d:%d%s", (int)((int)when.tm_mon + 1),when.tm_mday,when.tm_year,when.tm_hour,when.tm_min,when.tm_sec,str_ampm); } else { strDate = ""; } CString strPSTCorrection; strPSTCorrection.Format("%d", timecorrection); // Construct the version string. CString csEol = "\r\n"; csVersion = GetConfiguration()->ReplacementText('T'); csVersion += ' '; csVersion += GET_PMWAPP()->GetVersion(); csPPN = GET_PMWAPP()->GetParentPartNumber(); WritePrivateProfileString( "UserData", "UserId", GetGlobalContentManager()->GetAccountID(), csTextFile); WritePrivateProfileString( "UserData", "Description", csVersion, csTextFile); WritePrivateProfileString( "UserData", "SenderEmail", Dialog.m_csFrom, csTextFile); WritePrivateProfileString( "UserData", "RecipientEmail", Dialog.m_csTo, csTextFile); WritePrivateProfileString( "UserData", "sku", csPPN, csTextFile); WritePrivateProfileString( "CardData", "Title", Dialog.m_csTitle, csTextFile); WritePrivateProfileString( "CardData", "Date", strDate, csTextFile); WritePrivateProfileString( "CardData", "Offset", strPSTCorrection, csTextFile); #if 0 // Write version cfText.Write(csVersion, csVersion.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write "from" email address cfText.Write(Dialog.m_csFrom, Dialog.m_csFrom.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write "to" email address cfText.Write(Dialog.m_csTo, Dialog.m_csTo.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write Parent Part Number cfText.Write(csPPN, csPPN.GetLength()); cfText.Write(csEol, csEol.GetLength()); #endif //cfText.Close(); } CATCH_ALL(e) { // Could not write the text file. Complain. // LPCSTR pFormat = "Can't create the file\n%s"; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateFile); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csTextFile); AfxMessageBox(csMessage); return; } END_CATCH_ALL // Figure out how big we want the panels to be. CPoint cpFrontDims; CPoint cpInsideDims; PBOX World; pDoc->get_panel_world(&World, CARD_PANEL_Front); // Fit the front panel into a 425x425 square. PPNT FrontDims; FrontDims.x = World.x1 - World.x0; FrontDims.y = World.y1 - World.y0; double dScale = 425.0/(double)FrontDims.x; double dYScale = 425.0/(double)FrontDims.y; if (dScale > dYScale) dScale = dYScale; cpFrontDims.x = (int)((double)FrontDims.x*dScale); cpFrontDims.y = (int)((double)FrontDims.y*dScale); pDoc->get_panel_world(&World, CARD_PANEL_Inside); cpInsideDims.x = (int)((double)(World.x1-World.x0)*dScale); cpInsideDims.y = (int)((double)(World.y1-World.y0)*dScale); TRACE("Front: %d, %d; Inside: %d, %d\n", cpFrontDims.x, cpFrontDims.y, cpInsideDims.x, cpInsideDims.y); BOOL fSuccess = FALSE; CCardServerProgressDialog ProgressDialog(AfxGetMainWnd()); CString csName; Util::ConstructPath(csName, csDir, "front.gif"); ProgressDialog.SetStatus(IDS_BuildingFront); if (DumpPanel(CARD_PANEL_Front, csName, cpFrontDims)) { ProgressDialog.SetStatus(IDS_BuildingInside); Util::ConstructPath(csName, csDir, "inside.gif"); if(DumpPanel(CARD_PANEL_Inside, csName, cpInsideDims)) fSuccess = TRUE; } if (!fSuccess) { // "Can't create card pictures." AfxMessageBox(GET_PMWAPP()->GetResourceStringPointer(IDS_ErrWriteCardPictures)); return; } // Now, invoke the DLL to write the data. CCardServerDLL DLL; #ifdef WIN32 CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP32.DLL"); #else CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP16.DLL"); #endif // Startup the dialog. if (DLL.Startup(csDLLName)) { if(CheckForValidConnection()){ // Put up our progress dialog. // Send the files. int nResult = DLL.SendFiles(csDir, ProgressDialog); // Take down the progress dialog now. ProgressDialog.DestroyWindow(); // Shut down the DLL. DLL.Shutdown(); CPmwDialog Dialog(nResult == 0 ? IDD_CARD_SERVER_SUCCESS : IDD_CARD_SERVER_FAILURE); Dialog.DoModal(); } } else { // Not able to load the DLL. Complain. // LPCSTR pFormat = "The file\n%s\nis missing or bad."; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrMissingDLL); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csDLLName); AfxMessageBox(csMessage); } }