void CFragmentBar::DrawDownload(CDC* pDC, CRect* prcBar, CDownload* pDownload, COLORREF crNatural)
{
	QWORD nvOffset, nvLength;
	BOOL bvSuccess;
		
	if ( Settings.Downloads.ShowPercent && pDownload->IsStarted() )
	{
		DrawStateBar( pDC, prcBar, pDownload->m_nSize, 0, pDownload->GetVolumeComplete(),
			RGB( 0, 255, 0 ), TRUE );
	}
		
	for ( nvOffset = 0 ; pDownload->GetNextVerifyRange( nvOffset, nvLength, bvSuccess ) ; )
	{
		DrawStateBar( pDC, prcBar, pDownload->m_nSize, nvOffset, nvLength,
			bvSuccess ? RGB( 0, 220, 0 ) : RGB( 220, 0, 0 ) );
		nvOffset += nvLength;
	}
		
	for ( FF::SimpleFragmentList::ConstIterator pFragment = pDownload->GetEmptyFragmentList().begin();
		pFragment != pDownload->GetEmptyFragmentList().end(); ++pFragment )
	{
		DrawFragment( pDC, prcBar, pDownload->m_nSize,
			pFragment->begin(), pFragment->length(), crNatural, FALSE );
	}
		
	for ( CDownloadSource* pSource = pDownload->GetFirstSource() ; pSource ; pSource = pSource->m_pNext )
	{
		DrawSourceImpl( pDC, prcBar, pSource );
	}

	pDC->FillSolidRect( prcBar, pDownload->IsStarted() ? GetSysColor( COLOR_ACTIVECAPTION ) : crNatural );
}
void CFragmentBar::DrawSource(CDC* pDC, CRect* prcBar, CDownloadSource* pSource, COLORREF crNatural)
{
	if ( pSource->m_pTransfer != NULL )
    {
        if ( pSource->m_pTransfer->m_nLength < SIZE_UNKNOWN )
	    {
		    DrawStateBar( pDC, prcBar, pSource->m_pDownload->m_nSize,
			    pSource->m_pTransfer->m_nOffset, pSource->m_pTransfer->m_nLength,
			    RGB( 255, 255, 0 ), TRUE );
	    }

        switch( pSource->m_pTransfer->m_nProtocol )
        {
        case PROTOCOL_ED2K:
            for ( FF::SimpleFragmentQueue::ConstIterator pRequested
                = static_cast< CDownloadTransferED2K* >( pSource->m_pTransfer )->m_oRequested.begin();
                pRequested
                != static_cast< CDownloadTransferED2K* >( pSource->m_pTransfer )->m_oRequested.end();
                ++pRequested )
	        {
		        DrawStateBar( pDC, prcBar, pSource->m_pDownload->m_nSize,
			        pRequested->begin(), pRequested->length(), RGB( 255, 255, 0 ), TRUE );
	        }
            break;
        case PROTOCOL_BT:
            for ( FF::SimpleFragmentQueue::ConstIterator pRequested
                = static_cast< CDownloadTransferBT* >( pSource->m_pTransfer )->m_oRequested.begin();
                pRequested
                != static_cast< CDownloadTransferBT* >( pSource->m_pTransfer )->m_oRequested.end();
                ++pRequested )
	        {
		        DrawStateBar( pDC, prcBar, pSource->m_pDownload->m_nSize,
			        pRequested->begin(), pRequested->length(), RGB( 255, 255, 0 ), TRUE );
	        }
        }
    }
	
	DrawSourceImpl( pDC, prcBar, pSource );
	
	if ( !pSource->m_oAvailable.empty() )
	{
        for ( FF::SimpleFragmentList::ConstIterator pFragment
            = pSource->m_oAvailable.begin();
            pFragment != pSource->m_oAvailable.end(); ++pFragment )
		{
			DrawFragment( pDC, prcBar, pSource->m_pDownload->m_nSize,
				pFragment->begin(), pFragment->length(), crNatural, FALSE );
		}
		
		pDC->FillSolidRect( prcBar, GetSysColor( COLOR_BTNFACE ) );
	}
	else
	{
		pDC->FillSolidRect( prcBar, crNatural );
	}
}
Beispiel #3
0
void CFragmentBar::DrawDownload(CDC* pDC, CRect* prcBar, CDownload* pDownload, COLORREF crNatural)
{
	QWORD nvOffset, nvLength;
	BOOL bvSuccess;

	if ( Settings.Downloads.ShowPercent )
	{
		DrawStateBar( pDC, prcBar, pDownload->m_nSize, 0, pDownload->GetVolumeComplete(),
			RGB( 0, 255, 0 ), true );
	}

	for ( nvOffset = 0 ; pDownload->GetNextVerifyRange( nvOffset, nvLength, bvSuccess ) ; )
	{
		DrawStateBar( pDC, prcBar, pDownload->m_nSize, nvOffset, nvLength,
			bvSuccess ? CoolInterface.m_crFragmentPass : CoolInterface.m_crFragmentFail );
		nvOffset += nvLength;
	}

	Fragments::List oList( pDownload->GetEmptyFragmentList() );
	Fragments::List::const_iterator pItr = oList.begin();
	const Fragments::List::const_iterator pEnd = oList.end();
	for ( ; pItr != pEnd ; ++pItr )
	{
		DrawFragment( pDC, prcBar, pDownload->m_nSize, pItr->begin(),
			pItr->size(), crNatural, false );
	}

	for ( POSITION posSource = pDownload->GetIterator(); posSource ; )
	{
		CDownloadSource* pSource = pDownload->GetNext( posSource );

		pSource->Draw( pDC, prcBar );
	}

	pDC->FillSolidRect( prcBar, pDownload->IsStarted() ? CoolInterface.m_crFragmentComplete : crNatural );
}