int AppendItem2List( CListViewCtrlEx &listCtrl, T_VulListItemData * pVulItem )
{
	CString strTitle;
	FormatKBString(pVulItem->nID, strTitle);
	
	LPCTSTR lpszWarnDesc = GetLevelDesc(pVulItem->nWarnLevel);
	
	int nItem = listCtrl.Append(lpszWarnDesc, pVulItem->nWarnLevel>=0 ? LISTITEM_CHECKBOX:0);
	listCtrl.AppendSubItem(nItem, strTitle);
	listCtrl.AppendSubItem(nItem, pVulItem->strName);
	listCtrl.AppendSubItem(nItem, pVulItem->strPubDate);
	listCtrl.AppendSubItem(
        nItem, 
        pVulItem->nWarnLevel == -1 ? BkString::Get(IDS_VULFIX_5106)
                                   : (pVulItem->nWarnLevel > 0 ? BkString::Get(IDS_VULFIX_5107)
                                                               : BkString::Get(IDS_VULFIX_5108)) );
	
	if(pVulItem->nWarnLevel>3)
		listCtrl.SetSubItemColor(nItem, 0, red, false);
	
	/*listCtrl.SetItemData(nItem, (DWORD_PTR)pVulItem);*/
	listCtrl.SetItemData(nItem, (DWORD)pVulItem);
	return nItem;
}
void SetRelateInfo(CRichEditCtrlEx &ctlRichEdit, T_VulListItemData *pItemData, BOOL bOfferOperate)
{
	// Set Info Page Data 

	ctlRichEdit.ClearText();

	if(pItemData->nType==VTYPE_IGNORED)
	{
		CString str;
		str.Format(BkString::Get(IDS_VULFIX_5116), pItemData->strName);
		ctlRichEdit.AddText( str );
	}
	else
	{
		CString strText;

		// 软件的话, 提供操作 
		if(pItemData->nType==VTYPE_SOFTLEAK)
		{
			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5117), true);
			ctlRichEdit.AddText( pItemData->strName );
			ctlRichEdit.AddNewLine();
			
			if(bOfferOperate)
			{
				ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5118), true);
				int state = GetSoftItemState( pItemData );
				ctlRichEdit.AddText( SoftVulStatusOP[state] );
				ctlRichEdit.AddNewLine();
			}
			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5119), true);
			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5120));
			
			ctlRichEdit.AddNewLine();
			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5121), true);
			ctlRichEdit.AddText(pItemData->strDesc);
		}
		else
		{
			FormatKBString(pItemData->nID, strText);
			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5122), true);
			ctlRichEdit.AddText(strText);
			ctlRichEdit.AddNewLine();

			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5123), true);
			ctlRichEdit.AddText(pItemData->strMSID);
			ctlRichEdit.AddNewLine();

			FormatSizeString(pItemData->nFileSize, strText);
			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5124), true);
			ctlRichEdit.AddText(strText);
			ctlRichEdit.AddNewLine();

// 			ctlRichEdit.AddText(_T("发布日期:"), true);
// 			ctlRichEdit.AddText(pItemData->strPubDate);
// 			ctlRichEdit.AddNewLine();

			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5125), true);
//			ctlRichEdit.AddNewLine();
			COLORREF	clr=RGB(255,0,0);
			ctlRichEdit.AddText(pItemData->strAffects,FALSE,&clr);
			ctlRichEdit.AddNewLine();
			
			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5126), true);
			if ( !pItemData->isIgnored && pItemData->nWarnLevel > 0 )
				ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5120));
			else
				ctlRichEdit.AddText(pItemData->strSuggest);
			ctlRichEdit.AddNewLine();

			ctlRichEdit.AddText(BkString::Get(IDS_VULFIX_5127), true);
//			ctlRichEdit.AddNewLine();
			ctlRichEdit.AddText(pItemData->strDesc);			
		}
		
		ctlRichEdit.AddNewLine();
		ctlRichEdit.AddNewLine();
		ctlRichEdit.AddText(_T("  "));
		ctlRichEdit.AddLink(BkString::Get(IDS_VULFIX_5128));

		if( !pItemData->strDownloadUrl.IsEmpty() )
		{
			ctlRichEdit.AddText(_T("    "));
			ctlRichEdit.AddLink(BkString::Get(IDS_VULFIX_5129));
		}
		ctlRichEdit.AddNewLine();
		ctlRichEdit.AddText(_T("                    "));
		ctlRichEdit.EndLink();
	}
}
Beispiel #3
0
void CDlgTipDetail::OnPaint(CDCHandle dc)
{
    PAINTSTRUCT ps;
    HDC hDC = ::BeginPaint( m_hWnd, &ps );
    Gdiplus::Graphics grap(hDC);
    Gdiplus::Image *pImg = NULL;
    CDC memDC(hDC);
    int nDownHeightPos = m_rcClient.Height() - 27;

    memDC.SetBkMode(TRANSPARENT);

    pImg = BkPngPool::Get(IDP_VUL_TIP_HEAD);
    grap.DrawImage(pImg, 0,0);

    pImg = BkPngPool::Get(IDP_VUL_TIP_DOWN);
    grap.DrawImage(pImg, 0, nDownHeightPos);

    pImg = BkPngPool::Get(IDP_VUL_TIP_CLOSE);
    if (m_nCloseState == -1)
    {
        grap.DrawImage(pImg, m_rcCloseBtn.left, m_rcCloseBtn.top);
    }
    CRect rcGrant(0,84, DEF_VUL_TIP_DETAIL_WIDTH, nDownHeightPos);
    _DrawGradualColorRect(memDC, rcGrant,RGB(0xE4, 0xF0, 0xFE), RGB(0xD7, 0xE6, 0xF9), TRUE);
    
    _DrawLine(memDC, CPoint(0,0), CPoint(0,m_rcClient.Height()), RGB(0x87, 0x98, 0xA8));
    
    _DrawLine(memDC, CPoint(DEF_VUL_TIP_DETAIL_WIDTH - 1, 0), CPoint(DEF_VUL_TIP_DETAIL_WIDTH - 1, m_rcClient.Height()), RGB(0x87, 0x98, 0xA8));

    HFONT hHeadFont = BkFontPool::GetFont(TRUE, FALSE, FALSE, 1);
    HFONT hNormalFont = BkFontPool::GetFont(FALSE, FALSE, FALSE);
    CString strTitle;
    CString strTmp = BkString::Get(IDS_VULFIX_5019);
    FormatKBString(m_pItemData->nID, strTitle);
    strTitle =  strTmp + _T(":") + strTitle;
    CRect rcText(13, 10, 220, 25);
    CRect rcTemp;
    _DrawText(memDC, rcText, strTitle, RGB(0x0, 0x0, 0x0), hHeadFont);

    rcText.SetRect(15, 32, 200, 47);
    strTmp = BkString::Get(IDS_VULFIX_5021);
    strTitle = strTmp + _T(":") + m_pItemData->strPubDate;
    _DrawText(memDC, rcText, strTitle, RGB(0x44, 0x61, 0x83), hNormalFont);
    
    // 大小
    rcText.SetRect(275,32,DEF_VUL_TIP_DETAIL_WIDTH,47);
    FormatSizeString(m_pItemData->nFileSize, strTitle);
    strTmp = BkString::Get(IDS_VULFIX_5124);
    strTitle = strTmp + strTitle;
    _DrawText(memDC, rcText, strTitle, RGB(0x44, 0x61, 0x83), hNormalFont);
 
    // 绘制小点 和 描述文字
    pImg = BkPngPool::Get(IDP_VUL_TIP_POINT);
    CRect rcContent(15, 72, DEF_VUL_TIP_DETAIL_WIDTH, 72 + 15);
    
    if (!m_pItemData->strMSID.IsEmpty())
    {
        grap.DrawImage(pImg, rcContent.left, rcContent.top + 5);
        strTmp = BkString::Get(IDS_VULFIX_5123);
        strTmp += m_pItemData->strMSID;
        rcContent.left += 10;
        _DrawText(memDC, rcContent, strTmp, RGB(0,0,0), hNormalFont);
        rcContent.top += 17;
        rcContent.bottom += 17;
        rcContent.left = 15;
        rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH;
    }

    grap.DrawImage(pImg, rcContent.left, rcContent.top + 5);
    rcContent.left += 10;
    strTmp = BkString::Get(IDS_VULFIX_5125);
    _DrawText(memDC, rcContent, strTmp, RGB(0,0,0), hNormalFont);

    rcContent.left = rcContent.right;
    rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH;
    CString strAff = m_pItemData->strAffects;
    if (strAff.GetLength() < 25)
    {
        _DrawText(memDC, rcContent, strAff, RGB(255, 0, 0), hNormalFont);
    }
    else
    {
        strTmp = strAff.Mid(0, 25);
        _DrawText(memDC, rcContent, strTmp, RGB(255, 0, 0), hNormalFont);
        strAff = strAff.Mid(25);

        while(1)
        {
            if (strAff.GetLength() > 0)
            {
                int len = strAff.GetLength();
                rcContent.top += 17;
                rcContent.bottom += 17;
                rcContent.left = 25;
                rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH;
                if (strAff.GetLength() > 30)
                    len = 30;
                strTmp = strAff.Mid(0, len);
                _DrawText(memDC, rcContent, strTmp, RGB(255, 0, 0), hNormalFont);
                strAff = strAff.Mid(len);
            }
            else
            {
                break;
            }
        }
    }

    // 描述

    rcContent.top += 17;
    rcContent.bottom += 17;
    rcContent.left = 15;
    rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH;

    grap.DrawImage(pImg, rcContent.left, rcContent.top + 5);
    rcContent.left += 10;
    strTmp = BkString::Get(IDS_VULFIX_5172);
    _DrawText(memDC, rcContent, strTmp, RGB(0,0,0), hNormalFont);

    rcContent.left = rcContent.right;
    rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH;
    CString strDes = m_pItemData->strDesc;
    if (strDes.GetLength() < 25)
    {
        _DrawText(memDC, rcContent, strDes, RGB(0, 0, 0), hNormalFont);
    }
    else
    {
        HFONT oldFont = memDC.SelectFont(hNormalFont);;
        int len = 25;
        strTmp = strDes.Mid(0, len);
        int nCount = 0;
        while(1)
        {
            CSize nSize;
            memDC.GetTextExtent(strTmp, -1, &nSize);
            if (rcContent.left + nSize.cx < DEF_VUL_TIP_DETAIL_WIDTH - 30)
            {
                if (len < strDes.GetLength())
                {
                    ++len;
                    strTmp = strDes.Mid(0, len);
                }
                else
                {
                    break;
                }
            }
            else break;
        }
        _DrawText(memDC, rcContent, strTmp, RGB(0, 0, 0), hNormalFont);
        strDes = strDes.Mid(len);

        while(1)
        {
            if (nCount >= 2)
            {
                break;
            }
            if (strDes.GetLength() > 0)
            {
                int len = strDes.GetLength();
                rcContent.left = 25;
                rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH;
                if (strDes.GetLength() > 30)
                    len = 30;
                else 
                    break;
                strTmp = strDes.Mid(0, len);
                // 文字可能是混合的,从个数到计算长度来确定本行的个数。
                while(1)
                {
                    CSize nSize;
                    memDC.GetTextExtent(strTmp, -1, &nSize);
                    if (rcContent.left + nSize.cx < DEF_VUL_TIP_DETAIL_WIDTH - 30)
                    {
                        if (len < strDes.GetLength())
                        {
                            ++len;
                            strTmp = strDes.Mid(0, len);
                        }
                        else
                        {
                            break;
                        }
                    }
                    else break;
                }

                if (len == strDes.GetLength())
                    break;
                rcContent.top += 17;
                rcContent.bottom += 17;
                
                _DrawText(memDC, rcContent, strTmp, RGB(0, 0, 0), hNormalFont);
                strDes = strDes.Mid(len);
            }
            else
            {
                break;
            }
            nCount ++;
        }
        memDC.SelectFont(oldFont);
    }
    CSize nSize;
    rcContent.top += 17;
    rcContent.bottom += 17;
    rcContent.left = 25;
    rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH;
    memDC.GetTextExtent(strDes, -1, &nSize);
    if (rcContent.left + nSize.cx > DEF_VUL_TIP_DETAIL_WIDTH - 90)
        rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH - 90;
    _DrawText(memDC, rcContent, strDes, RGB(0, 0, 0), hNormalFont);

    rcContent.left = rcContent.right;
    rcContent.right = DEF_VUL_TIP_DETAIL_WIDTH;
    _DrawText(memDC, rcContent, BkString::Get(IDS_VULFIX_5128), RGB(0x33, 0x62, 0x9A), BkFontPool::GetFont(FALSE, TRUE ,FALSE));
    ::CopyRect(m_rcDetail, rcContent);
    
    // draw link
    HFONT hLinkFont = BkFontPool::GetFont(FALSE, TRUE, FALSE);
    CRect rcLink;
    COLORREF clrLink = RGB(0x33, 0x62, 0x9A);
    
    rcLink.SetRect(15, m_rcClient.Height() - 20, 300, m_rcClient.Height() - 5);
    _DrawText(memDC, rcLink, BkString::Get(IDS_VULFIX_5170), clrLink, hLinkFont);
    ::CopyRect(m_rcQuestion, rcLink);

    rcLink.left = 250;
    rcLink.right = DEF_VUL_TIP_DETAIL_WIDTH;
    _DrawText(memDC, rcLink, BkString::Get(IDS_VULFIX_5129), clrLink, hLinkFont);
    ::CopyRect(m_rcOfficial, rcLink);

    rcLink.left = 325;
    rcLink.right = DEF_VUL_TIP_DETAIL_WIDTH;
    _DrawText(memDC, rcLink, BkString::Get(IDS_VULFIX_5171), clrLink, hLinkFont);
    ::CopyRect(m_rcIgnoreVul, rcLink);

	::EndPaint( m_hWnd, &ps );
}