Пример #1
0
void CSimplePanelDlg::DrawLine()
{
	if(0 >= m_vecData.size())
		return;

	CDC* pDC = GetDC();

	int nSize = 0;
	m_vecData.size() < m_vecMemDC.size() ? nSize = (int)m_vecData.size() : nSize = (int)m_vecMemDC.size();

	for (int ii = 0; ii < 6; ii++)
	{
		int nIndexData = ii;

		//显示下一屏的数据,如果不够显示当前屏的
		(ii + m_nIndexShow * 6) >= (int)m_vecData.size() ? nIndexData : nIndexData = ii + m_nIndexShow * 6;

		CEsayMemDC* pMemDC = m_vecMemDC[ii];
		CRect& rc = pMemDC->GetMemRect();

		Gdiplus::Graphics gr(pMemDC->GetDC());

		if(nIndexData < m_vecData.size())
		{
			CData* pData = m_vecData[nIndexData];
			vector<BusArrivalInfo> vecArrival;
			pData->GetBusInfo(vecArrival);

			DrawArrive(gr, vecArrival, rc, pData);
		}
		else
			DrawEmpty(gr, rc);

		pMemDC->BltMem(*pDC);
	}

	ReleaseDC(pDC);
}
Пример #2
0
/*! draw the card control as mazzo
// \param RECT &rc : 
// \param HDC hdcDST : 
// \param HDC hdcSRC : 
*/
BOOL CAxJpgCard::DrawAsMazzo(RECT &rc, HDC hdcDST, HDC hdcSRC)
{
    SetStretchBltMode(hdcDST, COLORONCOLOR);
    
    HRESULT hrP = NULL;

    RECT rc1 = rc;

    rc1.left -= e_OverLine;
    rc1.right += e_OverLine;
    rc1.top -= e_OverLine;
    rc1.bottom += e_OverLine;

                            // draws background
    DrawEmpty(rc1, hdcDST, NULL);
    
    int iOffset = 10; 
   
                            // draws cards lines
    int iXold = rc.right;
    int iXnew = iXold - iOffset;
    int iYold = rc.top;
    int iYnew = rc.top + iOffset;
    int iLineHeight = (rc.bottom - rc.top)- iOffset; 
    int iLineStepV = iXold - iXnew;
    int iLineWidth = 2;
    int iNumLinVert = iLineStepV / iLineWidth;
    if ( iLineStepV <= 2)
        iNumLinVert = 0;

    if ( m_lNumMazzoItems <= 2)
    {
        iNumLinVert = 0;
    }
    else if ( m_lNumMazzoItems <= 4)
    {
        iNumLinVert = 2;
    }
    else if ( m_lNumMazzoItems <= 6)
    {
        iNumLinVert = 3;
    }
    else if ( m_lNumMazzoItems <= 8)
    {
        iNumLinVert = 4;
    }
    else 
    {
        iNumLinVert = 5;
    }


                            // tan(pi/4)
                            // neg because x grow, y small
    double dm = - 0.854; 
    double db = iYold - dm * iXold;

    HPEN pen_black = CreatePen(PS_SOLID, 0, RGB(0,0,0));
    HPEN pen_old = (HPEN)SelectObject(hdcDST, pen_black);   

                            //draw vertical lines
    for (int i = iNumLinVert - 1; i >= 0; i--)
    {
        int iX1 = iXold - iLineWidth * i;
        int iX2 = iX1;
        double dY1 = iX1 * dm + db;
        int iY1 = (int)dY1;
        int iY2 = iY1 + iLineHeight;

        MoveToEx(hdcDST, iX1, iY1, NULL);
        LineTo(hdcDST, iX2, iY2);
      
    }

                            // draw horizontal lines
    int iLineStepH = iYnew - iYold;
    //int iNumLinHor = iLineStepH / iLineWidth;
    int iNumLinHor = iNumLinVert;
    int iLineYwidth = (rc.right - rc.left) - iOffset; ;

    for (int i = iNumLinHor - 1; i >= 0; i--)
    {
        int iY1 = iYold + i * iLineWidth;
        int iY2 = iY1;
        
        double dX1 = (iY1 - db) / dm;
        int iX1 = (int)dX1;
        int iX2 = iX1 - iLineYwidth ;
        
        MoveToEx(hdcDST, iX1, iY1, NULL);
        LineTo(hdcDST, iX2, iY2);
      
    }

    SelectObject(hdcDST, pen_old); 
    DeleteObject(pen_black);

                            // draw deck bitmap
    rc.top  += iLineWidth * iNumLinHor ;
    rc.right  -= iLineWidth * iNumLinVert;

    Rectangle(hdcDST, rc.left, rc.top, rc.right, rc.bottom);

    rc.left += e_OverLine;
    rc.right -= e_OverLine;
    rc.top += e_OverLine;
    rc.bottom -= e_OverLine;
    
    StretchBlt(hdcDST, rc.left, rc.top, (rc.right - rc.left) , (rc.bottom - rc.top), 
        hdcSRC, 0,0, e_BmW, e_BmH, SRCCOPY );
    
    return TRUE;
}
Пример #3
0
/*! Draw current selected card
// \param ATL_DRAWINFO& di : 
*/
HRESULT CAxJpgCard::OnDraw(ATL_DRAWINFO& di)
{
    
    RECT& rc = *(RECT*)di.prcBounds;
    
    HDC hdcComp = CreateCompatibleDC(di.hdcDraw);
    
    short iType;
    m_hCurrentImage->get_Type(&iType);
    ATLASSERT(iType == PICTYPE_BITMAP);
    
    //CreateDib(hdcComp);
    
    //SelectObject(hdcComp, (HBITMAP)m_hCurrentImage);
    SelectObject(hdcComp, m_hCurrentBitmap);
    
    
                            // draw a contour rectangle
    if (m_eCardStatus != CSW_ST_MAZZO)
        Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
    
    rc.left += e_OverLine;
    rc.right -= e_OverLine;
    rc.top += e_OverLine;
    rc.bottom -= e_OverLine;
    
    m_rc = rc;
    
    switch (m_eCardStatus)
    {
    case CSW_ST_DRAWFIRST:
        // first draw
        GetDIBColorTable(hdcComp, 0,  256, m_pColors );
        
        //DrawEmpty(rc, di.hdcDraw, hdcComp);
        //m_eCardStatus = CSW_ST_EMPTY;
        
        DrawNormal(rc, di.hdcDraw, hdcComp);
        m_eCardStatus = CSW_ST_DRAWNORMAL;
        //DrawAsMazzo(rc, di.hdcDraw, hdcComp);
        //m_eCardStatus = CSW_ST_MAZZO;

        //DrawRotated(rc, di.hdcDraw, hdcComp);
        //m_eCardStatus = CSW_ST_ROTATE90;
        
        //::OutputDebugString("Draw First\n");
        break;
    case CSW_ST_MAZZO:
        // deck draw (mazzo)
        DrawAsMazzo(rc, di.hdcDraw, hdcComp);
        //::OutputDebugString("Draw Mazzo\n");
        
    case CSW_ST_DRAWNORMAL:
        // usual draw
        DrawNormal(rc, di.hdcDraw, hdcComp);
        //::OutputDebugString("Draw Normal\n");
        break;
        
    case CSW_ST_ANIMATETOBLACK:
        // animate bitmap color to black
        AnimateToBlack(rc, di.hdcDraw, hdcComp);
        m_eCardStatus = CSW_ST_EMPTY;
        //::OutputDebugString("Animate to black\n");
        break;
        
    case CSW_ST_INVISIBLE:
        DrawInvisibile(rc, di.hdcDraw, hdcComp);
        m_eOldStatus = CSW_ST_INVISIBLE;
        //::OutputDebugString("Control invisible\n");
        break;
        
    case CSW_ST_ROTATE90:
        DrawRotated(rc, di.hdcDraw, hdcComp);
        //::OutputDebugString("Draw rotate 90\n");
        break;
        
    case CSW_ST_EMPTY:
        DrawEmpty(rc, di.hdcDraw, hdcComp);
        //::OutputDebugString("Draw Empty\n");
        break;
        
    case CSW_ST_RESTORE:
        DrawOriginalColors(rc, di.hdcDraw, hdcComp);
        m_eCardStatus = CSW_ST_DRAWNORMAL;
        //::OutputDebugString("Draw restore\n");
        break;

    case CSW_ST_SELECTED1:
        DrawSelected(rc, di.hdcDraw, hdcComp,1);
        m_eCardStatus = CSW_ST_SELECTED1;
        break;

    case CSW_ST_SELECTED2:
        DrawSelected(rc, di.hdcDraw, hdcComp,2);
        m_eCardStatus = CSW_ST_SELECTED2;
        break;

        
    default:
        _ASSERT(0);
        
        
    }
    
    
    
    DeleteDC(hdcComp);
    
    
    return S_OK;
}