BOOL CDownloadReviewDlg::OnInitDialog() { CSkinDialog::OnInitDialog(); CRect rcList; m_wndReviews.GetClientRect( &rcList ); rcList.right -= GetSystemMetrics( SM_CXVSCROLL ); CoolInterface.SetImageListTo( m_wndReviews, LVSIL_SMALL ); m_wndReviews.InsertColumn( 0, _T("User"), LVCFMT_LEFT, 100, -1 ); m_wndReviews.InsertColumn( 1, _T("Rating"), LVCFMT_CENTER, 90, 0 ); m_wndReviews.InsertColumn( 2, _T("Comments"), LVCFMT_CENTER, rcList.right- 100 - 80, 1 ); m_wndReviews.InsertColumn( 3, _T("Order"), LVCFMT_CENTER, 0, 2 ); Skin.Translate( _T("CReviewList"), m_wndReviews.GetHeaderCtrl() ); m_wndReviews.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP, LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP ); m_wndReviews.EnableToolTips(); // Sort by order added- first at the top CLiveList::Sort( &m_wndReviews, 3, FALSE ); CLiveList::Sort( &m_wndReviews, 3, FALSE ); CLiveList pReviews( 4 ); int nIndex = 1; // Lock while we're loading the list. (In case the download is destroyed) CSingleLock pLock( &Transfers.m_pSection, TRUE ); if ( ! m_pDownload ) return FALSE; m_sReviewFileName = m_pDownload->m_sName; CDownloadReview* pReview = m_pDownload->GetFirstReview(); while ( pReview ) { CLiveItem* pItem = pReviews.Add( pReview ); // Client picture // Note: We don't have pictures yet. Currently, it uses a star for a G2 // review, and a little person for everyone else switch ( pReview->m_nUserPicture ) { case 0: pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_WIZARD ) ); break; case 1: pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) ); break; case 2: pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_WIZARD ) ); break; case 3: pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) ); break; default: pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) ); } pItem->Set( 0, pReview->m_sUserName ); int nRating = min( pReview->m_nFileRating, 6 ); nRating = max ( nRating, 0 ); CString strRating; LoadString( strRating, IDS_RATING_NORATING + nRating ); pItem->Set( 1, strRating ); pItem->Set( 2, pReview->m_sFileComments ); pItem->Format( 3, _T("%i"), nIndex ); nIndex++; pReview = pReview->m_pNext; } pLock.Unlock(); //m_wndReviews.SetFont( &theApp.m_gdiFontBold ); pReviews.Apply( &m_wndReviews, TRUE ); // Set window icon SkinMe( NULL, IDR_MEDIAFRAME ); UpdateData( FALSE ); return TRUE; }
void CHostCacheWnd::Update(BOOL bForce) { if ( !bForce ) if ( !m_bAllowUpdates ) return; CSingleLock pLock( &Network.m_pSection ); if ( ! pLock.Lock( 50 ) ) return; m_wndList.ModifyStyle( WS_VISIBLE, 0 ); CLiveList pLiveList( 8 ); PROTOCOLID nEffective = m_nMode ? m_nMode : PROTOCOL_G2; CHostCacheList* pCache = HostCache.ForProtocol( nEffective ); m_nCookie = pCache->m_nCookie; int nProtocolRev = m_gdiImageList.GetImageCount() - 1; for ( CHostCacheHost* pHost = pCache->GetNewest() ; pHost ; pHost = pHost->m_pPrevTime ) { // cancel update if mouse moves ouside window or user right-clicks // do not break if different cache window button pressed if ( !m_bAllowUpdates && !bForce ) break; if ( m_nMode == PROTOCOL_NULL ) { if ( HubHorizonPool.Find( &pHost->m_pAddress ) == NULL ) continue; } CLiveItem* pItem = pLiveList.Add( pHost ); pItem->m_nImage = theApp.m_bRTL ? nProtocolRev - pHost->m_nProtocol : pHost->m_nProtocol; pItem->m_nMaskOverlay = pHost->m_bPriority; pItem->Set( 0, CString( inet_ntoa( pHost->m_pAddress ) ) ); pItem->Format( 1, _T("%hu"), pHost->m_nPort ); #ifdef _DEBUG pItem->Format( 2, _T("K:%u A:%u Q:%u"), pHost->m_nKeyValue, pHost->m_tAck, pHost->m_tQuery ); #else if ( pHost->m_pVendor ) pItem->Set( 2, pHost->m_pVendor->m_sName ); else if ( pHost->m_nProtocol == PROTOCOL_G2 ) pItem->Set( 2, _T("(Gnutella2)") ); else if ( pHost->m_nProtocol == PROTOCOL_ED2K ) pItem->Set( 2, _T("(eDonkey Server)") ); #endif CTime pTime( (time_t)pHost->m_tSeen ); pItem->Set( 3, pTime.Format( _T("%Y-%m-%d %H:%M:%S") ) ); pItem->Set( 4, pHost->m_sName ); pItem->Set( 5, pHost->m_sDescription ); if ( pHost->m_nUserCount ) pItem->Format( 6, _T("%u"), pHost->m_nUserCount ); if ( pHost->m_nUserLimit ) pItem->Format( 7, _T("%u"), pHost->m_nUserLimit ); } if ( !m_bAllowUpdates && !bForce ) return; pLiveList.Apply( &m_wndList, TRUE ); m_wndList.ShowWindow( SW_SHOW ); tLastUpdate = GetTickCount(); // Update timer }