void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    if( !theApp.emuledlg->IsRunning() )
        return;
    if (!lpDrawItemStruct->itemData)
        return;
    CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC);
    BOOL bCtrlFocused = ((GetFocus() == this ) || (GetStyle() & LVS_SHOWSELALWAYS));
    if (lpDrawItemStruct->itemState & ODS_SELECTED) {
        if(bCtrlFocused)
            odc->SetBkColor(m_crHighlight);
        else
            odc->SetBkColor(m_crNoHighlight);
    }
    else
        odc->SetBkColor(GetBkColor());
    const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData;
    CMemDC dc(odc, &lpDrawItemStruct->rcItem);
    CFont* pOldFont = dc.SelectObject(GetFont());
    CRect cur_rec(lpDrawItemStruct->rcItem);
    COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText);

    int iOldBkMode;
    if (m_crWindowTextBk == CLR_NONE) {
        DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0);
        iOldBkMode = dc.SetBkMode(TRANSPARENT);
    }
    else
        iOldBkMode = OPAQUE;

    CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID());
    CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
    int iCount = pHeaderCtrl->GetItemCount();
    cur_rec.right = cur_rec.left - 8;
    cur_rec.left += 4;
    CString Sbuffer;
    for(int iCurrent = 0; iCurrent < iCount; iCurrent++) {
        int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
        if( !IsColumnHidden(iColumn) ) {
            cur_rec.right += GetColumnWidth(iColumn);
            switch(iColumn) {
            case 0: {
                uint8 image;
                if (client->IsFriend())
                    image = 4;
                else if (client->GetClientSoft() == SO_EDONKEYHYBRID) {
//==> Xman CreditSystem [shadow2004]
                    if (client->credits->GetScoreRatio(client/*->GetIP()*/) > 1)
                        image = 8;
                    else
                        image = 7;
                }
                else if (client->GetClientSoft() == SO_MLDONKEY) {
                    if (client->credits->GetScoreRatio(client/*->GetIP()*/) > 1)
                        image = 6;
                    else
                        image = 5;
                }
                else if (client->GetClientSoft() == SO_SHAREAZA) {
                    if(client->credits->GetScoreRatio(client/*->GetIP()*/) > 1)
                        image = 10;
                    else
                        image = 9;
                }
                else if (client->GetClientSoft() == SO_AMULE) {
                    if(client->credits->GetScoreRatio(client/*->GetIP()*/) > 1)
                        image = 12;
                    else
                        image = 11;
                }
                else if (client->GetClientSoft() == SO_LPHANT) {
                    if(client->credits->GetScoreRatio(client/*->GetIP()*/) > 1)
                        image = 14;
                    else
                        image = 13;
                }
                else if (client->ExtProtocolAvailable()) {
                    if(client->credits->GetScoreRatio(client/*->GetIP()*/) > 1)
//==>Modversion [shadow2004]
#ifdef MODVERSION
                        image = (client->IsNextEMF())?16:3;
#else //Modversion
                        image = 3;
#endif //Modversion
//<==Modversion [shadow2004]
                    else
//==>Modversion [shadow2004]
#ifdef MODVERSION
                        image = (client->IsNextEMF())?16:1;
#else //Modversion
                        image = 1;
#endif //Modversion
//<==Modversion [shadow2004]


                }
                else {
                    if (client->credits->GetScoreRatio(client/*->GetIP()*/) > 1)
//==> Xman CreditSystem [shadow2004]
                        image = 2;
                    else
                        image = 0;
                }

                POINT point = {cur_rec.left, cur_rec.top+1};
                imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0));
                Sbuffer = client->GetUserName();
                cur_rec.left +=20;
                dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT);
                cur_rec.left -=20;
                break;
            }
            case 1:
                if(file)
                    Sbuffer = file->GetFileName();
                else
                    Sbuffer = _T("?");
                break;
            case 2:
                if(file) {
                    switch (file->GetUpPriority()) {
                    case PR_VERYLOW : {
                        Sbuffer = GetResString(IDS_PRIOVERYLOW);
                        break;
                    }
                    case PR_LOW : {
                        if( file->IsAutoUpPriority() )
                            Sbuffer = GetResString(IDS_PRIOAUTOLOW);
                        else
                            Sbuffer = GetResString(IDS_PRIOLOW);
                        break;
                    }
                    case PR_NORMAL : {
                        if( file->IsAutoUpPriority() )
                            Sbuffer = GetResString(IDS_PRIOAUTONORMAL);
                        else
                            Sbuffer = GetResString(IDS_PRIONORMAL);
                        break;
                    }
                    case PR_HIGH : {
                        if( file->IsAutoUpPriority() )
                            Sbuffer = GetResString(IDS_PRIOAUTOHIGH);
                        else
                            Sbuffer = GetResString(IDS_PRIOHIGH);
                        break;
                    }
                    case PR_VERYHIGH : {
                        Sbuffer = GetResString(IDS_PRIORELEASE);
                        break;
                    }
                    default:
                        Sbuffer.Empty();
                    }
                }
                else
                    Sbuffer = _T("?");
                break;
            case 3:
                Sbuffer.Format(_T("%i"),client->GetScore(false,false,true));
                break;
            case 4:
                if (client->HasLowID()) {
                    if (client->m_bAddNextConnect)
                        Sbuffer.Format(_T("%i ****"),client->GetScore(false));
                    else
                        Sbuffer.Format(_T("%i LowID"),client->GetScore(false));
                }
                else
                    Sbuffer.Format(_T("%i"),client->GetScore(false));
                break;
            case 5:
                Sbuffer.Format(_T("%i"),client->GetAskedCount());
                break;
            case 6:
                Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetLastUpRequest())/1000);
                break;
            case 7:
                Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetWaitStartTime())/1000);
                break;
            case 8:
                if(client->IsBanned())
                    Sbuffer = GetResString(IDS_YES);
                else
                    Sbuffer = GetResString(IDS_NO);
                break;
            case 9:
                if( client->GetUpPartCount()) {
                    cur_rec.bottom--;
                    cur_rec.top++;
                    client->DrawUpStatusBar(dc,&cur_rec,false);
                    cur_rec.bottom++;
                    cur_rec.top--;
                }
                break;
//==>Modversion [shadow2004]
#ifdef MODVERSION
            case 10:
                Sbuffer = client->GetClientSoftVer();
                break;
#endif //Modversion
//<==Modversion [shadow2004]
            }
Exemple #2
0
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	if (!theApp.emuledlg->IsRunning())
		return;
	if (!lpDrawItemStruct->itemData)
		return;
	CDC* odc = CDC::FromHandle(lpDrawItemStruct->hDC);
	BOOL bCtrlFocused = ((GetFocus() == this) || (GetStyle() & LVS_SHOWSELALWAYS));
	if (lpDrawItemStruct->itemState & ODS_SELECTED) {
		if (bCtrlFocused)
			odc->SetBkColor(m_crHighlight);
		else
			odc->SetBkColor(m_crNoHighlight);
	}
	else
		odc->SetBkColor(GetBkColor());
	const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData;
	CMemDC dc(odc, &lpDrawItemStruct->rcItem);
	CFont* pOldFont = dc.SelectObject(GetFont());
	CRect cur_rec(lpDrawItemStruct->rcItem);
	COLORREF crOldTextColor = dc.SetTextColor((lpDrawItemStruct->itemState & ODS_SELECTED) ? m_crHighlightText : m_crWindowText);

	int iOldBkMode;
	if (m_crWindowTextBk == CLR_NONE){
		DefWindowProc(WM_ERASEBKGND, (WPARAM)(HDC)dc, 0);
		iOldBkMode = dc.SetBkMode(TRANSPARENT);
	}
	else
		iOldBkMode = OPAQUE;

	CKnownFile* file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID());
	CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
	int iCount = pHeaderCtrl->GetItemCount();
	cur_rec.right = cur_rec.left - 8;
	cur_rec.left += 4;
	CString Sbuffer;
	for(int iCurrent = 0; iCurrent < iCount; iCurrent++){
		int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
		if( !IsColumnHidden(iColumn) ){
			cur_rec.right += GetColumnWidth(iColumn);
			switch(iColumn){
				case 0:{
					uint8 image;
					if (client->IsFriend())
						image = 4;
					else if (client->GetClientSoft() == SO_EDONKEYHYBRID){
						if (client->credits->GetScoreRatio(client->GetIP()) > 1)
							image = 8;
						else
							image = 7;
					}
					else if (client->GetClientSoft() == SO_MLDONKEY){
						if (client->credits->GetScoreRatio(client->GetIP()) > 1)
							image = 6;
						else
							image = 5;
					}
					else if (client->GetClientSoft() == SO_SHAREAZA){
						if(client->credits->GetScoreRatio(client->GetIP()) > 1)
							image = 10;
						else
							image = 9;
					}
					else if (client->GetClientSoft() == SO_AMULE){
						if(client->credits->GetScoreRatio(client->GetIP()) > 1)
							image = 12;
						else
							image = 11;
					}
					else if (client->GetClientSoft() == SO_LPHANT){
						if(client->credits->GetScoreRatio(client->GetIP()) > 1)
							image = 14;
						else
							image = 13;
					}
					else if (client->ExtProtocolAvailable()){
						if(client->credits->GetScoreRatio(client->GetIP()) > 1)
							image = 3;
						else
							image = 1;
					}
					else{
						if (client->credits->GetScoreRatio(client->GetIP()) > 1)
							image = 2;
						else
							image = 0;
					}
					uint32 nOverlayImage = 0;
					if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED))
						nOverlayImage |= 1;
					if (client->IsObfuscatedConnectionEstablished())
						nOverlayImage |= 2;
					int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1;
					POINT point = {cur_rec.left, cur_rec.top + iIconPosY};
					imagelist.Draw(dc,image, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage));
					
					Sbuffer = client->GetUserName();
					cur_rec.left += 20;
					dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT);
					cur_rec.left -= 20;
					break;
				}
				case 1:
					if(file)
						Sbuffer = file->GetFileName();
					else
						Sbuffer = _T("?");
					break;
				case 2:
					if(file){
						switch (file->GetUpPriority()) {
							case PR_VERYLOW : {
								Sbuffer = GetResString(IDS_PRIOVERYLOW);
								break; }
							case PR_LOW : {
								if( file->IsAutoUpPriority() )
									Sbuffer = GetResString(IDS_PRIOAUTOLOW);
								else
									Sbuffer = GetResString(IDS_PRIOLOW);
								break; }
							case PR_NORMAL : {
								if( file->IsAutoUpPriority() )
									Sbuffer = GetResString(IDS_PRIOAUTONORMAL);
								else
									Sbuffer = GetResString(IDS_PRIONORMAL);
								break; }
							case PR_HIGH : {
								if( file->IsAutoUpPriority() )
									Sbuffer = GetResString(IDS_PRIOAUTOHIGH);
								else
									Sbuffer = GetResString(IDS_PRIOHIGH);
								break; }
							case PR_VERYHIGH : {
								Sbuffer = GetResString(IDS_PRIORELEASE);
								break; }
							default:
								Sbuffer.Empty();
						}
					}
					else
						Sbuffer = _T("?");
					break;
				case 3:
					Sbuffer.Format(_T("%i"),client->GetScore(false,false,true));
					break;
				case 4:
					if (client->HasLowID()){
						if (client->m_bAddNextConnect)
							Sbuffer.Format(_T("%i ****"),client->GetScore(false));
						else
							Sbuffer.Format(_T("%i (%s)"),client->GetScore(false), GetResString(IDS_IDLOW));
					}
					else
						Sbuffer.Format(_T("%i"),client->GetScore(false));
					break;
				case 5:
					Sbuffer.Format(_T("%i"),client->GetAskedCount());
					break;
				case 6:
					Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetLastUpRequest())/1000);
					break;
				case 7:
					Sbuffer = CastSecondsToHM((::GetTickCount() - client->GetWaitStartTime())/1000);
					break;
				case 8:
					if(client->IsBanned())
						Sbuffer = GetResString(IDS_YES);
					else
						Sbuffer = GetResString(IDS_NO);
					break;
				case 9:
					if( client->GetUpPartCount()){
						cur_rec.bottom--;
						cur_rec.top++;
						client->DrawUpStatusBar(dc,&cur_rec,false,thePrefs.UseFlatBar());
						cur_rec.bottom++;
						cur_rec.top--;
					}
					break;
		   	}
			if( iColumn != 9 && iColumn != 0)
				dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT);
			cur_rec.left += GetColumnWidth(iColumn);
		}
	}

	// draw rectangle around selected item(s)
	if (lpDrawItemStruct->itemState & ODS_SELECTED)
	{
		RECT outline_rec = lpDrawItemStruct->rcItem;

		outline_rec.top--;
		outline_rec.bottom++;
		dc.FrameRect(&outline_rec, &CBrush(GetBkColor()));
		outline_rec.top++;
		outline_rec.bottom--;
		outline_rec.left++;
		outline_rec.right--;

		if(bCtrlFocused)
			dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine));
		else
			dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine));
	}
	
	if (m_crWindowTextBk == CLR_NONE)
		dc.SetBkMode(iOldBkMode);
	dc.SelectObject(pOldFont);
	dc.SetTextColor(crOldTextColor);
}
void CSharedFilesCtrl::OnRightClick(wxListEvent& event)
{
	long item_hit = CheckSelection(event);

	if ( (m_menu == NULL) && (item_hit != -1)) {
		m_menu = new wxMenu(_("Shared Files"));
		wxMenu* prioMenu = new wxMenu();
		prioMenu->AppendCheckItem(MP_PRIOVERYLOW, _("Very low"));
		prioMenu->AppendCheckItem(MP_PRIOLOW, _("Low"));
		prioMenu->AppendCheckItem(MP_PRIONORMAL, _("Normal"));
		prioMenu->AppendCheckItem(MP_PRIOHIGH, _("High"));
		prioMenu->AppendCheckItem(MP_PRIOVERYHIGH, _("Very High"));
		prioMenu->AppendCheckItem(MP_POWERSHARE, _("Release"));
		prioMenu->AppendCheckItem(MP_PRIOAUTO, _("Auto"));

		m_menu->Append(0,_("Priority"),prioMenu);
		m_menu->AppendSeparator();

		CKnownFile* file = (CKnownFile*)GetItemData(item_hit);
		if (file->GetFileComment().IsEmpty() && !file->GetFileRating()) {
			m_menu->Append(MP_CMT, _("Add Comment/Rating"));
		} else {
			m_menu->Append(MP_CMT, _("Edit Comment/Rating"));
		}
		
		m_menu->AppendSeparator();
		m_menu->Append(MP_RENAME, _("Rename"));
		m_menu->AppendSeparator();

		if (file->GetFileName().GetExt() == wxT("emulecollection")) {
			m_menu->Append( MP_ADDCOLLECTION, _("Add files in collection to transfer list"));
			m_menu->AppendSeparator();
		}
		m_menu->Append(MP_GETMAGNETLINK,_("Copy magnet &URI to clipboard"));
		m_menu->Append(MP_GETED2KLINK,_("Copy eD2k &link to clipboard"));
		m_menu->Append(MP_GETSOURCEED2KLINK,_("Copy eD2k link to clipboard (&Source)"));
		m_menu->Append(MP_GETCRYPTSOURCEDED2KLINK,_("Copy eD2k link to clipboard (Source) (&With Crypt options)"));
		m_menu->Append(MP_GETHOSTNAMESOURCEED2KLINK,_("Copy eD2k link to clipboard (&Hostname)"));
		m_menu->Append(MP_GETHOSTNAMECRYPTSOURCEED2KLINK,_("Copy eD2k link to clipboard (Hostname) (With &Crypt options)"));		
		m_menu->Append(MP_GETAICHED2KLINK,_("Copy eD2k link to clipboard (&AICH info)"));
		m_menu->Append(MP_WS,_("Copy feedback to clipboard"));
		
		m_menu->Enable(MP_GETAICHED2KLINK, file->HasProperAICHHashSet());
		m_menu->Enable(MP_GETHOSTNAMESOURCEED2KLINK, !thePrefs::GetYourHostname().IsEmpty());
		m_menu->Enable(MP_GETHOSTNAMECRYPTSOURCEED2KLINK, !thePrefs::GetYourHostname().IsEmpty());

		int priority = file->IsAutoUpPriority() ? PR_AUTO : file->GetUpPriority();

		prioMenu->Check(MP_PRIOVERYLOW,	priority == PR_VERYLOW);
		prioMenu->Check(MP_PRIOLOW,	priority == PR_LOW);
		prioMenu->Check(MP_PRIONORMAL,	priority == PR_NORMAL);
		prioMenu->Check(MP_PRIOHIGH,	priority == PR_HIGH);
		prioMenu->Check(MP_PRIOVERYHIGH,priority == PR_VERYHIGH);
		prioMenu->Check(MP_POWERSHARE,	priority == PR_POWERSHARE);
		prioMenu->Check(MP_PRIOAUTO,	priority == PR_AUTO);

		PopupMenu( m_menu, event.GetPoint() );

		delete m_menu;

		m_menu = NULL;
	}
}
void CSharedFilesCtrl::OnDrawItem( int item, wxDC* dc, const wxRect& rect, const wxRect& rectHL, bool highlighted )
{
	CKnownFile *file = (CKnownFile*)GetItemData(item);
	wxASSERT( file );

	if ( highlighted ) {
		CMuleColour newcol(GetFocus() ? wxSYS_COLOUR_HIGHLIGHT : wxSYS_COLOUR_BTNSHADOW);	
		dc->SetBackground(newcol.Blend(125).GetBrush());
		dc->SetTextForeground( CMuleColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
		// The second blending goes over the first one.
		dc->SetPen(newcol.Blend(65).GetPen());
	} else {
		dc->SetBackground( CMuleColour(wxSYS_COLOUR_LISTBOX).GetBrush() );
		dc->SetTextForeground(CMuleColour(wxSYS_COLOUR_WINDOWTEXT));
		dc->SetPen(*wxTRANSPARENT_PEN);
	}
	
	dc->SetBrush(dc->GetBackground());
	dc->DrawRectangle(rectHL);
	dc->SetPen(*wxTRANSPARENT_PEN);

	// Offset based on the height of the fonts
	const int textVOffset = ( rect.GetHeight() - dc->GetCharHeight() ) / 2;
	// Empty space to each side of a column
	const int SPARE_PIXELS_HORZ	= 4;

	// The leftmost position of the current column
	int columnLeft = 0;
	
	for ( int i = 0; i < GetColumnCount(); ++i ) {
		const int columnWidth = GetColumnWidth(i);

		if (columnWidth > 2*SPARE_PIXELS_HORZ) {
			wxRect columnRect(
				columnLeft + SPARE_PIXELS_HORZ, rect.y,
				columnWidth - 2 * SPARE_PIXELS_HORZ, rect.height);
			
			wxDCClipper clipper(*dc, columnRect);
			
			wxString textBuffer;
			switch ( i ) {
				case ID_SHARED_COL_NAME:
					textBuffer = file->GetFileName().GetPrintable();

					if (file->GetFileRating() || file->GetFileComment().Length()) {
						int image = Client_CommentOnly_Smiley;
						if (file->GetFileRating()) {
							image = Client_InvalidRating_Smiley + file->GetFileRating() - 1;
						}	
							
						wxASSERT(image >= Client_InvalidRating_Smiley);
						wxASSERT(image <= Client_CommentOnly_Smiley);

						int imgWidth = 16;
						
						theApp->amuledlg->m_imagelist.Draw(image, *dc, columnRect.x,
								columnRect.y + 1, wxIMAGELIST_DRAW_TRANSPARENT);

						// Move the text to the right
						columnRect.x += (imgWidth + 4);
					}

					break;
				
				case ID_SHARED_COL_SIZE:
					textBuffer = CastItoXBytes(file->GetFileSize());
					break;

				case ID_SHARED_COL_TYPE:
					textBuffer = GetFiletypeByName(file->GetFileName());
					break;

				case ID_SHARED_COL_PRIO:
					textBuffer = PriorityToStr(file->GetUpPriority(), file->IsAutoUpPriority());
					break;

				case ID_SHARED_COL_ID:
					textBuffer = file->GetFileHash().Encode();
					break;
				
				case ID_SHARED_COL_REQ:
					textBuffer = CFormat(wxT("%u (%u)"))
							% file->statistic.GetRequests()
							% file->statistic.GetAllTimeRequests();
					break;

				case ID_SHARED_COL_AREQ:
					textBuffer = CFormat(wxT("%u (%u)"))
							% file->statistic.GetAccepts()
							% file->statistic.GetAllTimeAccepts();
					break;

				case ID_SHARED_COL_TRA:
					textBuffer = CastItoXBytes(file->statistic.GetTransferred())
						+ wxT(" (") + CastItoXBytes(file->statistic.GetAllTimeTransferred()) + wxT(")");
					break;
					
				case ID_SHARED_COL_RTIO:
					textBuffer = CFormat(wxT("%.2f")) %	((double)file->statistic.GetAllTimeTransferred() / file->GetFileSize());
					break;
				
				case ID_SHARED_COL_PART:
					if ( file->GetPartCount() ) {
						wxRect barRect(columnRect.x, columnRect. y + 1, 
							columnRect.width, columnRect.height - 2);
						
						DrawAvailabilityBar(file, dc, barRect);
					}
					break;
				
				case ID_SHARED_COL_CMPL:
					if ( file->m_nCompleteSourcesCountLo == 0 ) {
						if ( file->m_nCompleteSourcesCountHi ) {
							textBuffer = CFormat(wxT("< %u")) % file->m_nCompleteSourcesCountHi;
						} else {
							textBuffer = wxT("0");
						}
					} else if (file->m_nCompleteSourcesCountLo == file->m_nCompleteSourcesCountHi) {
						textBuffer = CFormat(wxT("%u")) % file->m_nCompleteSourcesCountLo;
					} else {
						textBuffer = CFormat(wxT("%u - %u")) % file->m_nCompleteSourcesCountLo % file->m_nCompleteSourcesCountHi;
					}
					
					break;				
				
				case ID_SHARED_COL_PATH:
					if ( file->IsPartFile() ) {
						textBuffer = _("[PartFile]");
					} else {
						textBuffer = file->GetFilePath().GetPrintable();
					}
			}

			if (!textBuffer.IsEmpty()) {
				dc->DrawText(textBuffer, columnRect.x, columnRect.y + textVOffset);
			}
		}

		// Move to the next column
		columnLeft += columnWidth;
	}
}
void CUploadListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    if (!theApp.emuledlg->IsRunning())
        return;
    if (!lpDrawItemStruct->itemData)
        return;

    CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem);
    BOOL bCtrlFocused;
    InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused);
    CRect cur_rec(lpDrawItemStruct->rcItem);
    CRect rcClient;
    GetClientRect(&rcClient);

    const CUpDownClient* client = (CUpDownClient*)lpDrawItemStruct->itemData;

    COLORREF crOldBackColor = dc->GetBkColor(); //Xman PowerRelease

    CKnownFile* file = CGlobalVariable::sharedfiles->GetFileByID(client->GetUploadFileID());
    CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
    int iCount = pHeaderCtrl->GetItemCount();
    cur_rec.right = cur_rec.left - 8;
    cur_rec.left += 4;
    CString Sbuffer;
    for (int iCurrent = 0; iCurrent < iCount; iCurrent++)
    {
        int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
        if (!IsColumnHidden(iColumn))
        {
            cur_rec.right += GetColumnWidth(iColumn);
            switch (iColumn)
            {
            case 0: {
                uint8 image;
                if (client->IsFriend())
                    image = 4;
                else if (client->GetClientSoft() == SO_EDONKEYHYBRID) {
                    if (client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1)
                        image = 8;
                    else
                        image = 7;
                }
                else if (client->GetClientSoft() == SO_MLDONKEY) {
                    if (client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1)
                        image = 6;
                    else
                        image = 5;
                }
                else if (client->GetClientSoft() == SO_SHAREAZA) {
                    if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1)
                        image = 10;
                    else
                        image = 9;
                }
                else if (client->GetClientSoft() == SO_AMULE) {
                    if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1)
                        image = 12;
                    else
                        image = 11;
                }
                else if (client->GetClientSoft() == SO_LPHANT) {
                    if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1)
                        image = 14;
                    else
                        image = 13;
                }
                else if (client->ExtProtocolAvailable()) {
                    if(client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1)
                        image = 3;
                    else
                        image = 1;
                }
                else {
                    if (client->credits && client->credits->GetScoreRatio(client->GetIP()) > 1)
                        image = 2;
                    else
                        image = 0;
                }

                uint32 nOverlayImage = 0;
                if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED))
                    nOverlayImage |= 1;
                if (client->IsObfuscatedConnectionEstablished())
                    nOverlayImage |= 2;
                POINT point = {cur_rec.left, cur_rec.top+1};
                imagelist.Draw(dc,image, point, ILD_NORMAL | ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED) ? INDEXTOOVERLAYMASK(1) : 0));
                Sbuffer = client->GetUserName();

                //EastShare Start - added by AndCycle, IP to Country
                CString tempStr;
                tempStr.Format(_T("%s%s"), client->GetCountryName(), Sbuffer);
                Sbuffer = tempStr;

                if(CGlobalVariable::ip2country->ShowCountryFlag()) {
                    cur_rec.left += 20;
                    POINT point2= {cur_rec.left,cur_rec.top+1};
                    CGlobalVariable::ip2country->GetFlagImageList()->DrawIndirect(dc, client->GetCountryFlagIndex(), point2, CSize(18,16), CPoint(0,0), ILD_NORMAL);
                }
                //EastShare End - added by AndCycle, IP to Country

                cur_rec.left += 20;
                dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT);
                cur_rec.left -= 20;

                //EastShare Start - added by AndCycle, IP to Country
                if(CGlobalVariable::ip2country->ShowCountryFlag()) {
                    cur_rec.left-=20;
                }
                //EastShare End - added by AndCycle, IP to Country

                break;
            }
            case 1:
                if (file)
                    Sbuffer = file->GetFileName();
                else
                    Sbuffer = _T("?");
                if(file && file->GetUpPriority()==PR_POWER) ///PowerRelease
                    dc->SetBkColor(RGB(255,225,225));
                break;
            case 2:
                Sbuffer = CastItoXBytes(client->GetDatarate(), false, true);
                break;
            case 3:
                // NOTE: If you change (add/remove) anything which is displayed here, update also the sorting part..
                if (thePrefs.m_bExtControls)
                    Sbuffer.Format( _T("%s (%s)"), CastItoXBytes(client->GetSessionUp(), false, false), CastItoXBytes(client->GetQueueSessionPayloadUp(), false, false));
                else
                    Sbuffer = CastItoXBytes(client->GetSessionUp(), false, false);
                break;
            case 4:
                if (client->HasLowID())
                    Sbuffer.Format(_T("%s (%s)"), CastSecondsToHM(client->GetWaitTime()/1000), GetResString(IDS_IDLOW));
                else
                    Sbuffer = CastSecondsToHM(client->GetWaitTime()/1000);
                break;
            case 5:
                Sbuffer = CastSecondsToHM(client->GetUpStartTimeDelay()/1000);
                break;
            case 6:
                Sbuffer = client->GetUploadStateDisplayString();
                break;
            case 7:
                cur_rec.bottom--;
                cur_rec.top++;
                client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar());
                cur_rec.bottom++;
                cur_rec.top--;
                break;
            }
            if (iColumn != 7 && iColumn != 0)
                dc.DrawText(Sbuffer, Sbuffer.GetLength(), &cur_rec, DLC_DT_TEXT);
            dc->SetBkColor( crOldBackColor );
            cur_rec.left += GetColumnWidth(iColumn);
        }
    }

    //draw rectangle around selected item(s)
    if (lpDrawItemStruct->itemState & ODS_SELECTED)
    {
        RECT outline_rec = lpDrawItemStruct->rcItem;

        outline_rec.top--;
        outline_rec.bottom++;
        dc.FrameRect(&outline_rec, &CBrush(GetBkColor()));
        outline_rec.top++;
        outline_rec.bottom--;
        outline_rec.left++;
        outline_rec.right--;

        if (bCtrlFocused)
            dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine));
        else
            dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine));
    }

    /*
    	if (m_crWindowTextBk == CLR_NONE)
    		dc.SetBkMode(iOldBkMode);
    	dc.SelectObject(pOldFont);
    	dc.SetTextColor(crOldTextColor);*/
}