///////////////////////////////////////////////////////////////////////////////////// // create handler void TPdfFrontend::onCreate(void) { FileSel fs; // if no documents, just do nothing if(!Documents.GetCount()) return; // first, gets last browsed path (if any) String cfgPath = GetPdfConfigPath() + "lastpath"; if(FileExists(cfgPath)) { FileIn f(cfgPath); fs.Set(f.GetLine()); } // gets the output file name, returns if cancelled fs.DefaultExt(".pdf").Type("documenti pdf", "*.pdf"); if(!fs.ExecuteSaveAs("Nome del documento pdf:")) return; // stores last active output path RealizeDirectory(GetPdfConfigPath()); FileOut f(cfgPath); f.PutLine(fs.Get()); // creates the command line and executes ghostscript String FileName = fs.Get(); String args = "-q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=\"" + FileName + "\" \"" + Documents[0] + "\""; for(int i = 1 ; i < Documents.GetCount(); i++) args = args + " \"" + Documents[i] + "\""; String OutStr, ErrStr; bool res = SysExec("gs", args, Environment(), OutStr, ErrStr); // creates progress bar and hooks inside client // Progress progress("Creazione pdf in corso...."); // Client.setProgress(progress); // progress.Create(); // Client.setProgress(0); // if(progress.Canceled()) // res = false; // if error, does nothing if(!res) return; // clear collected documents ClearDocuments(); // closes application Break(0); } // END TPdfFrontend::onCreate()
void LoggerCtrl::Save() { FileSel fs; fs.Type("Text file", "*.txt"); if(!fs.ExecuteSaveAs("Save Log to file")) return; String fn = fs.Get(); if(fn.IsEmpty()) return; FileOut out(fn); Flush(); DocEdit::Save(out); }
void bigmailer::onOpenList() { FileSel fs; fs.ActiveDir(ConfigFile("")) ; fs.Type("list files", "*.list") ; if ( ! fs.ExecuteOpen(t_("select a list file") ) ) return; onCloseList() ; theDefList.Load(fs.Get()) ; SetTitle() ; }
// image selection callback void XMLBarEditor::imageSelCb(void) { static String lastPath = ""; // opens a file selector, allows selection of some // kind of image formats FileSel fs; fs.ActiveDir(lastPath); fs.Type(t_("Image files"), "*.png,*.jpg,*.ico,*.bmp"); if(!fs.ExecuteOpen(t_("Select icon file"))) return; String path = fs.Get(); lastPath = GetFileFolder(path); String ext = ToUpper(GetFileExt(path)); Image img; if(ext != ".ICO") img = StreamRaster::LoadFileAny(path); else { String data = LoadFile(path); Vector<Image> imgVec; try { imgVec = ReadIcon(data); } catch(...) { } if(imgVec.GetCount()) img = imgVec[0]; else img = Null; } curIcon = img; itemPane.icon.SetImage(img); fieldsModCb(); }
void bigmailer::DataPageImportCSV() { FileSel fs ; fs.ActiveDir(ConfigFile("")) ; fs.Type("csv files", "*.csv") ; if ( ! fs.ExecuteOpen(t_("")) ) return; csvResult csv ; if ( ! csv.ImportFrom(fs.Get()) ) return ; WithcsvToDefLayout<TopWindow> dlg; CtrlLayout(dlg, "Import From CSV"); for (int i = 0; i < csv.fields.GetCount(); i++) { dlg.dropName.Add( csv.fields[i] ) ; dlg.dropEmail.Add( csv.fields[i] ) ; } dlg.dropName.SetIndex(0) ; dlg.dropEmail.SetIndex(1) ; dlg.btOk.WhenAction = Breaker(IDOK) ; dlg.btCancel.WhenAction = Breaker( IDCANCEL ) ; if (dlg.Execute() == IDOK) { if (PromptOKCancel("Con esta operación se van a eliminar [* TODOS]") == IDOK) { // añadimos la cabecera theDefList.fields.Clear() ; theDefList.fields.Add( dlg.dropName.GetValue() ) ; theDefList.fields.Add( dlg.dropEmail.GetValue() ) ; for (int i = 0; i < csv.fields.GetCount(); i++) { String f = csv.fields[i] ; if (f != theDefList.fields[0] && f != theDefList.fields[1]) theDefList.fields.Add(f) ; } theDefList.data.Clear() ; for (int i = 0; i < csv.values.GetCount(); i++) // para cada registro { Vector<String>& line = csv.values[i] ; Vector<String>& record = theDefList.data.Add() ; for (int j = 0; j < theDefList.fields.GetCount(); j++) { String fieldName = theDefList.fields[j] ; for (int k = 0; k < csv.fields.GetCount(); k++) { if (fieldName == csv.fields[k]) { record.Add( line[k] ) ; break ; } } } } theDefList.Save() ; DataPageFill() ; } } }