所以我做了這個函數,繪製一個帶有圖片框和圖片的「按鈕」作爲參數。該按鈕應該是活躍的時候是藍色和灰色不活動時,但不知何故機能的研究吸引到按鈕上藍線時,它被認爲是不活躍c#繪製函數錯誤
如何刪除藍線?
void DrawButton(PictureBox PIC, Image IMG)
{
using (Font myFont = new Font("Century Gothic", 11))
{
Bitmap bitmap = new Bitmap(IMG, PIC.Width, PIC.Height);
bitmap.MakeTransparent();
Graphics graph = Graphics.FromImage(bitmap);
// PIC.Tag is "Next"
graph.DrawString(PIC.Tag.ToString(), myFont, Brushes.White, new Point(42, 0));
PIC.Image = bitmap;
graph.Dispose();
}
}
而且我的函數的調用:
private void picNext_MouseLeave(object sender, EventArgs e)
{
if (_CURRENT_PAGE * 12 < DB.GetOnlinePlayers())
DrawButton(picNext, Properties.Resources.play_no_hover);
else DrawButton(picNext, Properties.Resources.play_no_active);
}
private void picNext_MouseUp(object sender, MouseEventArgs e)
{
if (_CURRENT_PAGE * 12 < DB.GetOnlinePlayers())
DrawButton(picNext, Properties.Resources.play_hover);
else DrawButton(picNext, Properties.Resources.play_no_active);
}
private void picNext_MouseDown(object sender, MouseEventArgs e)
{
if (_CURRENT_PAGE * 12 < DB.GetOnlinePlayers())
DrawButton(picNext, Properties.Resources.play_take);
else DrawButton(picNext, Properties.Resources.play_no_active);
}
private void picNext_MouseEnter(object sender, EventArgs e)
{
if (_CURRENT_PAGE * 12 < DB.GetOnlinePlayers())
DrawButton(picNext, Properties.Resources.play_hover);
else DrawButton(picNext, Properties.Resources.play_no_active);
}
這是所有有代碼?如果是,你的'Properties.Resources.play_ *'資源是怎麼樣的? –
你在做什麼:Winforms,WPF,ASP ..? __Always__正確標記您的問題! – TaW
@DirkVollmar我添加了一張圖片。 – jeaks