X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Logo.cpp;h=5f0eba88891b69a0041e60246dc7cb125de51d84;hb=b19bbc6c6d83edfefba9c98e78a57d21eb8aa1a8;hp=63638e4d93bd4addbb5f4c358af2b984575a3010;hpb=da64d37d0a13895554e4ad945c46dd0af6d1c0e6;p=xestiaab%2F.git diff --git a/source/contacteditor/frmContactEditor-Logo.cpp b/source/contacteditor/frmContactEditor-Logo.cpp index 63638e4..5f0eba8 100644 --- a/source/contacteditor/frmContactEditor-Logo.cpp +++ b/source/contacteditor/frmContactEditor-Logo.cpp @@ -134,3 +134,80 @@ void frmContactEditor::DeleteLogo( wxCommandEvent& event ) imgLogo->SetBitmap(LogoImage); } +void frmContactEditor::SaveLogo( wxCommandEvent &event ) +{ + + long longSelected = -1; + int intSelectedData = 0; + + if (!GetSelectedItem(lboLogos, + &longSelected, + &intSelectedData)){ + + return; + + } + + wxString FileTypes; + + wxString FinalFilename; + + std::map::iterator initier; + std::map::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