private void ShowHand_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; //绘画背景 //CImageHandle ImageHandle(&m_ImageBack); GameGraphics.DrawImage(g, m_ImageBack, 0, 0, m_ImageBack.Width, m_ImageBack.Height, 0, 0); //设置 DC //dc.SetBkMode(TRANSPARENT); Brush textbrush = new SolidBrush(Color.Black); //dc.SetTextColor(RGB(0,0,0)); //dc.SelectObject(CSkinResourceManager::GetDefaultFont()); //创建字体 Font ViewFont = new Font("Arial", 15); //ViewFont.CreateFont(-15,0,0,0,400,0,0,0,134,3,2,1,1,TEXT("Arial")); //CFont *pOldFont=dc.SelectObject(&ViewFont); string tCh = string.Format("{0}", m_bTimes); //TCHAR tCh[128]=TEXT(""); //_snprintf(tCh,sizeof(tCh),TEXT("%ld"),m_bTimes); Rectangle rcScore = new Rectangle(85, 10, 85 + 65, 10 + 19); GameGraphics.DrawString(g, tCh, ViewFont, textbrush, rcScore); //还原字体 //dc.SelectObject(pOldFont); //ViewFont.DeleteObject(); }
//绘画筹码 public void DrawGoldView(Graphics g, int nXPos, int nYPos, bool bCount, bool bCenter, byte bDUser) { //加载位图 //CImageHandle ImageHandle(&m_ImageGold); if (!bCenter) { //绘画筹码 int nYPosDraw = nYPos - GOLD_IMAGE_HEIGHT / 2; int iDrawCount = 0; for (int i = 0; i < m_lGoldCount.Length; i++) { for (int j = 0; j < m_lGoldCount[i]; j++) { iDrawCount++; GameGraphics.DrawAlphaImage(g, m_ImageGold, nXPos - GOLD_IMAGE_WIDTH / 2, nYPosDraw, GOLD_IMAGE_WIDTH, GOLD_IMAGE_HEIGHT, (m_lGoldCount.Length - i - 1) * GOLD_IMAGE_WIDTH, 0, Color.FromArgb(255, 0, 255)); nYPosDraw -= 3; if (iDrawCount >= m_lMaxLayer) { break; } } if (iDrawCount >= m_lMaxLayer) { break; } } } else //中心筹码 { //绘画筹码 int nYPosDraw = nYPos - GOLD_IMAGE_HEIGHT / 2; int nXPosDraw = nXPos - GOLD_IMAGE_HEIGHT / 2; int iCount = 0, iDrawCount = 0; int xTemp = 0, yTemp = 0; for (int i = 0; i < m_lGoldCount.Length; i++) { for (int j = 0; j < m_lGoldCount[i]; j++) { iDrawCount++; GameGraphics.DrawAlphaImage(g, m_ImageGold, nXPosDraw + xTemp, nYPosDraw + GOLD_IMAGE_HEIGHT / 2 + 2, GOLD_IMAGE_WIDTH, GOLD_IMAGE_HEIGHT, (m_lGoldCount.Length - i - 1) * GOLD_IMAGE_WIDTH, 0, Color.FromArgb(255, 0, 255)); nYPosDraw -= 3; if (iDrawCount >= m_lMaxLayer) { iDrawCount = 0; nYPosDraw = nYPos - GOLD_IMAGE_HEIGHT / 2; iCount++; if (iCount == 1) { xTemp = GOLD_IMAGE_WIDTH; } else if (iCount == 2) { xTemp = -GOLD_IMAGE_WIDTH; } else if (iCount == 3) { xTemp = GOLD_IMAGE_WIDTH * 2; } else if (iCount == 4) { xTemp = -GOLD_IMAGE_WIDTH * 2; } } } } } //绘画数字 if ((m_lGold >= 1L) && (bCount == true)) { Font ViewFont; Brush brush; if (bCenter) { //ViewFont = new Font((-17,0,0,0,400,0,0,0,134,3,2,1,1,TEXT("Arial")); ViewFont = new Font("Arial", 17); brush = new SolidBrush(Color.FromArgb(255, 255, 4)); } else { //ViewFont = new Font(-15,0,0,0,400,0,0,0,134,3,2,1,1,TEXT("Arial")); ViewFont = new Font("Arial", 15); brush = new SolidBrush(Color.FromArgb(255, 255, 4)); } //CFont *pOldFont=pDC->SelectObject(&ViewFont); //int iBkMode = pDC->SetBkMode( TRANSPARENT ); string szBuffer = GameGraphics.GetGoldString(m_lGold); int iY = nYPos + GOLD_IMAGE_HEIGHT / ((bCenter)?1:2) + 1; int iX = (bDUser != 4)?0:62; Rectangle DrawRect = new Rectangle(nXPos - 50 + iX, iY, 96, 20); if (bDUser != 4) { GameGraphics.DrawString(g, szBuffer, ViewFont, brush, DrawRect); } else { StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; //stringFormat.LineAlignment = StringAlignment.Center; stringFormat.FormatFlags = StringFormatFlags.NoWrap; g.DrawString(szBuffer, ViewFont, brush, DrawRect, stringFormat); } //pDC->SetBkMode(iBkMode); //pDC->SelectObject(pOldFont); //ViewFont.DeleteObject(); } return; }
private void ScoreView_Paint(object sender, PaintEventArgs e) { if (this.Visible != true) { return; } //CPaintDC dc(this); //SetupRegion(&dc,m_ImageBack,RGB(255,0,255)); //设置 DC //dc.SetBkMode(TRANSPARENT); //dc.SetTextColor(RGB(250,250,250)); //dc.SelectObject(CSkinResourceManager::GetDefaultFont()); Graphics g = e.Graphics; Brush brush = new SolidBrush(Color.FromArgb(250, 250, 250)); Font viewFont = new Font("Arial", 12); //绘画背景 //CImageHandle ImageHandle(&m_ImageBack); if (m_lGameScore > 0) { // m_ImageBack.BitBlt(dc.GetSafeHdc(),0,0,m_ImageBack.GetWidth()/3,m_ImageBack.GetHeight(),0,0,SRCCOPY); GameGraphics.DrawAlphaImage(g, m_ImageBack, 0, 0, m_ImageBack.Width / 3, m_ImageBack.Height, 0, 0, Color.FromArgb(255, 0, 255)); } else if (m_lGameScore == 0L) { GameGraphics.DrawAlphaImage(g, m_ImageBack, 0, 0, m_ImageBack.Width / 3, m_ImageBack.Height, m_ImageBack.Width / 3, 0, Color.FromArgb(255, 0, 255)); } else { GameGraphics.DrawAlphaImage(g, m_ImageBack, 0, 0, m_ImageBack.Width / 3, m_ImageBack.Height, 2 * m_ImageBack.Width / 3, 0, Color.FromArgb(255, 0, 255)); } //显示分数 string szBuffer = string.Empty; Rectangle rcScore = new Rectangle(60, 60, 65, 19); //用户金币 szBuffer = string.Format("{0}", m_lGameScore); GameGraphics.DrawString(g, szBuffer, viewFont, brush, rcScore); //dc.SetTextColor(RGB(0,0,0)); //显示秒数 string szBuffe = string.Empty; int ileft = 52; int itop = 8; Rectangle rcScor = new Rectangle(ileft, itop, ileft + 15, itop + 15); //创建资源 Font InfoFont; //InfoFont.CreateFont(-14,0,0,0,10,0,0,0,4,0,2,1,2,TEXT("宋体")); InfoFont = new Font("宋体", 14); //设置 DC //dc.SetTextAlign(TA_CENTER|TA_TOP); //CFont * pOldFont=dc.SelectObject(&InfoFont); //绘画信息 szBuffe = string.Format("{0}", m_bTimes); //dc.Ellipse(&rcScor); brush = new SolidBrush(Color.FromArgb(255, 255, 255)); g.DrawString(szBuffe, InfoFont, brush, ileft + 132, itop - 2); //清理资源 //dc.SelectObject(pOldFont); //InfoFont.DeleteObject(); return; }