LRESULT SpyFrame::handleSpeaker(WPARAM wParam, LPARAM lParam) { if(wParam == SPEAK_SEARCH) { boost::scoped_ptr<tstring> x((tstring*)lParam); total++; // Not thread safe, but who cares really... perSecond[cur % AVG_TIME]++; int j = searches->find(*x); if(j == -1) { TStringList a; a.push_back(*x); a.push_back(Text::toT(Util::toString(1))); a.push_back(Text::toT(Util::getTimeString())); searches->insert(a); if(searches->size() > 500) { searches->erase(searches->size() - 1); } } else { searches->setText(j, COLUMN_COUNT, Text::toT(Util::toString(Util::toInt(Text::fromT(searches->getText(j, COLUMN_COUNT))) + 1))); searches->setText(j, COLUMN_TIME, Text::toT(Util::getTimeString())); if(searches->getSortColumn() == COLUMN_COUNT || searches->getSortColumn() == COLUMN_TIME ) searches->resort(); } setStatus(STATUS_TOTAL, str(TF_("Total: %1%") % total)); setStatus(STATUS_HITS, str(TF_("Hits: %1%") % ShareManager::getInstance()->getHits())); double ratio = total > 0 ? ((double)ShareManager::getInstance()->getHits()) / (double)total : 0.0; setStatus(STATUS_HIT_RATIO, str(TF_("Hit Ratio: %1%") % ratio)); } return 0; }
bool SpyFrame::eachSecond() { size_t tot = std::accumulate(perSecond, perSecond + AVG_TIME, 0u); size_t t = std::max(1u, std::min(cur, AVG_TIME)); float x = static_cast<float>(tot)/t; cur++; perSecond[cur % AVG_TIME] = 0; setStatus(STATUS_AVG_PER_SECOND, str(TF_("Average/s: %1%") % x)); return true; }
void SearchTypeDlg::showError(const tstring& badExt) { dwt::MessageBox(this).show(str(TF_("Invalid extension: %1%") % badExt), _T(APPNAME) _T(" ") _T(VERSIONSTRING), dwt::MessageBox::BOX_OK, dwt::MessageBox::BOX_ICONSTOP); }
tstring SearchTypeDlg::getTitle() const { return str(TF_("Extensions for the %1% search type") % name); }