本文整理汇总了C++中CastItoXBytes函数的典型用法代码示例。如果您正苦于以下问题:C++ CastItoXBytes函数的具体用法?C++ CastItoXBytes怎么用?C++ CastItoXBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CastItoXBytes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetDlgItemText
void CPartFileConvertDlg::UpdateJobInfo(ConvertJob* job) {
if (job==NULL) {
SetDlgItemText(IDC_CURJOB, GetResString(IDS_FSTAT_WAITING) );
SetDlgItemText(IDC_CONV_PROZENT, _T(""));
pb_current.SetPos(0);
SetDlgItemText(IDC_CONV_PB_LABEL,_T(""));
return;
}
CString buffer;
// search jobitem in listctrl
LVFINDINFO find;
find.flags = LVFI_PARAM;
find.lParam = (LPARAM)job;
int itemnr = joblist.FindItem(&find);
if (itemnr != -1) {
joblist.SetItemText(itemnr,0, job->filename.IsEmpty()?job->folder:job->filename );
joblist.SetItemText(itemnr,1, CPartFileConvert::GetReturncodeText(job->state) );
buffer=_T("");
if (job->size>0)
buffer.Format(GetResString(IDS_IMP_SIZE),CastItoXBytes(job->size, false, false),CastItoXBytes(job->spaceneeded, false, false));
joblist.SetItemText(itemnr,2, buffer );
joblist.SetItemText(itemnr,3, job->filehash);
} else {
// AddJob(job); why???
}
}
示例2: GetResString
void CHttpDownloadDlg::SetTimeLeft(DWORD dwSecondsLeft, DWORD dwBytesRead, DWORD dwFileSize)
{
CString strTimeLeft;
strTimeLeft.Format( GetResString(IDS_HTTPDOWNLOAD_TIMELEFT),
CastSecondsToHM(dwSecondsLeft), CastItoXBytes(dwBytesRead), CastItoXBytes(dwFileSize) );
m_ctrlTimeLeft.SetWindowText(strTimeLeft);
}
示例3: CastChild
void CFileDetailDialog::UpdateData()
{
wxString bufferS;
CastChild(IDC_FNAME,wxStaticText)->SetLabel(MakeStringEscaped(
TruncateFilename(m_file->GetFileName(),60)));
CastChild(IDC_METFILE,wxStaticText)->SetLabel(MakeStringEscaped(
TruncateFilename(m_file->GetFullName(),60,true)));
wxString tmp = CastChild(IDC_FILENAME, wxTextCtrl)->GetValue();
if (tmp.Length() < 3) {
resetValueForFilenameTextEdit();
}
CastChild(IDC_FHASH,wxStaticText)->SetLabel(m_file->GetFileHash().Encode());
bufferS = wxString::Format(wxT("%llu bytes ("), m_file->GetFileSize())
+ CastItoXBytes(m_file->GetFileSize())
+ wxT(")");
CastChild(IDC_FSIZE,wxControl)->SetLabel(bufferS);
CastChild(IDC_PFSTATUS,wxControl)->SetLabel(m_file->getPartfileStatus());
bufferS = wxString::Format(wxT("%i (%i)"),m_file->GetPartCount(),m_file->GetHashCount());
CastChild(IDC_PARTCOUNT,wxControl)->SetLabel(bufferS);
CastChild(IDC_TRANSFERRED,wxControl)->SetLabel(CastItoXBytes(m_file->GetTransferred()));
CastChild(IDC_FD_STATS1,wxControl)->SetLabel(CastItoXBytes(m_file->GetLostDueToCorruption()));
CastChild(IDC_FD_STATS2,wxControl)->SetLabel(CastItoXBytes(m_file->GetGainDueToCompression()));
CastChild(IDC_FD_STATS3,wxControl)->SetLabel(CastItoIShort(m_file->TotalPacketsSavedDueToICH()));
CastChild(IDC_COMPLSIZE,wxControl)->SetLabel(CastItoXBytes(m_file->GetCompletedSize()));
bufferS = wxString::Format(_("%.2f%% done"),m_file->GetPercentCompleted());
CastChild(IDC_PROCCOMPL,wxControl)->SetLabel(bufferS);
bufferS = wxString::Format(_("%.2f kB/s"),(float)m_file->GetKBpsDown());
CastChild(IDC_DATARATE,wxControl)->SetLabel(bufferS);
bufferS = wxString::Format(wxT("%i"),m_file->GetSourceCount());
CastChild(IDC_SOURCECOUNT,wxControl)->SetLabel(bufferS);
bufferS = wxString::Format(wxT("%i"),m_file->GetTransferingSrcCount());
CastChild(IDC_SOURCECOUNT2,wxControl)->SetLabel(bufferS);
bufferS = wxString::Format(wxT("%i (%.1f%%)"),
m_file->GetAvailablePartCount(),
((m_file->GetAvailablePartCount() * 100.0f)/ m_file->GetPartCount()));
CastChild(IDC_PARTAVAILABLE,wxControl)->SetLabel(bufferS);
bufferS = CastSecondsToHM(m_file->GetDlActiveTime());
CastChild(IDC_DLACTIVETIME, wxControl)->SetLabel(bufferS);
if (m_file->lastseencomplete==0) {
bufferS = wxString(_("Unknown")).MakeLower();
} else {
wxDateTime last_seen(m_file->lastseencomplete);
bufferS = last_seen.FormatISODate() + wxT(" ") + last_seen.FormatISOTime();
}
CastChild(IDC_LASTSEENCOMPL,wxControl)->SetLabel(bufferS);
setEnableForApplyButton();
// disable "Show all comments" button if there are no comments
FileRatingList list;
m_file->GetRatingAndComments(list);
CastChild(IDC_CMTBT, wxControl)->Enable(!list.empty());
FillSourcenameList();
Layout();
}
示例4: DecodeStatisticsDat
void DecodeStatisticsDat(const CFileDataIO& file)
{
uint8_t version = file.ReadUInt8();
cout << "Version : " << (unsigned)version << '\n';
if (version == 0) {
uint64_t tmp = file.ReadUInt64();
cout << "Total sent bytes : " << tmp << " (" << CastItoXBytes(tmp) << ")\n";
tmp = file.ReadUInt64();
cout << "Total received bytes : " << tmp << " (" << CastItoXBytes(tmp) << ")\n";
}
}
示例5: AddDebugLogLineN
// Check all clients that uploaded corrupted data,
// and ban them if they didn't upload enough good data too.
void CCorruptionBlackBox::EvaluateData()
{
CCBBClientMap::iterator it = m_badClients.begin();
for (; it != m_badClients.end(); ++it) {
uint32 ip = it->first;
uint64 bad = it->second.m_downloaded;
if (!bad) {
wxFAIL; // this should not happen
continue;
}
uint64 good = 0;
CCBBClientMap::iterator it2 = m_goodClients.find(ip);
if (it2 != m_goodClients.end()) {
good = it2->second.m_downloaded;
}
int nCorruptPercentage = bad * 100 / (bad + good);
if (nCorruptPercentage > CBB_BANTHRESHOLD) {
CUpDownClient* pEvilClient = theApp->clientlist->FindClientByIP(ip);
wxString clientName;
if (pEvilClient != NULL) {
clientName = pEvilClient->GetClientShortInfo();
AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Banning: Found client which sent %d of %d corrupted data, %s"))
% m_partNumber % bad % (good + bad) % pEvilClient->GetClientFullInfo());
theApp->clientlist->AddTrackClient(pEvilClient);
pEvilClient->Ban(); // Identified as sender of corrupt data
// Stop download right away
pEvilClient->SetDownloadState(DS_BANNED);
if (pEvilClient->Disconnected(wxT("Upload of corrupted data"))) {
pEvilClient->Safe_Delete();
}
} else {
clientName = Uint32toStringIP(ip);
theApp->clientlist->AddBannedClient(ip);
}
AddLogLineN(CFormat(_("Banned client %s for sending %s corrupt data of %s total for the file '%s'"))
% clientName % CastItoXBytes(bad) % CastItoXBytes(good + bad) % m_fileName);
} else {
CUpDownClient* pSuspectClient = theApp->clientlist->FindClientByIP(ip);
if (pSuspectClient != NULL) {
AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Reporting: Found client which probably sent %d of %d corrupted data, but it is within the acceptable limit, %s"))
% m_partNumber % bad % (good + bad) % pSuspectClient->GetClientFullInfo());
theApp->clientlist->AddTrackClient(pSuspectClient);
} else {
AddDebugLogLineN(logPartFile, CFormat(wxT("CorruptionBlackBox(%s): Reporting: Found client which probably sent %d of %d corrupted data, but it is within the acceptable limit, %s"))
% m_partNumber % bad % (good + bad) % Uint32toStringIP(ip));
}
}
}
}
示例6: SetDlgItemText
void CStatisticsInfo::SetTransfer(int range, uint64 pos)
{
pop_bartrans.SetRange32(0, range/1024);
pop_bartrans.SetPos((int)pos/1024);
pop_bartrans.SetShowPercent();
SetDlgItemText(IDC_STRANSFERRED, CastItoXBytes(pos, false, false));
}
示例7: GetConversionState
void CPartFileConvertDlg::UpdateJobInfo(ConvertInfo& info)
{
if (s_convertgui) {
// search jobitem in listctrl
long itemnr = s_convertgui->m_joblist->FindItem(-1, info.id);
// if it does not exist, add it
if (itemnr == -1) {
itemnr = s_convertgui->m_joblist->InsertItem(s_convertgui->m_joblist->GetItemCount(), info.folder.GetPrintable());
if (itemnr != -1) {
s_convertgui->m_joblist->SetItemData(itemnr, info.id);
}
}
// update columns
if (itemnr != -1) {
s_convertgui->m_joblist->SetItem(itemnr, 0, info.filename.IsOk() ? info.folder.GetPrintable() : info.filename.GetPrintable() );
s_convertgui->m_joblist->SetItem(itemnr, 1, GetConversionState(info.state) );
if (info.size > 0) {
s_convertgui->m_joblist->SetItem(itemnr, 2, CFormat(_("%s (Disk: %s)")) % CastItoXBytes(info.size) % CastItoXBytes(info.spaceneeded));
} else {
s_convertgui->m_joblist->SetItem(itemnr, 2, wxEmptyString);
}
s_convertgui->m_joblist->SetItem(itemnr, 3, info.filehash);
}
}
}
示例8: GetDlgItemText
// 更新ui上的feed大小信息
void CDlgFeedConfig::UpdateFeedSizeInfo()
{
// 磁盘剩余空间
CString strSaveDir;
GetDlgItemText(IDC_EDIT_RW_SAVE_DIR, strSaveDir);
uint64 uFreeSpace;
if ( strSaveDir.GetLength() < 3 || strSaveDir.GetAt(1) != _T(':') || strSaveDir.GetAt(2) != _T('\\') )
{
uFreeSpace = 0;
}
else
{
uFreeSpace = GetFreeDiskSpaceX(strSaveDir.Left(3));
}
// 订阅大小(磁盘剩余空间)
CString strText;
strText.Format(_T("%s (%s%s)"),
m_strFeedSize,
GetResString(IDS_ADDTASKDLG_FREE_SPACE),
CastItoXBytes(uFreeSpace)
);
SetDlgItemText(IDC_EDIT_RW_FEED_SIZE, strText);
}
示例9: SetDlgItemText
void CDownloadDetailDlg::SetPartFileInfo(CKnownFile *file)
{
if(! file) return ;
CPartFile *pPartFile = NULL;
if ( file->IsKindOf(RUNTIME_CLASS(CPartFile)) )
pPartFile = (CPartFile*) file;
SetDlgItemText(IDC_STATIC_FILENAME, file->GetFilePath());
CString strTmp;
time_t restTime;
if ( NULL != pPartFile )
{
if (!thePrefs.UseSimpleTimeRemainingComputation())
restTime = pPartFile->getTimeRemaining();
else
restTime = pPartFile->getTimeRemainingSimple();
strTmp.Format(_T("%s (%s)"), CastSecondsToHM(restTime), CastItoXBytes((pPartFile->GetFileSize() - pPartFile->GetCompletedSize()), false, false));
SetDlgItemText(IDC_STATIC_LAST_SEEN_TIME, strTmp);
}
}
示例10: CastItoXBytes
void CHttpDownloadDlg::SetTimeLeft(DWORD dwSecondsLeft, DWORD dwBytesRead, DWORD dwFileSize)
{
CString sOf;
sOf.Format(GetResString(IDS_HTTPDOWNLOAD_OF), CastItoXBytes((uint64)dwBytesRead, false, false), CastItoXBytes((uint64)dwFileSize, false, false));
CString sTimeLeft;
sTimeLeft.Format(GetResString(IDS_HTTPDOWNLOAD_TIMELEFT), CastSecondsToHM(dwSecondsLeft), sOf);
m_ctrlTimeLeft.SetWindowText(sTimeLeft);
}
示例11: ScreenToClient
void CUploadListCtrl::OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMLVGETINFOTIP>(pNMHDR);
if (pGetInfoTip->iSubItem == 0)
{
LVHITTESTINFO hti = {0};
::GetCursorPos(&hti.pt);
ScreenToClient(&hti.pt);
if (SubItemHitTest(&hti) == -1 || hti.iItem != pGetInfoTip->iItem || hti.iSubItem != 0){
// don' show the default label tip for the main item, if the mouse is not over the main item
if ((pGetInfoTip->dwFlags & LVGIT_UNFOLDED) == 0 && pGetInfoTip->cchTextMax > 0 && pGetInfoTip->pszText[0] != '\0')
pGetInfoTip->pszText[0] = '\0';
return;
}
const CUpDownClient* client = (CUpDownClient*)GetItemData(pGetInfoTip->iItem);
if (client && pGetInfoTip->pszText && pGetInfoTip->cchTextMax > 0)
{
CString info;
CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID());
// build info text and display it
info.Format(GetResString(IDS_USERINFO), client->GetUserName());
if (file)
{
info += GetResString(IDS_SF_REQUESTED) + _T(" ") + CString(file->GetFileName()) + _T("\n");
CString stat;
stat.Format(GetResString(IDS_FILESTATS_SESSION)+GetResString(IDS_FILESTATS_TOTAL),
file->statistic.GetAccepts(), file->statistic.GetRequests(), CastItoXBytes(file->statistic.GetTransferred(), false, false),
file->statistic.GetAllTimeAccepts(), file->statistic.GetAllTimeRequests(), CastItoXBytes(file->statistic.GetAllTimeTransferred(), false, false) );
info += stat;
}
else
{
info += GetResString(IDS_REQ_UNKNOWNFILE);
}
_tcsncpy(pGetInfoTip->pszText, info, pGetInfoTip->cchTextMax);
pGetInfoTip->pszText[pGetInfoTip->cchTextMax-1] = _T('\0');
}
}
*pResult = 0;
}
示例12: FormatValue
void FormatValue(CFormat& format, const CECTag* tag)
{
wxASSERT(tag->GetTagName() == EC_TAG_STAT_NODE_VALUE);
wxString extra;
const CECTag *tmp_tag = tag->GetTagByName(EC_TAG_STAT_NODE_VALUE);
if (tmp_tag) {
wxString tmp_fmt;
const CECTag* tmp_vt = tmp_tag->GetTagByName(EC_TAG_STAT_VALUE_TYPE);
EC_STATTREE_NODE_VALUE_TYPE tmp_valueType = tmp_vt != NULL ? (EC_STATTREE_NODE_VALUE_TYPE)tmp_vt->GetInt() : EC_VALUE_INTEGER;
switch (tmp_valueType) {
case EC_VALUE_INTEGER:
tmp_fmt = wxT("%llu");
break;
case EC_VALUE_DOUBLE:
tmp_fmt = wxT("%.2f%%"); // it's used for percentages
break;
default:
tmp_fmt = wxT("%s");
}
CFormat tmp_format(wxT(" (") + tmp_fmt + wxT(")"));
FormatValue(tmp_format, tmp_tag);
extra = tmp_format.GetString();
}
const CECTag* vt = tag->GetTagByName(EC_TAG_STAT_VALUE_TYPE);
EC_STATTREE_NODE_VALUE_TYPE valueType = vt != NULL ? (EC_STATTREE_NODE_VALUE_TYPE)vt->GetInt() : EC_VALUE_INTEGER;
switch (valueType) {
case EC_VALUE_INTEGER:
format = format % tag->GetInt();
break;
case EC_VALUE_ISTRING:
format = format % (CFormat(wxT("%u")) % tag->GetInt() + extra);
break;
case EC_VALUE_BYTES:
format = format % (CastItoXBytes(tag->GetInt()) + extra);
break;
case EC_VALUE_ISHORT:
format = format % (CastItoIShort(tag->GetInt()) + extra);
break;
case EC_VALUE_TIME:
format = format % (CastSecondsToHM(tag->GetInt()) + extra);
break;
case EC_VALUE_SPEED:
format = format % (CastItoSpeed(tag->GetInt()) + extra);
break;
case EC_VALUE_STRING:
format = format % (wxGetTranslation(tag->GetStringData()) + extra);
break;
case EC_VALUE_DOUBLE:
format = format % tag->GetDoubleData();
break;
default:
wxFAIL;
}
}
示例13: ASSERT
void CMiniMule::UpdateContent(UINT uUpDatarate, UINT uDownDatarate)
{
ASSERT( GetCurrentThreadId() == _uMainThreadId );
if (m_bResolveImages)
{
static const LPCTSTR _apszConnectedImgs[] =
{
_T("CONNECTEDNOTNOT.GIF"),
_T("CONNECTEDNOTLOW.GIF"),
_T("CONNECTEDNOTHIGH.GIF"),
_T("CONNECTEDLOWNOT.GIF"),
_T("CONNECTEDLOWLOW.GIF"),
_T("CONNECTEDLOWHIGH.GIF"),
_T("CONNECTEDHIGHNOT.GIF"),
_T("CONNECTEDHIGHLOW.GIF"),
_T("CONNECTEDHIGHHIGH.GIF")
};
UINT uIconIdx = theApp.emuledlg->GetConnectionStateIconIndex();
if (uIconIdx >= ARRSIZE(_apszConnectedImgs))
{
ASSERT(0);
uIconIdx = 0;
}
TCHAR szModulePath[_MAX_PATH];
if (GetModuleFileName(AfxGetResourceHandle(), szModulePath, ARRSIZE(szModulePath)))
{
CString strFilePathUrl(CreateFilePathUrl(szModulePath, INTERNET_SCHEME_RES));
CComPtr<IHTMLImgElement> elm;
GetElementInterface(_T("connectedImg"), &elm);
if (elm)
{
CString strResourceURL;
strResourceURL.Format(_T("%s/%s"), strFilePathUrl, _apszConnectedImgs[uIconIdx]);
elm->put_src(CComBSTR(strResourceURL));
}
}
}
SetElementHtml(_T("connected"), CComBSTR(theApp.IsConnected() ? GetResString(IDS_YES) : GetResString(IDS_NO)));
SetElementHtml(_T("upRate"), CComBSTR(theApp.emuledlg->GetUpDatarateString(uUpDatarate)));
SetElementHtml(_T("downRate"), CComBSTR(theApp.emuledlg->GetDownDatarateString(uDownDatarate)));
UINT uCompleted = 0;
if (thePrefs.GetRemoveFinishedDownloads())
uCompleted = thePrefs.GetDownSessionCompletedFiles();
else if (theApp.emuledlg && theApp.emuledlg->transferwnd && theApp.emuledlg->transferwnd->downloadlistctrl.m_hWnd)
{
int iTotal;
uCompleted = theApp.emuledlg->transferwnd->downloadlistctrl.GetCompleteDownloads(-1, iTotal); // [Ded]: -1 to get the count of all completed files in all categories
}
SetElementHtml(_T("completed"), CComBSTR(CastItoIShort(uCompleted, false, 0)));
SetElementHtml(_T("freeSpace"), CComBSTR(CastItoXBytes(GetFreeTempSpace(-1), false, false)));
}
示例14: UpdateGauge
void UpdateGauge(int total, int current) {
CFormat label( wxT("( %s / %s )") );
label % CastItoXBytes(current);
if (total > 0) {
label % CastItoXBytes(total);
} else {
label % _("Unknown");
}
CastChild(IDC_DOWNLOADSIZE, wxStaticText)->SetLabel(label.GetString());
if (total && (total != m_progressbar->GetRange())) {
m_progressbar->SetRange(total);
}
if (current && (current <= total)) {
m_progressbar->SetValue(current);
}
Layout();
}
示例15: CFormat
wxString CStatTreeItemPacketTotals::GetDisplayString() const
{
uint32_t tmp_packets = m_packets;
uint64_t tmp_bytes = m_bytes;
for (std::vector<CStatTreeItemPackets*>::const_iterator it = m_counters.begin();
it != m_counters.end(); ++it) {
tmp_packets += (*it)->m_packets;
tmp_bytes += (*it)->m_bytes;
}
return CFormat(wxGetTranslation(m_label)) %
a_brackets_b(CastItoXBytes(tmp_bytes), CastItoIShort(tmp_packets));
}