//绘画界面
VOID CDlgInsureGame::OnDrawClientArea(CDC * pDC, INT nWidth, INT nHeight)
{	
	m_ImageFrame.DrawImage(pDC,30,55);
	DrawNumberString(pDC,m_lGameGold,200,78);
	DrawNumberString(pDC,m_lStorageGold,200,104);
	CRect rcScore(120,80,200,95);
	pDC->DrawText(TEXT("当前游戏币:"),rcScore,DT_END_ELLIPSIS | DT_CENTER | DT_WORDBREAK);
	CRect rcBank(120,105,200,120);
	pDC->DrawText(TEXT("保险柜游戏币:"),rcBank,DT_END_ELLIPSIS | DT_CENTER | DT_WORDBREAK);
	CRect rect(0,315,nWidth,nHeight);
	CString strInfo;
	strInfo.Format(TEXT("温馨提示:存入游戏币免手续费,取出将扣除%ld‰的手续费"), m_wRevenueTake);
	pDC->DrawText(strInfo,rect,DT_END_ELLIPSIS | DT_CENTER | DT_WORDBREAK);
}
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	DrawViewImage(pDC,m_ImageCenter,enMode_Centent);

	//单元积分
	m_ImageCellScore.DrawImage( pDC,m_nXBorder+5,m_nYBorder+5 );
	TCHAR szBuffer[32] = TEXT("");
	_snprintf( szBuffer,CountArray(szBuffer),TEXT("%ld"),m_lCellScore );
	DrawTextString( pDC,szBuffer,RGB(255,255,255),RGB(0,0,0),m_nXBorder+5+56,m_nYBorder+5+12,true );

	//绘画用户
	pDC->SetTextColor(RGB(255,255,0));
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		const tagUserData * pUserData=GetUserInfo(i);
		//test
		//tagUserData *pUserData = new tagUserData;
		//lstrcpy(pUserData->szName,TEXT("SSSSSssssssssssss"));
		//pUserData->cbUserStatus = US_READY;
		//end test
		if (pUserData!=NULL)
		{
			//用户名字
			pDC->SetTextAlign((i==1)?(TA_RIGHT|TA_TOP):(TA_LEFT|TA_TOP));
			DrawTextString(pDC,pUserData->szName,RGB(255,255,255),RGB(0,0,0),m_ptName[i].x,m_ptName[i].y,false);

			//胡牌先后
			if( m_cbWinOrder[i] != 0 )
			{
				CImageHandle HandleWinOrder(&m_ImageWinOrder);
				INT nWinOrderWidth = m_ImageWinOrder.GetWidth()/4;
				INT nWinOrderHeight = m_ImageWinOrder.GetHeight();
				m_ImageWinOrder.AlphaDrawImage( pDC,m_ptWinOrder[i].x-nWinOrderWidth/2,m_ptWinOrder[i].y-nWinOrderHeight/2,
					nWinOrderWidth,nWinOrderHeight,(m_cbWinOrder[i]-1)*nWinOrderWidth,0,RGB(255,0,255) );
			}

			//其他信息
			WORD wUserTimer=GetUserTimer(i);
			//test
			//wUserTimer = 30;
			//end test
			if ((wUserTimer!=0)&&(m_wCurrentUser!=INVALID_CHAIR))
			{
				DrawUserTimer(pDC,nWidth/2,nHeight/2 + 24,wUserTimer);
				if(m_wCurrentUser==0)
					m_ImageArrow.DrawImage(pDC,
									nWidth/2-15,	//X坐标
									nHeight/2-m_ImageArrow.GetHeight()*2 + 24,	//Y坐标
									m_ImageArrow.GetWidth()/4,				//宽
									m_ImageArrow.GetHeight(),				//高
									m_ImageArrow.GetWidth()/4*m_wCurrentUser,//起始位置X
									0);
				if(m_wCurrentUser==1)
					m_ImageArrow.DrawImage(pDC,nWidth/2+m_ImageArrow.GetWidth()/4,nHeight/2-15 + 24,m_ImageArrow.GetWidth()/4,m_ImageArrow.GetHeight(),m_ImageArrow.GetWidth()/4*m_wCurrentUser,0);
				if(m_wCurrentUser==2)
					m_ImageArrow.DrawImage(pDC,nWidth/2-15,nHeight/2+m_ImageArrow.GetHeight() + 24,m_ImageArrow.GetWidth()/4,m_ImageArrow.GetHeight(),m_ImageArrow.GetWidth()/4*m_wCurrentUser,0);
				if(m_wCurrentUser==3)
					m_ImageArrow.DrawImage(pDC,nWidth/2-m_ImageArrow.GetWidth()/4*2,nHeight/2-15 + 24,m_ImageArrow.GetWidth()/4,m_ImageArrow.GetHeight(),m_ImageArrow.GetWidth()/4*m_wCurrentUser,0);
			}
			if((wUserTimer!=0)&&(m_wCurrentUser==INVALID_CHAIR))
			{
				DrawUserTimer(pDC,nWidth/2,nHeight/2,wUserTimer);
				if(i==0)
					m_ImageArrow.DrawImage(pDC,nWidth/2-15,nHeight/2-m_ImageArrow.GetHeight()*2,m_ImageArrow.GetWidth()/4,m_ImageArrow.GetHeight(),m_ImageArrow.GetWidth()/4*i,0);
				if(i==1)
					m_ImageArrow.DrawImage(pDC,nWidth/2+m_ImageArrow.GetWidth()/4,nHeight/2-15,m_ImageArrow.GetWidth()/4,m_ImageArrow.GetHeight(),m_ImageArrow.GetWidth()/4*i,0);
				if(i==2)
					m_ImageArrow.DrawImage(pDC,nWidth/2-15,nHeight/2+m_ImageArrow.GetHeight(),m_ImageArrow.GetWidth()/4,m_ImageArrow.GetHeight(),m_ImageArrow.GetWidth()/4*i,0);
				if(i==3)
					m_ImageArrow.DrawImage(pDC,nWidth/2-m_ImageArrow.GetWidth()/4*2,nHeight/2-15,m_ImageArrow.GetWidth()/4,m_ImageArrow.GetHeight(),m_ImageArrow.GetWidth()/4*i,0);

			}

			if (pUserData->cbUserStatus==US_READY) 
				DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);

			//托管
			if(m_bTrustee[i])
			{
				m_ImageTrustee.DrawImage(pDC,m_PointTrustee[i].x,m_PointTrustee[i].y);
			}
		}
		//test
		//delete pUserData;
		//end test
	}

	//用户标志
	if (m_wBankerUser!=INVALID_CHAIR)
	{
		//加载位图
		CImageHandle ImageHandle(&m_ImageUserFlag);
		int nImageWidth=m_ImageUserFlag.GetWidth()/4;
		int nImageHeight=m_ImageUserFlag.GetHeight();

		//绘画标志
		for (WORD i=0;i<GAME_PLAYER;i++)
		{
			WORD wIndex=((i+GAME_PLAYER)-m_wBankerUser)%GAME_PLAYER;
			m_ImageUserFlag.AlphaDrawImage(pDC,m_UserFlagPos[i].x,m_UserFlagPos[i].y,nImageWidth,nImageHeight,nImageWidth*wIndex,0,RGB(255,0,255));
		}
	}
	
	//用户扑克
	m_UserCard[0].DrawCardControl(pDC);
	m_TableCard[0].DrawCardControl(pDC);
	
	//组合
	m_WeaveCard[0][0].DrawCardControl(pDC);	
	m_WeaveCard[0][1].DrawCardControl(pDC);
	m_WeaveCard[0][2].DrawCardControl(pDC);
	m_WeaveCard[0][3].DrawCardControl(pDC);

	m_HeapCard[0].DrawCardControl(pDC);	//上

	//桌面扑克
	m_TableCard[1].DrawCardControl(pDC);
	m_TableCard[2].DrawCardControl(pDC);
	m_TableCard[3].DrawCardControl(pDC);
	//for (WORD i=0;i<4;i++)
	//{
	//	m_TableCard[i].DrawCardControl(pDC); //桌子上的
	//	//m_DiscardCard[i].DrawCardControl(pDC);	//丢的

	//}

	m_UserCard[1].DrawCardControl(pDC);
	//组合
	m_WeaveCard[1][3].DrawCardControl(pDC);	
	m_WeaveCard[1][2].DrawCardControl(pDC);
	m_WeaveCard[1][1].DrawCardControl(pDC);
	m_WeaveCard[1][0].DrawCardControl(pDC);

	//组合
	m_WeaveCard[2][0].DrawCardControl(pDC);	
	m_WeaveCard[2][1].DrawCardControl(pDC);
	m_WeaveCard[2][2].DrawCardControl(pDC);
	m_WeaveCard[2][3].DrawCardControl(pDC);
	//组合
	m_WeaveCard[3][0].DrawCardControl(pDC);	
	m_WeaveCard[3][1].DrawCardControl(pDC);
	m_WeaveCard[3][2].DrawCardControl(pDC);
	m_WeaveCard[3][3].DrawCardControl(pDC);

	//丢弃牌
	m_DiscardCard[0].DrawCardControl(pDC);	//丢的
	m_DiscardCard[1].DrawCardControl(pDC);	//丢的
	m_DiscardCard[3].DrawCardControl(pDC);	//丢的
	m_DiscardCard[2].DrawCardControl(pDC);	//丢的

	//堆积扑克
	m_HeapCard[3].DrawCardControl(pDC);	//左
	//m_HeapCard[0].DrawCardControl(pDC);	//上
	m_HeapCard[1].DrawCardControl(pDC);	//右
	m_HeapCard[2].DrawCardControl(pDC);	//下

	//用户扑克
	//m_UserCard[0].DrawCardControl(pDC);
	//m_UserCard[1].DrawCardControl(pDC);
	m_UserCard[2].DrawCardControl(pDC);
	m_HandCardControl.DrawCardControl(pDC);

	//出牌提示
	if (m_bOutCard==true)
	{
		CImageHandle HandleOutCard(&m_ImageOutCard);
		m_ImageOutCard.AlphaDrawImage(pDC,(nWidth-m_ImageOutCard.GetWidth())/2,nHeight-145,RGB(255,0,255));
	}

	//等待提示
	if (m_bWaitOther==true)
	{
		CImageHandle HandleWait(&m_ImageWait);
		m_ImageWait.AlphaDrawImage(pDC,(nWidth-m_ImageWait.GetWidth())/2,nHeight-145,RGB(255,0,255));
	}

	//用户状态
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if ((m_wOutCardUser==i)||(m_cbUserAction[i]!=0))
		{
			//计算位置
			int nXPos=0,nYPos=0;
			switch (i)
			{
			case 0:	//北向	上
				{
					nXPos=nWidth/2 - 22;
					nYPos=nHeight/2 - 100 - 100 - 20;
					break;
				}
			case 1:	//东向   右
				{
					nXPos=nWidth/2 - 52 + 100 + 200;
					nYPos=nHeight/2 - 45;
					break;
				}
			case 2:	//南向	下
				{
					nXPos=nWidth/2 - 22;
					nYPos=nHeight/2 + 100 + 100 - 50;
					break;
				}
			case 3:	//西向	左
				{
					nXPos=nWidth/2 - 22 - 100 - 200;
					nYPos=nHeight/2 - 45;
					break;
				}
			}

			//绘画动作
			if (m_cbUserAction[i]!=WIK_NULL)
			{	

				//绘画动作
				if (m_bBombEffect==true)
				{

					//绘画效果
					INT nItemHeight=m_ImageActionAni.GetHeight()/6;
					INT nItemWidth=m_ImageActionAni.GetWidth()/BOMB_EFFECT_COUNT;

					//绘画动作
					int nYImagePos=0;
					if (m_cbUserAction[i]&WIK_PENG) nYImagePos=nItemHeight;
					else if (m_cbUserAction[i]&WIK_GANG) nYImagePos=nItemHeight*2;
					else if (m_cbUserAction[i]==WIK_CHI_HU) nYImagePos=nItemHeight*4;
					else if (m_cbUserAction[i]&WIK_ZI_MO) nYImagePos=nItemHeight*5;
					else nYImagePos=0;
					m_ImageActionAni.DrawImage(pDC,nXPos-nItemWidth/2+54,nYPos+42-nItemHeight/2,nItemWidth,nItemHeight,
						nItemWidth*(m_cbBombFrameIndex%BOMB_EFFECT_COUNT),nYImagePos,nItemWidth,nItemHeight);
				}
			}
			else
			{	
				//动作背景
				CImageHandle ImageHandle(&m_ImageActionBack);
				m_ImageActionBack.BlendDrawImage(pDC,nXPos,nYPos,m_ImageActionBack.GetWidth(),m_ImageActionBack.GetHeight(),
					0,0,RGB(255,0,255),180);


				//绘画扑克
				g_CardResource.m_ImageUserBottom.DrawCardItem(pDC,m_cbCardData,nXPos+15,nYPos+13);
			}

		}
	}

	//丢弃效果
	if(m_wDiscUser!=INVALID_CHAIR)
	{
		CSize SizeDisc(m_ImageDisc.GetWidth()/DISC_EFFECT_COUNT,m_ImageDisc.GetHeight());
		CPoint pt=m_DiscardCard[m_wDiscUser].GetLastCardPosition();
		pt.Offset(-SizeDisc.cx/2,-SizeDisc.cy);
		//绘画信息
		m_ImageDisc.DrawImage(pDC,pt.x,pt.y,SizeDisc.cx,SizeDisc.cy,
			m_cbDiscFrameIndex*SizeDisc.cx,0,SizeDisc.cx,SizeDisc.cy);
	}

	//绘画成绩框
	for( WORD i = 0; i < GAME_PLAYER; i++ )
		m_ScoreControl[i].DrawScoreControl( pDC );

	//杠牌得分动画
	if( m_wGangChairId != INVALID_CHAIR )
	{
		//刮风下雨动画
		if( m_cbXiaYu )
		{
			int nImageWidth = m_PngXiaYu.GetWidth()/4;
			int nImageHeight = m_PngXiaYu.GetHeight();
			m_PngXiaYu.DrawImage( pDC,m_ptGangScore[m_wGangChairId].x,m_ptGangScore[m_wGangChairId].y,
				nImageWidth,nImageHeight,nImageWidth*m_cbGangIndex,0,nImageWidth,nImageHeight );
		}
		else
		{
			int nImageWidth = m_PngGuaFeng.GetWidth()/4;
			int nImageHeight = m_PngGuaFeng.GetHeight();
			m_PngGuaFeng.DrawImage( pDC,m_ptGangScore[m_wGangChairId].x,m_ptGangScore[m_wGangChairId].y,
				nImageWidth,nImageHeight,nImageWidth*m_cbGangIndex,0,nImageWidth,nImageHeight );
		}
		for( WORD i = 0; i < GAME_PLAYER; i++ )
		{
			if( m_lGangScore[i] > 0 )
				DrawNumberString( pDC,m_PngNumWin,m_ptGangScore[i].x,m_ptGangScore[i].y-m_nYGangStep*3,m_lGangScore[i],true,true );
			else DrawNumberString( pDC,m_PngNumLost,m_ptGangScore[i].x,m_ptGangScore[i].y-m_nYGangStep*3,m_lGangScore[i],true,true );
		}
	}

	return;
}