📄 statisticsdlg.cpp
字号:
if(currtop<ver && ver<lasttop && ver != 0x91)
{
double percent = (double)cnt/totcnt;
if( lasttop == 0xFFFFFFFF &&
( (totcnt > 75 && ((cnt <= 2) || percent < 0.01)) ||
(totcnt > 50 && cnt <= 1)
)
)
continue;
topper=percent;
topver=ver;
topcnt=cnt;
currtop=ver;
}
}
lasttop=currtop;
currtop=0;
if(topcnt)
cbuffer.Format("v%.1f: %i (%1.1f%%)", (float)topver/10.0f, topcnt, topper*100);
else
cbuffer="";
stattree.SetItemText(cli_versions[i+10], cbuffer);
}
}
if (stattree.GetItemState(cli3, TVIS_EXPANDED)&&TVIS_EXPANDED == TVIS_EXPANDED ) {
uint32 totcnt = myStats[4];
//--- find top 4 eDonkey-Hybrid client versions ---
uint32 currtop = 0;
uint32 lasttop = 0xFFFFFFFF;
for(uint32 i=0; i<4; i++)
{
POSITION pos=clientVersionEDonkeyHybrid.GetStartPosition();
uint32 topver=0;
uint32 topcnt=0;
double topper=0;
while(pos)
{
uint16 ver;
uint32 cnt;
clientVersionEDonkeyHybrid.GetNextAssoc(pos, ver, cnt);
if(currtop<ver && ver<lasttop && ver != 0x91)
{
double percent = (double)cnt/totcnt;
if( lasttop == 0xFFFFFFFF &&
( (totcnt > 75 && ((cnt <= 2) || percent < 0.01)) ||
(totcnt > 50 && cnt <= 1)
)
)
continue;
topper=percent;
topver=ver;
topcnt=cnt;
currtop=ver;
}
}
lasttop=currtop;
currtop=0;
if(topcnt)
cbuffer.Format("v%.1f: %i (%1.1f%%)", (float)topver/10.0f, topcnt, topper*100);
else
cbuffer="";
stattree.SetItemText(cli_versions[i+6], cbuffer);
}
}
if (stattree.GetItemState(cli1, TVIS_EXPANDED)&&TVIS_EXPANDED == TVIS_EXPANDED ) {
uint32 totcnt = myStats[2];
//--- find top 4 eMule client versions ---
uint32 currtop = 0;
uint32 lasttop = 0xFFFFFFFF;
for(uint32 i=0; i<6; i++)
{
POSITION pos=clientVersionEMule.GetStartPosition();
uint32 topver=0;
uint32 topcnt=0;
double topper=0;
while(pos)
{
uint16 ver;
uint32 cnt;
clientVersionEMule.GetNextAssoc(pos, ver, cnt);
if(currtop<ver && ver<lasttop )
{
double percent = (double)cnt/totcnt;
if( lasttop == 0xFFFFFFFF &&
( (totcnt > 75 && ((cnt <= 2) || percent < 0.01)) ||
(totcnt > 50 && cnt <= 1)
)
)
continue;
topper=percent;
topver=ver;
topcnt=cnt;
currtop=ver;
}
}
lasttop=currtop;
currtop=0;
if(topcnt)
cbuffer.Format("v%.2f: %i (%1.1f%%)", (float)topver/1000.0f, topcnt, topper*100);
else
cbuffer="";
stattree.SetItemText(cli_versions[i], cbuffer);
}
// xrmb
}
// get serverstats
uint32 servtotal;
uint32 servfail;
uint32 servuser;
uint32 servfile;
uint32 servtuser;
uint32 servtfile;
float servocc;
theApp.serverlist->GetStatus( servtotal, servfail, servuser, servfile, servtuser, servtfile,servocc);
cbuffer.Format("%s: %i",GetResString(IDS_SF_WORKING),servtotal-servfail);stattree.SetItemText(srv1, cbuffer);
cbuffer.Format("%s: %i",GetResString(IDS_SF_FAIL),servfail);stattree.SetItemText(srv2, cbuffer);
cbuffer.Format("%s: %i",GetResString(IDS_SF_TOTAL),servtotal);stattree.SetItemText(srv3, cbuffer);
cbuffer.Format("%s: %i",GetResString(IDS_SF_DELCOUNT),theApp.serverlist->GetDeletedServerCount());stattree.SetItemText(srv4, cbuffer);
cbuffer.Format("%s: %i",GetResString(IDS_SF_WUSER),servuser);stattree.SetItemText(srv5, cbuffer);
cbuffer.Format("%s: %i",GetResString(IDS_SF_WFILE),servfile);stattree.SetItemText(srv6, cbuffer);
cbuffer.Format("%s: %i",GetResString(IDS_SF_USER),servtuser);stattree.SetItemText(srv7, cbuffer);
cbuffer.Format("%s: %i",GetResString(IDS_SF_FILE),servtfile);stattree.SetItemText(srv8, cbuffer);
cbuffer.Format("%s: %i",GetResString(IDS_SF_ACTIVECON),activeconnections);stattree.SetItemText(con6, cbuffer);
cbuffer.Format(GetResString(IDS_SF_SRVOCC),servocc);stattree.SetItemText(srv9, cbuffer);
uint32 m_itemp = theApp.listensocket->GetMaxConnectionReached();
if( m_itemp != m_ilastMaxConnReached ){
char osDate[30],osTime[30];
_strtime( osTime );
_strdate( osDate );
cbuffer.Format("%s: %i : %s %s",GetResString(IDS_SF_MAXCONLIMITREACHED),m_itemp,osDate,osTime);stattree.SetItemText(con7, cbuffer);
m_ilastMaxConnReached = m_itemp;
}
else if( m_itemp == 0 ){
cbuffer.Format("%s: %i",GetResString(IDS_SF_MAXCONLIMITREACHED),m_itemp);stattree.SetItemText(con7, cbuffer);}
if(theApp.serverconnect->IsConnected()){
cbuffer.Format("%s: %i",GetResString(IDS_SF_AVGCON),(int)averageconnections);stattree.SetItemText(con8, cbuffer);
}
else{
stattree.SetItemText(con8, GetResString(IDS_STATS_WAITCONN));
}
cbuffer.Format("%s: %i",GetResString(IDS_SF_PEAKCON),peakconnections);
stattree.SetItemText(con9, cbuffer);
}
float CStatisticsDlg::GetAvgDownloadRate(int averageType) {
if (averageType==AVG_SESSION) {
if (theApp.stat_transferStarttime ==0) return 0;
DWORD running=(GetTickCount()-theApp.stat_transferStarttime)/1000;
if (running<5) return 0;
return (float)(theApp.stat_sessionReceivedBytes/1024) / running;
} else {
if (downrateHistory.size()==0) return 0;
return (float)((float)((downrateHistory.front()-downrateHistory.back())/1024)/downrateHistory.size());
}
}
float CStatisticsDlg::GetAvgUploadRate(int averageType) {
if (averageType==AVG_SESSION) {
if (theApp.stat_transferStarttime==0) return 0;
DWORD running=(GetTickCount()-theApp.stat_transferStarttime)/1000;
if (running<5) return 0;
return (float)(theApp.stat_sessionSentBytes/1024) / running;
} else {
if (uprateHistory.size()==0) return 0;
return (float)((float)((uprateHistory.front()-uprateHistory.back())/1024)/uprateHistory.size());
}
}
void CStatisticsDlg::OnShowWindow(BOOL bShow,UINT nStatus){
}
void CStatisticsDlg::OnSize(UINT nType, int cx, int cy)
{
CResizableDialog::OnSize(nType, cx, cy);
ShowInterval();
} //OnSize
void CStatisticsDlg::ShowInterval(){
// Check if OScope already initialized
if(m_DownloadOMeter.GetSafeHwnd() != NULL && m_UploadOMeter.GetSafeHwnd() != NULL){
// Retrieve the size (in pixel) of the OScope
CRect plotRect;
m_UploadOMeter.GetPlotRect(plotRect);
// Dynamic update of time scale [Maella]
int shownSecs = plotRect.Width() * theApp.glob_prefs->GetTrafficOMeterInterval();
if(shownSecs == 0){
m_DownloadOMeter.SetXUnits(GetResString(IDS_STOPPED));
m_UploadOMeter.SetXUnits(GetResString(IDS_STOPPED));
}
else {
const CString buffer = CastSecondsToHM(shownSecs);
m_UploadOMeter.SetXUnits(buffer);
m_DownloadOMeter.SetXUnits(buffer);
}
UpdateData(FALSE);
}
}
void CStatisticsDlg::SetARange(bool SetDownload,int maxValue){
if (SetDownload) {
m_DownloadOMeter.SetRange(0, maxValue+4, 0);
m_DownloadOMeter.SetRange(0, maxValue+4, 1);
m_DownloadOMeter.SetRange(0, maxValue+4, 2);
}else{
m_UploadOMeter.SetRange(0, maxValue+4, 0) ;
m_UploadOMeter.SetRange(0, maxValue+4, 1);
m_UploadOMeter.SetRange(0, maxValue+4, 2);
}
}
void CStatisticsDlg::Localize(){
GetDlgItem(IDC_STATIC_D3)->SetWindowText(GetResString(IDS_ST_DOWNLOAD));
GetDlgItem(IDC_STATIC_U)->SetWindowText(GetResString(IDS_ST_UPLOAD));
GetDlgItem(IDC_STATIC_D)->SetWindowText(GetResString(IDS_ST_CURRENT));
GetDlgItem(IDC_STATIC_U2)->SetWindowText(GetResString(IDS_ST_CURRENT));
GetDlgItem(IDC_STATIC_D2)->SetWindowText(GetResString(IDS_ST_SESSION));
GetDlgItem(IDC_STATIC_U3)->SetWindowText(GetResString(IDS_ST_SESSION));
GetDlgItem(IDC_STATIC_S2)->SetWindowText(GetResString(IDS_ST_ACTIVED));
GetDlgItem(IDC_STATIC_S0)->SetWindowText(GetResString(IDS_ST_ACTIVEC));
GetDlgItem(IDC_STATIC_S1)->SetWindowText(GetResString(IDS_ST_ACTIVEU));
GetDlgItem(IDC_STATIC_S3)->SetWindowText(GetResString(IDS_ST_WAITINGU));
CString value;value.Format(" (%u %s)",theApp.glob_prefs->GetStatsAverageMinutes(),GetResString(IDS_MINS) );
GetDlgItem(IDC_TIMEAVG1)->SetWindowText(GetResString(IDS_AVG) + value );
GetDlgItem(IDC_TIMEAVG2)->SetWindowText(GetResString(IDS_AVG) + value);
}
CString CStatisticsDlg::ExportHTML() {
int8 ix;
CString temp;
CString text="";
HTREEITEM item;
item=stattree.GetRootItem();
text=stattree.GetItemText(item);
HTREEITEM lastparent=item;
while (item!=NULL)
{
item=stattree.GetNextVisibleItem(item);
if (item==NULL) break;
stattree.Expand(item,TVE_EXPAND);
temp="";
for (ix=0;ix<3*stattree.GetItemData(item);ix++) temp+=" ";
text+="<br>"+temp+stattree.GetItemText(item);
}
return text;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -