void CDownloadClientsCtrl::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;

	CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
	int iCount = pHeaderCtrl->GetItemCount();
	cur_rec.right = cur_rec.left - sm_iLabelOffset;
	cur_rec.left += sm_iIconOffset;
	for (int iCurrent = 0; iCurrent < iCount; iCurrent++)
	{
		int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
		if (!IsColumnHidden(iColumn))
		{
			UINT uDrawTextAlignment;
			int iColumnWidth = GetColumnWidth(iColumn, uDrawTextAlignment);
			cur_rec.right += iColumnWidth;
			if (cur_rec.left < cur_rec.right && HaveIntersection(rcClient, cur_rec))
			{
				TCHAR szItem[1024];
				GetItemDisplayText(client, iColumn, szItem, _countof(szItem));
				switch (iColumn)
				{
					case 0:{
						int iImage;
						if (client->credits != NULL)
						{
							if (client->IsFriend())
								iImage = 4;
							else if (client->GetClientSoft() == SO_EDONKEYHYBRID) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 8;
								else
									iImage = 7;
							}
							else if (client->GetClientSoft() == SO_MLDONKEY) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 6;
								else
									iImage = 5;
							}
							else if (client->GetClientSoft() == SO_SHAREAZA) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 10;
								else
									iImage = 9;
							}
							else if (client->GetClientSoft() == SO_AMULE) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 12;
								else
									iImage = 11;
							}
							else if (client->GetClientSoft() == SO_LPHANT) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 14;
								else
									iImage = 13;
							}
							else if (client->ExtProtocolAvailable()) {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 3;
								else
									iImage = 1;
							}
							else {
								if (client->credits->GetScoreRatio(client->GetIP()) > 1)
									iImage = 2;
								else
									iImage = 0;
							}
						}
						else
							iImage = 0;

						UINT 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 };
						m_ImageList.Draw(dc, iImage, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage));

						cur_rec.left += 16 + sm_iLabelOffset;
						dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
						cur_rec.left -= 16;
						cur_rec.right -= sm_iSubItemInset;
						break;
					}

					case 4:
						cur_rec.bottom--;
						cur_rec.top++;
						client->DrawStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar());
						cur_rec.bottom++;
						cur_rec.top--;
						break;

					default:
						dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
						break;
				}
			}
			cur_rec.left += iColumnWidth;
		}
	}

	DrawFocusRect(dc, lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState & ODS_FOCUS, bCtrlFocused, lpDrawItemStruct->itemState & ODS_SELECTED);
}
void CQueueListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	if (!theApp.emuledlg->IsRunning())
		return;
	if (!lpDrawItemStruct->itemData)
		return;

	// ==> Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle
	/*
	CMemDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem);
	*/
	CMemoryDC dc(CDC::FromHandle(lpDrawItemStruct->hDC), &lpDrawItemStruct->rcItem);
	// <== Visual Studio 2010 Compatibility [Stulle/Avi-3k/ied] - Stulle
	BOOL bCtrlFocused;
	//Xman narrow font at transferwindow
	/*
	InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused);
	*/
	// ==> Design Settings [eWombat/Stulle] - Stulle
	/*
	InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true);
	//Xman end
	*/
	InitItemMemDC(dc, lpDrawItemStruct, bCtrlFocused, true, style_b_queuelist);
	// <== Design Settings [eWombat/Stulle] - Stulle
	CRect cur_rec(lpDrawItemStruct->rcItem);
	CRect rcClient;
	GetClientRect(&rcClient);
	const CUpDownClient *client = (CUpDownClient *)lpDrawItemStruct->itemData;

	// ==> Design Settings [eWombat/Stulle] - Stulle
	/*
	COLORREF crOldBackColor = dc->GetBkColor(); //Xman PowerRelease //Xman show LowIDs
	*/
	// <== Design Settings [eWombat/Stulle] - Stulle
	CHeaderCtrl *pHeaderCtrl = GetHeaderCtrl();
	int iCount = pHeaderCtrl->GetItemCount();
	cur_rec.right = cur_rec.left - sm_iLabelOffset;
	cur_rec.left += sm_iIconOffset;
	for (int iCurrent = 0; iCurrent < iCount; iCurrent++)
	{
		int iColumn = pHeaderCtrl->OrderToIndex(iCurrent);
		if (!IsColumnHidden(iColumn))
		{
			UINT uDrawTextAlignment;
			int iColumnWidth = GetColumnWidth(iColumn, uDrawTextAlignment);
			cur_rec.right += iColumnWidth;
			if (cur_rec.left < cur_rec.right && HaveIntersection(rcClient, cur_rec))
			{
				TCHAR szItem[1024];
				GetItemDisplayText(client, iColumn, szItem, _countof(szItem));
				switch (iColumn)
				{
					case 0:{
						int iImage;
						//Xman Show correct Icons
						/*
						if (client->IsFriend())
							iImage = 4;
						else if (client->GetClientSoft() == SO_EDONKEYHYBRID) {
							if (client->credits->GetScoreRatio(client->GetIP()) > 1)
								iImage = 8;
							else
								iImage = 7;
						}
						else if (client->GetClientSoft() == SO_MLDONKEY) {
							if (client->credits->GetScoreRatio(client->GetIP()) > 1)
								iImage = 6;
							else
								iImage = 5;
						}
						else if (client->GetClientSoft() == SO_SHAREAZA) {
							if (client->credits->GetScoreRatio(client->GetIP()) > 1)
								iImage = 10;
							else
								iImage = 9;
						}
						else if (client->GetClientSoft() == SO_AMULE) {
							if (client->credits->GetScoreRatio(client->GetIP()) > 1)
								iImage = 12;
							else
								iImage = 11;
						}
						else if (client->GetClientSoft() == SO_LPHANT) {
							if (client->credits->GetScoreRatio(client->GetIP()) > 1)
								iImage = 14;
							else
								iImage = 13;
						}
						else if (client->ExtProtocolAvailable()) {
							if (client->credits->GetScoreRatio(client->GetIP()) > 1)
								iImage = 3;
							else
								iImage = 1;
						}
						else {
							if (client->credits->GetScoreRatio(client->GetIP()) > 1)
								iImage = 2;
							else
								iImage = 0;
						}
						*/
						if (client->IsFriend())
							iImage = 6;
						else if (client->GetClientSoft() == SO_EDONKEYHYBRID){
							iImage = 10;
						}
						else if (client->GetClientSoft() == SO_EDONKEY){
							iImage = 2;
						}
						else if (client->GetClientSoft() == SO_MLDONKEY){
							iImage = 8;
						}
						else if (client->GetClientSoft() == SO_SHAREAZA){
							iImage = 12;
						}
						else if (client->GetClientSoft() == SO_AMULE){
							iImage = 14;
						}
						else if (client->GetClientSoft() == SO_LPHANT){
							iImage = 16;
						}
						else if (client->ExtProtocolAvailable()){
							// ==> Mod Icons - Stulle
							/*
							iImage = 4;
							*/
							if(client->GetModClient() == MOD_NONE)
								iImage = 4;
							else
								iImage = (uint8)(client->GetModClient() + 19);
							// <== Mod Icons - Stulle
						}
						else{
							iImage = 0;
						}
						//Xman Anti-Leecher
						if(client->IsLeecher()>0)
							iImage=18;
						else
						//Xman end
						if (((client->credits)?client->credits->GetScoreRatio(client):0) > 1)
							// ==> Mod Icons - Stulle
							// ==> CreditSystems [EastShare/ MorphXT] - Stulle
							/*
							iImage++;
							*/
							if (client->GetModClient() == MOD_NONE){
								if(client->credits && client->credits->GetHasScore(client))
									iImage++;
							}
							// <== CreditSystems [EastShare/ MorphXT] - Stulle
							// <== Mod Icons - Stulle
						//Xman end

						UINT nOverlayImage = 0;
						if ((client->Credits() && client->Credits()->GetCurrentIdentState(client->GetIP()) == IS_IDENTIFIED))
							nOverlayImage |= 1;
						//Xman changed: display the obfuscation icon for all clients which enabled it
						/*
						if (client->IsObfuscatedConnectionEstablished())
						*/
						if(client->IsObfuscatedConnectionEstablished() 
							|| (!(client->socket != NULL && client->socket->IsConnected())
							&& (client->SupportsCryptLayer() && thePrefs.IsClientCryptLayerSupported() && (client->RequestsCryptLayer() || thePrefs.IsClientCryptLayerRequested()))))
							nOverlayImage |= 2;
						int iIconPosY = (cur_rec.Height() > 16) ? ((cur_rec.Height() - 16) / 2) : 1;
						POINT point = { cur_rec.left, cur_rec.top + iIconPosY };
						m_ImageList.Draw(dc, iImage, point, ILD_NORMAL | INDEXTOOVERLAYMASK(nOverlayImage));

						// ==> Mod Icons - Stulle
						if(client->Credits() && client->credits->GetHasScore(client) && client->GetModClient() != MOD_NONE)
						{
							if (nOverlayImage & 1)
								m_overlayimages.Draw(dc,1, point, ILD_TRANSPARENT);
							else
								m_overlayimages.Draw(dc,0, point, ILD_TRANSPARENT);
						}
						// <== Mod Icons - Stulle

						//Xman friend visualization
						if (client->IsFriend() && client->GetFriendSlot())
							m_ImageList.Draw(dc,19, point, ILD_NORMAL);
						//Xman end

						//EastShare Start - added by AndCycle, IP to Country 
						if(theApp.ip2country->ShowCountryFlag() )
						{
							cur_rec.left+=20;
							POINT point2= {cur_rec.left,cur_rec.top+1};
							//theApp.ip2country->GetFlagImageList()->Draw(dc, client->GetCountryFlagIndex(), point2, ILD_NORMAL);
							theApp.ip2country->GetFlagImageList()->DrawIndirect(&theApp.ip2country->GetFlagImageDrawParams(dc,client->GetCountryFlagIndex(),point2));
							cur_rec.left += sm_iLabelOffset;
						}
						//EastShare End - added by AndCycle, IP to Country

						cur_rec.left += 16 + sm_iLabelOffset;
						dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
						cur_rec.left -= 16;
						cur_rec.right -= sm_iSubItemInset;

						//EastShare Start - added by AndCycle, IP to Country
						if(theApp.ip2country->ShowCountryFlag() )
						{
							cur_rec.left-=20;
						}
						//EastShare End - added by AndCycle, IP to Country
						break;
					}
					case 9:
						if (client->GetUpPartCount()) {
							cur_rec.bottom--;
							cur_rec.top++;
							COLORREF crOldBackColor = dc->GetBkColor(); //Xman Code Improvement: FillSolidRect
							client->DrawUpStatusBar(dc, &cur_rec, false, thePrefs.UseFlatBar());
							dc.SetBkColor(crOldBackColor); //Xman Code Improvement: FillSolidRect
							//Xman client percentage (font idea by morph)
							CString buffer;
							// ==> Show Client Percentage optional [Stulle] - Stulle
							/*
							if (thePrefs.GetUseDwlPercentage())
							*/
							if (thePrefs.GetShowClientPercentage())
							// <== Show Client Percentage optional [Stulle] - Stulle
							{
								if(client->GetHisCompletedPartsPercent_UP() >=0)
								{
									COLORREF oldclr = dc.SetTextColor(RGB(0,0,0));
									int iOMode = dc.SetBkMode(TRANSPARENT);
									buffer.Format(_T("%i%%"), client->GetHisCompletedPartsPercent_UP());
									CFont *pOldFont = dc.SelectObject(&m_fontBoldSmaller);
#define	DrawClientPercentText	dc.DrawText(buffer, buffer.GetLength(),&cur_rec, ((MLC_DT_TEXT | DT_RIGHT) & ~DT_LEFT) | DT_CENTER)
									cur_rec.top-=1;cur_rec.bottom-=1;
									DrawClientPercentText;cur_rec.left+=1;cur_rec.right+=1;
									DrawClientPercentText;cur_rec.left+=1;cur_rec.right+=1;
									DrawClientPercentText;cur_rec.top+=1;cur_rec.bottom+=1;
									DrawClientPercentText;cur_rec.top+=1;cur_rec.bottom+=1;
									DrawClientPercentText;cur_rec.left-=1;cur_rec.right-=1;
									DrawClientPercentText;cur_rec.left-=1;cur_rec.right-=1;
									DrawClientPercentText;cur_rec.top-=1;cur_rec.bottom-=1;
									DrawClientPercentText;cur_rec.left++;cur_rec.right++;
									dc.SetTextColor(RGB(255,255,255));
									DrawClientPercentText;
									dc.SelectObject(pOldFont);
									dc.SetBkMode(iOMode);
									dc.SetTextColor(oldclr);
								}
							}
							//Xman end
							cur_rec.bottom++;
							cur_rec.top--;
						}
						break;
					default:
						// ==> Design Settings [eWombat/Stulle] - Stulle
						/*
						//Xman PowerRelease //Xman show LowIDs
						if(iColumn == 1) { 
							const CKnownFile *file = theApp.sharedfiles->GetFileByID(client->GetUploadFileID());
							if(file && file->GetUpPriority()==PR_POWER)
							dc.SetBkColor(RGB(255,225,225));
						}
						else if(iColumn == 10 && client->HasLowID()) 
							dc.SetBkColor(RGB(255,250,200));
						//Xman end
						*/
						// <== Design Settings [eWombat/Stulle] - Stulle
						dc.DrawText(szItem, -1, &cur_rec, MLC_DT_TEXT | uDrawTextAlignment);
						// ==> Design Settings [eWombat/Stulle] - Stulle
						/*
						dc.SetBkColor(crOldBackColor); //Xman PowerRelease //Xman show LowIDs
						*/
						// <== Design Settings [eWombat/Stulle] - Stulle
						break;
				}
			}
			cur_rec.left += iColumnWidth;
		}
	}

	DrawFocusRect(dc, lpDrawItemStruct->rcItem, lpDrawItemStruct->itemState & ODS_FOCUS, bCtrlFocused, lpDrawItemStruct->itemState & ODS_SELECTED);
}
예제 #3
0
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);*/
}