Beispiel #1
0
void AFXAPI AfxFailRadio(CDataExchange* pDX)
{
	CString prompt;
	AfxFormatStrings(prompt, AFX_IDP_PARSE_RADIO_BUTTON, NULL, 0);
	AfxMessageBox(prompt, MB_ICONEXCLAMATION, AFX_IDP_PARSE_RADIO_BUTTON);
	prompt.Empty(); // exception prep
	pDX->Fail();
}
void COSMCtrlMapOperationsDlg::UpdateZoom(int nZoomLevel)
{
  //Validate our parameters
  AFXASSUME(m_pOSMCtrl != NULL);
  
  //Display a wait cursor while we do the maths to work out how many tiles we will be working on
  CWaitCursor waitCursor;

  //Reset the tiles array
  m_Tiles.reserve(100000);
  
  //Work out how many tiles this operation will affect
  COSMCtrlPosition topLeft;
  COSMCtrlPosition bottomRight;
  int nZoom = static_cast<int>(m_pOSMCtrl->GetZoom());
  if (m_pOSMCtrl->m_SelectionPolygon.GetBoundingRect(topLeft, bottomRight))
  {
    //Iterate across all the zoom levels we will be operating on
    for (int i=nZoom; i<=nZoomLevel; i++)
    { 
      //Work our the start and end X and Y values for the tiles at this zoom level 
      double fStartX = COSMCtrlHelper::Longitude2TileX(topLeft.m_fLongitude, i);
      int nStartX = static_cast<int>(fStartX);
      double fStartY = COSMCtrlHelper::Latitude2TileY(topLeft.m_fLatitude, i);
      int nStartY = static_cast<int>(fStartY);

      double fEndX = COSMCtrlHelper::Longitude2TileX(bottomRight.m_fLongitude, i);
      int nEndX = static_cast<int>(fEndX);
      double fEndY = COSMCtrlHelper::Latitude2TileY(bottomRight.m_fLatitude, i);
      int nEndY = static_cast<int>(fEndY);
    
      //Add all the tiles for this zoom level to the array
      for (int j=nStartX; j<=nEndX; j++)
      {
        for (int k=nStartY; k<=nEndY; k++)
        {
          COSMCtrlMapOperationsDlgTile tile;
          tile.m_nTileX = j;
          tile.m_nTileY = k;
          tile.m_nZoom = i;
          m_Tiles.push_back(tile);
        }
      }
    }
  }
  
  //Free up any unused memory in the array
  m_Tiles.shrink_to_fit();

  //Set the range on the progress control  
  int nTiles = static_cast<int>(m_Tiles.size());
  m_ctrlProgress.SetPos(0);
  m_ctrlProgress.SetRange32(0, nTiles);

  //Finally update the text on the UI
  CString sStatus;
  CString sZoom1;
  sZoom1.Format(_T("%d"), nZoom);
  CString sTiles;
  sTiles.Format(_T("%d"), nTiles);
  if (nZoom == nZoomLevel)
    AfxFormatString2(sStatus, IDS_OSMCTRL_MAP_OPERATIONS_UPDATE_ZOOM2, sZoom1, sTiles);
  else
  {
    CString sZoom2;
    sZoom2.Format(_T("%d"), nZoomLevel);
    
    LPCTSTR szStrings[3];
    szStrings[0] = sZoom1;
    szStrings[1] = sZoom2;
    szStrings[2] = sTiles;
    AfxFormatStrings(sStatus, IDS_OSMCTRL_MAP_OPERATIONS_UPDATE_ZOOM3, szStrings, 3);
  }
  m_ctrlStatusText.SetWindowText(sStatus);
}