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(); }
//重画函数 private void GoldControl_Paint(object sender, PaintEventArgs e) { if (GetGold() >= m_lMinGold) { m_btOK.Enabled = true; } else { m_btOK.Enabled = false; } Graphics g = e.Graphics; //获取位置 Rectangle ClientRect = this.ClientRectangle; //GetClientRect(&ClientRect); //建立缓冲图 Bitmap BufferBmp = new Bitmap(ClientRect.Width, ClientRect.Height, g); Graphics BackFaceDC = Graphics.FromImage(BufferBmp); //加载资源 //CImageHandle ImageMidHandle(&m_ImageMid); //CImageHandle ImageLeftHandle(&m_ImageLeft); //CImageHandle ImageRightHandle(&m_ImageRight); //绘画背景 GameGraphics.DrawImage(BackFaceDC, m_ImageLeft, 0, 0, m_ImageLeft.Width, m_ImageLeft.Height, 0, 0); Rectangle dstRect = new Rectangle(m_ImageLeft.Width, 0, ClientRect.Width - m_ImageRight.Width, m_ImageMid.Height); Rectangle srcRect = new Rectangle(0, 0, m_ImageMid.Width, m_ImageMid.Height); g.DrawImage(m_ImageMid, dstRect, srcRect, GraphicsUnit.Pixel); //GameGraphics.DrawImage(BackFaceDC, m_ImageMid, m_ImageLeft.Width, 0, , , 0, 0); GameGraphics.DrawImage(BackFaceDC, m_ImageRight, ClientRect.Width - m_ImageRight.Width, 0, m_ImageRight.Width, m_ImageRight.Height, 0, 0); //绘画金币 int nXExcursion = ClientRect.Width - RIGHT_WIDTH; for (int i = 0; i < m_nCellCount; i++) { //绘画逗号 if ((i != 0) && (i % 3) == 0) { nXExcursion -= IMAGE_WIDTH; DrawGoldCell(BackFaceDC, nXExcursion, 12, 10); } //绘画数字 nXExcursion -= IMAGE_WIDTH; DrawGoldCell(BackFaceDC, nXExcursion, 12, m_lGoldCell[i]); } //绘画界面 GameGraphics.DrawImage(g, BufferBmp, 0, 0, ClientRect.Width, ClientRect.Height, 0, 0); }
//========================================================================== //Draw map //========================================================================== public void DrawMap() { if (INITIALIZED && RUNNING) { GameGraphics.SmoothingMode = SmoothingMode.AntiAlias; GameGraphics.DrawImage(MapOutput, Character.GetPoint(Canvas)); GameGraphics.DrawImage(Character.OImage, Canvas.Width / 2, Canvas.Height / 2); } }
//绘画金币 void DrawGoldCell(Graphics g, int nXPos, int nYPox, int lGold) { //CImageHandle ImageNumberHandle(&m_ImageNumber); if (lGold < 10) { GameGraphics.DrawImage(g, m_ImageNumber, nXPos, nYPox, IMAGE_WIDTH, IMAGE_HEIGHT, lGold * IMAGE_WIDTH, 0); } else { GameGraphics.DrawImage(g, m_ImageNumber, nXPos, nYPox, IMAGE_WIDTH, IMAGE_HEIGHT, 10 * IMAGE_WIDTH, 0); } return; }