Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Implemented option to save photos, logos and sounds.
[xestiaab/.git] / source / contacteditor / frmContactEditor-Logo.cpp
index 94280d2..5f0eba8 100644 (file)
@@ -137,6 +137,77 @@ void frmContactEditor::DeleteLogo( wxCommandEvent& event )
 void frmContactEditor::SaveLogo( wxCommandEvent &event )
 {
        
-       return; 
+       long longSelected = -1;
+       int intSelectedData = 0;
+    
+       if (!GetSelectedItem(lboLogos,
+                         &longSelected,
+                         &intSelectedData)){
+               
+               return;
+               
+       }
+       
+       wxString FileTypes;
+       
+       wxString FinalFilename;
+       
+       std::map<int,std::string>::iterator initier;
+       std::map<int,wxString>::iterator logotypeiter;
+    
+       initier = LogosList.find(intSelectedData);
+       logotypeiter = LogosListPictureType.find(intSelectedData);
+       
+       if (logotypeiter->second == wxT("image/jpeg")){
+    
+               FileTypes.Append("JPEG Image (*.jpeg)|*.jpeg");
+       
+       } else if (logotypeiter->second == wxT("image/png")){
+
+               FileTypes.Append("PNG Image (*.png)|*.png");        
+        
+       } else if (logotypeiter->second == wxT("image/gif")){
+        
+               FileTypes.Append("GIF Image (*.gif)|*.gif"); 
+       
+       } else {
+
+               wxMessageBox(_("Picture format for saving is not supported."), _("Picture format unsupported"), wxOK, this);
+               return;
+
+       }
+       
+       // Open up the dialog to save the picture.
+       
+       wxFileDialog ExportDlg(this, wxT("Save Logo"), wxT(""), wxT(""),
+               FileTypes, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
+       
+       if (ExportDlg.ShowModal() == wxID_CANCEL){
+       
+               return;
+       
+       }
+       
+       // Write out the picture to the file.
+       
+       wxFile LogoFile;
+       
+       if (LogoFile.Open(ExportDlg.GetPath(), wxFile::write)){
+       
+               std::string base64dec;
+               
+               initier = LogosList.find(intSelectedData);
+               base64dec = base64_decode(initier->second);
+               
+               LogoFile.Write(base64dec.c_str(), (size_t)base64dec.size());
+
+               LogoFile.Close();
+       
+       } else {
+       
+               wxMessageBox(_("An error occured whilst saving the logo. Check that you have free space and permissions to write the picture at this location."), _("Logo save error"), wxOK, this);
+               return;
+       
+       }
        
 }
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy