做視頻網(wǎng)站需要什么服務(wù)器網(wǎng)絡(luò)的推廣方式有哪些
目錄
一、涉及到的知識點
1.設(shè)置窗體的背景圖
2.加載窗體背景圖
3.清空窗體的背景圖
二、 示例
一、涉及到的知識點
1.設(shè)置窗體的背景圖
? ? ? ? 詳見本文作者的其他文章:C#手動改變自制窗體的大小-CSDN博客 ?https://wenchm.blog.csdn.net/article/details/137027140
2.加載窗體背景圖
????????詳見本文作者的其他文章:C#手動改變自制窗體的大小-CSDN博客 ?https://wenchm.blog.csdn.net/article/details/137027140
? ? ? ? 推薦使用下列方法:
/// <summary>
/// 加載初始背景圖片
/// </summary>
private void Form1_Load(object? sender, EventArgs e)
{BackgroundImage = Properties.Resources.test;BackgroundImageLayout = ImageLayout.Tile;
}
3.清空窗體的背景圖
????????graphics.Clear()?方法用于清除指定的?Graphics?對象的背景。這個方法接受一個?Color?類型的參數(shù),它指定了要使用的顏色,例如使用了Color.BlueViolet?作為參數(shù),這意味著當(dāng)調(diào)用?graphics.Clear(Color.BlueViolet)?時,窗體的背景將被清除并設(shè)置為藍(lán)紫色。
????????graphics.Clear()?方法通常用于在開始繪制之前清空畫布或窗體的背景。如果不調(diào)用此方法,那么任何在窗體上繪制的內(nèi)容都會疊加在以前的內(nèi)容之上,這可能會導(dǎo)致一些不需要的視覺效果。
????????graphics.Clear()?方法只會清除?Graphics?對象所關(guān)聯(lián)的設(shè)備的背景,例如窗體或圖像。如果想要清除其他設(shè)備的背景,例如打印機或文件,需要使用其他方法。
二、 示例
? ? ? ? ?本實例在圖片資源管理器里放置了2張圖片,通過Load初始化加載一個背景圖,通過鼠標(biāo)單擊事件清空背景圖,通過鼠標(biāo)雙擊事件加載另一張背景圖。循環(huán)往復(fù)操作,觀察效果。
// 清空背景圖片
namespace _174
{public partial class Form1 : Form{public Form1(){InitializeComponent();}/// <summary>/// 加載初始背景圖片/// </summary>private void Form1_Load(object? sender, EventArgs e){BackgroundImage = Properties.Resources.test;BackgroundImageLayout = ImageLayout.Tile;}/// <summary>/// 清空背景圖片/// </summary>private void Form1_MouseClick(object sender, MouseEventArgs e){Graphics graphics = CreateGraphics(); //創(chuàng)建繪圖對象graphics.Clear(Color.BlueViolet); //清空背景graphics.Dispose(); //釋放繪圖資源}/// <summary>/// 再次加載背景圖片/// </summary>private void Form1_MouseDoubleClick(object sender, MouseEventArgs e){BackgroundImage = Properties.Resources.testnew;BackgroundImageLayout = ImageLayout.Tile;}}
}