///////////////
// Attach font
void DialogAttachments::OnAttachFont(wxCommandEvent &event) {
	// Pick files
	wxArrayString filenames;
	wxArrayString paths;
	{
		wxFileDialog diag (this,_("Choose file to be attached"), Options.AsText(_T("Fonts Collector Destination")), _T(""), _T("Font Files (*.ttf)|*.ttf"), wxOPEN | wxFILE_MUST_EXIST | wxMULTIPLE);
		if (diag.ShowModal() == wxID_CANCEL) return;
		diag.GetFilenames(filenames);
		diag.GetPaths(paths);
	}

	// Create attachments
	for (size_t i=0;i<filenames.Count();i++) {
		//wxFileName file(filenames[i]);
		AssAttachment *newAttach = new AssAttachment(filenames[i]);
		try {
			newAttach->Import(paths[i]);
		}
		catch (...) {
			delete newAttach;
			return;
		}
		newAttach->group = _T("[Fonts]");
		AssFile::top->InsertAttachment(newAttach);
	}

	// Update
	UpdateList();
}
///////////////////
// Attach graphics
void DialogAttachments::OnAttachGraphics(wxCommandEvent &event) {
	// Pick files
	wxArrayString filenames;
	wxArrayString paths;
	{
		wxFileDialog diag (this,_("Choose file to be attached"), _T(""), _T(""), _T("Graphic Files (*.bmp,*.gif,*.jpg,*.ico,*.wmf)|*.bmp;*.gif;*.jpg;*.ico;*.wmf"), wxOPEN | wxFILE_MUST_EXIST | wxMULTIPLE);
		if (diag.ShowModal() == wxID_CANCEL) return;
		diag.GetFilenames(filenames);
		diag.GetPaths(paths);
	}

	// Create attachments
	for (size_t i=0;i<filenames.Count();i++) {
		//wxFileName file(filenames[i]);
		AssAttachment *newAttach = new AssAttachment(filenames[i]);
		try {
			newAttach->Import(paths[i]);
		}
		catch (...) {
			delete newAttach;
			return;
		}
		newAttach->group = _T("[Graphics]");
		AssFile::top->InsertAttachment(newAttach);
	}

	// Update
	UpdateList();
}
Esempio n. 3
0
void DialogAttachments::AttachFile(wxFileDialog &diag, AssEntryGroup group, wxString const& commit_msg) {
	if (diag.ShowModal() == wxID_CANCEL) return;

	wxArrayString filenames;
	diag.GetFilenames(filenames);

	wxArrayString paths;
	diag.GetPaths(paths);

	// Create attachments
	for (size_t i = 0; i < filenames.size(); ++i) {
		AssAttachment *newAttach = new AssAttachment(filenames[i], group);
		try {
			newAttach->Import(paths[i]);
		}
		catch (...) {
			delete newAttach;
			return;
		}
		ass->InsertLine(newAttach);
	}

	ass->Commit(commit_msg, AssFile::COMMIT_ATTACHMENT);

	UpdateList();
}