📄 statisticsdlg.cpp
字号:
// <-----khaos-
return true;
}
void CStatisticsDlg::SetupLegend( int ResIdx, int ElmtIdx, int legendNr){
CRect Rect;
GetDlgItem( ResIdx )->GetWindowRect( Rect );
ScreenToClient( Rect );
if (legendNr==1){
if (!m_Led1[ ElmtIdx ]) m_Led1[ ElmtIdx ].Create( WS_VISIBLE | WS_CHILD, Rect, this );
m_Led1[ ElmtIdx ].SetBackgroundColor( m_DownloadOMeter.GetPlotColor( ElmtIdx ) );
m_Led1[ ElmtIdx ].SetFrameColor( RGB( 0x00, 0x00, 0x00 ) );
} else if (legendNr==2) {
if (!m_Led2[ ElmtIdx ]) m_Led2[ ElmtIdx ].Create( WS_VISIBLE | WS_CHILD, Rect, this );
m_Led2[ ElmtIdx ].SetBackgroundColor( m_UploadOMeter.GetPlotColor( ElmtIdx ) );
m_Led2[ ElmtIdx ].SetFrameColor( RGB( 0x00, 0x00, 0x00 ) );
} else if (legendNr==3){
if (!m_Led3[ ElmtIdx ]) m_Led3[ ElmtIdx ].Create( WS_VISIBLE | WS_CHILD, Rect, this );
m_Led3[ ElmtIdx ].SetBackgroundColor( m_Statistics.GetPlotColor( ElmtIdx ) );
m_Led3[ ElmtIdx ].SetFrameColor( RGB( 0x00, 0x00, 0x00 ) );
}
}
void CStatisticsDlg::RepaintMeters() {
m_DownloadOMeter.SetBackgroundColor(thePrefs.GetStatsColor(0)) ;
m_DownloadOMeter.SetGridColor(thePrefs.GetStatsColor(1)) ;
m_DownloadOMeter.SetPlotColor( thePrefs.GetStatsColor(4) ,0) ;
m_DownloadOMeter.SetPlotColor( thePrefs.GetStatsColor(3) ,1) ;
m_DownloadOMeter.SetPlotColor( thePrefs.GetStatsColor(2) ,2) ;
m_UploadOMeter.SetBackgroundColor(thePrefs.GetStatsColor(0)) ;
m_UploadOMeter.SetGridColor(thePrefs.GetStatsColor(1)) ;
m_UploadOMeter.SetPlotColor( thePrefs.GetStatsColor(7) ,0) ;
m_UploadOMeter.SetPlotColor( thePrefs.GetStatsColor(6) ,1) ;
m_UploadOMeter.SetPlotColor( thePrefs.GetStatsColor(5) ,2) ;
m_Statistics.SetBackgroundColor(thePrefs.GetStatsColor(0)) ;
m_Statistics.SetGridColor(thePrefs.GetStatsColor(1)) ;
m_Statistics.SetPlotColor( thePrefs.GetStatsColor(8),0) ;
m_Statistics.SetPlotColor( thePrefs.GetStatsColor(10),1) ;
//m_Statistics.SetPlotColor( thePrefs.GetStatsColor(10),2) ;
m_Statistics.SetPlotColor( thePrefs.GetStatsColor(9),3) ;
SetupLegend( IDC_C0_2, 0 ,1);
SetupLegend( IDC_C0_3, 1 ,1);
SetupLegend( IDC_C0, 2 ,1);
SetupLegend( IDC_C1_2, 0 ,2 );
SetupLegend( IDC_C1_3, 1 ,2 );
SetupLegend( IDC_C1, 2 ,2 );
SetupLegend( IDC_S0, 0 ,3);
SetupLegend( IDC_S1, 1 ,3);
//SetupLegend( IDC_S2, 2 ,3);
SetupLegend( IDC_S3, 3 ,3);
}
void CStatisticsDlg::SetCurrentRate(float uploadrate, float downloadrate)
{
double m_dPlotDataUp[3];
double m_dPlotDataDown[3];
if (!theApp.emuledlg->IsRunning())
return;
// current rate
m_dPlotDataDown[2]=downloadrate;
m_dPlotDataUp[2]=uploadrate;
// -khaos--+++>
//I moved code from here that updated maxDown in the original code...
// <-----khaos-
// Websever [kuchin]
UpDown updown;
updown.upload = uploadrate;
updown.download = downloadrate;
updown.connections=theApp.listensocket->GetActiveConnections();
theApp.webserver->AddStatsLine(updown);
// averages
m_dPlotDataDown[0]= theStats.GetAvgDownloadRate(AVG_SESSION);
m_dPlotDataUp[0]= theStats.GetAvgUploadRate(AVG_SESSION);
m_dPlotDataDown[1]= theStats.GetAvgDownloadRate(AVG_TIME);
m_dPlotDataUp[1]= theStats.GetAvgUploadRate(AVG_TIME);
// show
m_DownloadOMeter.AppendPoints(m_dPlotDataDown);
m_UploadOMeter.AppendPoints(m_dPlotDataUp);
// get Partialfiles summary
CDownloadQueue::SDownloadStats myStats;
theApp.downloadqueue->GetDownloadStats(myStats);
// -khaos--+++> Ratio is now handled in the scope itself
m_dPlotDataMore[0]=theApp.listensocket->GetActiveConnections();
// <-----khaos-
m_dPlotDataMore[1]=theApp.uploadqueue->GetUploadQueueLength();
m_dPlotDataMore[2]=0;//theApp.uploadqueue->GetWaitingUserCount();
m_dPlotDataMore[3]=myStats.a[1];
m_Statistics.AppendPoints(m_dPlotDataMore);
}
// -khaos--+++> Completely rewritten ShowStatistics
void CStatisticsDlg::ShowStatistics(bool forceUpdate) {
stattree.SetRedraw(false);
CString cbuffer;
// Set Tree Values
// TRANSFER SECTION
// If a section is not expanded, don't waste CPU cycles updating it.
if (forceUpdate || stattree.IsExpanded(h_transfer)) {
uint32 statGoodSessions = 0;
uint32 statBadSessions = 0;
double percentSessions = 0;
// Transfer Ratios
if ( theApp.stat_sessionReceivedBytes>0 && theApp.stat_sessionSentBytes>0 ) {
// Session
if (theApp.stat_sessionReceivedBytes<theApp.stat_sessionSentBytes) {
cbuffer.Format(_T("%s %.2f : 1"),GetResString(IDS_STATS_SRATIO),(float)theApp.stat_sessionSentBytes/theApp.stat_sessionReceivedBytes);
stattree.SetItemText(trans[0], cbuffer);
} else {
cbuffer.Format(_T("%s 1 : %.2f"),GetResString(IDS_STATS_SRATIO),(float)theApp.stat_sessionReceivedBytes/theApp.stat_sessionSentBytes);
stattree.SetItemText(trans[0], cbuffer);
}
}
else {
cbuffer.Format(_T("%s %s"), GetResString(IDS_STATS_SRATIO), GetResString(IDS_FSTAT_WAITING)); // Localize
stattree.SetItemText(trans[0], cbuffer);
}
if ( theApp.stat_sessionReceivedBytes>0 && theApp.stat_sessionSentBytes>0) {
// Session
if (theApp.stat_sessionSentBytes > theApp.stat_sessionSentBytesToFriend && theApp.stat_sessionReceivedBytes<theApp.stat_sessionSentBytes-theApp.stat_sessionSentBytesToFriend) {
cbuffer.Format(_T("%s %.2f : 1"),GetResString(IDS_STATS_FRATIO),(float)(theApp.stat_sessionSentBytes-theApp.stat_sessionSentBytesToFriend)/theApp.stat_sessionReceivedBytes);
stattree.SetItemText(trans[1], cbuffer);
} else {
cbuffer.Format(_T("%s 1 : %.2f"),GetResString(IDS_STATS_FRATIO),(float)theApp.stat_sessionReceivedBytes/(theApp.stat_sessionSentBytes-theApp.stat_sessionSentBytesToFriend));
stattree.SetItemText(trans[1], cbuffer);
}
}
else {
cbuffer.Format(_T("%s %s"), GetResString(IDS_STATS_FRATIO), GetResString(IDS_FSTAT_WAITING)); // Localize
stattree.SetItemText(trans[1], cbuffer);
}
if ( (thePrefs.GetTotalDownloaded()>0 && thePrefs.GetTotalUploaded()>0) || (theApp.stat_sessionReceivedBytes>0 && theApp.stat_sessionSentBytes>0) ) {
// Cumulative
if ((theApp.stat_sessionReceivedBytes+thePrefs.GetTotalDownloaded())<(theApp.stat_sessionSentBytes+thePrefs.GetTotalUploaded())) {
cbuffer.Format(_T("%s %.2f : 1"),GetResString(IDS_STATS_CRATIO),(float)(theApp.stat_sessionSentBytes+thePrefs.GetTotalUploaded())/(theApp.stat_sessionReceivedBytes+thePrefs.GetTotalDownloaded()));
stattree.SetItemText(trans[2], cbuffer);
} else {
cbuffer.Format(_T("%s 1 : %.2f"),GetResString(IDS_STATS_CRATIO),(float)(theApp.stat_sessionReceivedBytes+thePrefs.GetTotalDownloaded())/(theApp.stat_sessionSentBytes+thePrefs.GetTotalUploaded()));
stattree.SetItemText(trans[2], cbuffer);
}
}
else {
cbuffer.Format(_T("%s %s"), GetResString(IDS_STATS_CRATIO), GetResString(IDS_FSTAT_WAITING)); // Localize
stattree.SetItemText(trans[2], cbuffer);
}
// TRANSFER -> DOWNLOADS SECTION
if (forceUpdate || stattree.IsExpanded(h_download)) {
uint64 DownOHTotal = 0;
uint64 DownOHTotalPackets = 0;
CDownloadQueue::SDownloadStats myStats;
theApp.downloadqueue->GetDownloadStats(myStats);
// TRANSFER -> DOWNLOADS -> SESSION SECTION
if (forceUpdate || stattree.IsExpanded(h_down_session)) {
// Downloaded Data
cbuffer.Format( GetResString( IDS_STATS_DDATA ) , CastItoXBytes( theApp.stat_sessionReceivedBytes ) );
stattree.SetItemText( down_S[0] , cbuffer );
if (forceUpdate || stattree.IsExpanded(down_S[0])) {
// Downloaded Data By Client
if (forceUpdate || stattree.IsExpanded(hdown_scb)) {
int i = 0;
uint64 DownDataTotal = thePrefs.GetDownSessionClientData();
uint64 DownDataClient = thePrefs.GetDownData_EMULE();
double percentClientTransferred = 0;
if ( DownDataTotal!=0 && DownDataClient!=0 )
percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
cbuffer.Format( _T("eMule: %s (%1.1f%%)") , CastItoXBytes( DownDataClient ) , percentClientTransferred);
stattree.SetItemText( down_scb[i] , cbuffer ); i++;
DownDataClient = thePrefs.GetDownData_EDONKEYHYBRID();
if ( DownDataTotal!=0 && DownDataClient!=0 )
percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
else
percentClientTransferred = 0;
cbuffer.Format( _T("eD Hybrid: %s (%1.1f%%)") , CastItoXBytes( DownDataClient ) , percentClientTransferred );
stattree.SetItemText( down_scb[i] , cbuffer ); i++;
DownDataClient = thePrefs.GetDownData_EDONKEY();
if ( DownDataTotal!=0 && DownDataClient!=0 )
percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
else
percentClientTransferred = 0;
cbuffer.Format( _T("eDonkey: %s (%1.1f%%)") , CastItoXBytes( DownDataClient ), percentClientTransferred );
stattree.SetItemText( down_scb[i] , cbuffer ); i++;
DownDataClient = thePrefs.GetDownData_AMULE();
if ( DownDataTotal!=0 && DownDataClient!=0 )
percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
else
percentClientTransferred = 0;
cbuffer.Format( _T("aMule: %s (%1.1f%%)") , CastItoXBytes( DownDataClient ), percentClientTransferred );
stattree.SetItemText( down_scb[i] , cbuffer ); i++;
DownDataClient = thePrefs.GetDownData_MLDONKEY();
if ( DownDataTotal!=0 && DownDataClient!=0 )
percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
else
percentClientTransferred = 0;
cbuffer.Format( _T("MLdonkey: %s (%1.1f%%)") , CastItoXBytes( DownDataClient ), percentClientTransferred );
stattree.SetItemText( down_scb[i] , cbuffer ); i++;
DownDataClient = thePrefs.GetDownData_SHAREAZA();
if ( DownDataTotal!=0 && DownDataClient!=0 )
percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
else
percentClientTransferred = 0;
cbuffer.Format( _T("Shareaza: %s (%1.1f%%)") , CastItoXBytes( DownDataClient ), percentClientTransferred );
stattree.SetItemText( down_scb[i] , cbuffer ); i++;
DownDataClient = thePrefs.GetDownData_EMULECOMPAT();
if ( DownDataTotal!=0 && DownDataClient!=0 )
percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
else
percentClientTransferred = 0;
cbuffer.Format( _T("eM Compat: %s (%1.1f%%)") , CastItoXBytes( DownDataClient ), percentClientTransferred );
stattree.SetItemText( down_scb[i] , cbuffer ); i++;
DownDataClient = thePrefs.GetDownData_URL();
if ( DownDataTotal!=0 && DownDataClient!=0 )
percentClientTransferred = (double) 100 * DownDataClient / DownDataTotal;
else
percentClientTransferred = 0;
cbuffer.Format( _T("URL: %s (%1.1f%%)") , CastItoXBytes( DownDataClient ), percentClientTransferred );
stattree.SetItemText( down_scb[i] , cbuffer ); i++;
}
// Downloaded Data By Port
if (forceUpdate || stattree.IsExpanded(hdown_spb)) {
int i = 0;
uint64 PortDataDefault = thePrefs.GetDownDataPort_4662();
uint64 PortDataOther = thePrefs.GetDownDataPort_OTHER();
uint64 PortDataTotal = thePrefs.GetDownSessionDataPort();
double percentPortTransferred = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -