wxInt32 CViewProjects::GetDocCount() { CMainDocument* pDoc = wxGetApp().GetDocument(); if (pDoc) { return pDoc->GetProjectCount(); } return -1; }
void CProjectInfoPage::OnPageChanging( wxWizardExEvent& event ) { if (event.GetDirection() == false) return; wxLogTrace(wxT("Function Start/End"), wxT("CProjectInfoPage::OnPageChanging - Function Begin")); CMainDocument* pDoc = wxGetApp().GetDocument(); CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxString strTitle; int iAnswer; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); strTitle.Printf( wxT("%s"), pSkinAdvanced->GetApplicationName().c_str() ); // Check to see if the project is supported: if ( !GetProjectSupported() ) { iAnswer = wxGetApp().SafeMessageBox( _("This project may not have work for your type of computer. Do you want to add it anyway?"), strTitle, wxCENTER | wxYES_NO | wxICON_INFORMATION ); // Project is not supported if (wxNO == iAnswer) { event.Veto(); } } else { // Check if we are already attached to that project: for (int i = 0; i < pDoc->GetProjectCount(); ++i) { PROJECT* project = pDoc->project(i); if (project) { std::string project_url = project->master_url; std::string new_project_url = (const char*)m_strProjectURL.mb_str(); canonicalize_master_url(project_url); canonicalize_master_url(new_project_url); if (project_url == new_project_url) { wxGetApp().SafeMessageBox( _("You already added this project. Please choose a different project."), strTitle, wxCENTER | wxICON_INFORMATION ); // We are already attached to that project, event.Veto(); break; } } } } wxLogTrace(wxT("Function Start/End"), wxT("CProjectInfoPage::OnPageChanging - Function End")); }