void AppSettings::CacheImages() { if (!parsedImages) { FindImages(imgTable, rootPath, searchPaths, extensions); parsedImages = true; } }
HRESULT CMainWindow::DrawClientArea() { // Begin drawing the client area HRESULT hr = CreateDeviceResources(); if (SUCCEEDED(hr)) { hr = FindImages(); if (SUCCEEDED(hr)) { m_pRenderTarget->BeginDraw(); // Retrieve the size of the render target D2D1_SIZE_F sizeRenderTarget = m_pRenderTarget->GetSize(); // Paint the background m_pRenderTarget->FillRectangle( D2D1::RectF( 0.0f, 0.0f, sizeRenderTarget.width, sizeRenderTarget.height ), m_pBackgroundBrush ); // Paint all the thumbnails for (UINT i = 0; i < m_uThumbCount; i++) { hr = m_thumbs[i].Render( m_pRenderTarget, m_pOutlineBrush ); if (FAILED(hr)) { break; } } // Can only return one failure HRESULT HRESULT hrEndDraw = m_pRenderTarget->EndDraw(); if (SUCCEEDED(hr)) { hr = hrEndDraw; } } if (hr == D2DERR_RECREATE_TARGET) { DiscardDeviceResources(); } } return hr; }
string AppSettings::FindImage(const string& fname){ TCHAR buffer[MAX_PATH]; // Simply check for fully qualified path if (PathIsRoot(fname.c_str())) { if (-1 != _taccess(fname.c_str(), 0)) return fname; } // Test if its relative and in one of the specified root paths for (stringlist::iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr ){ PathCombine(buffer, itr->c_str(), fname.c_str()); if (-1 != _taccess(buffer, 0)){ return string(buffer); } } // Hit the directories to find out whats out there if (!parsedImages){ FindImages(imgTable, rootPath, searchPaths, extensions); parsedImages = true; } // Search my filename for our texture _tcscpy(buffer, PathFindFileName(fname.c_str())); PathRemoveExtension(buffer); NameValueCollection::iterator itr = imgTable.find(buffer); if (itr != imgTable.end()){ if (!rootPath.empty()) { _tcscpy(buffer, rootPath.c_str()); PathCombine(buffer, rootPath.c_str(), ((*itr).second).c_str()); return string(buffer); } else { return (*itr).second; } } return fname; }