-1
我想使用paint事件製作帶有動畫背景的窗口。 像這樣:C#Win Forms背景動畫
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
namespace DrawGUI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
int w = this.ClientSize.Width;
int h = this.ClientSize.Height;
g.DrawLine(Pens.Red, 0, h/2 - 20, w, h/2 - 20);
int a = 0;
while (true)
{
a++;
g.DrawRectangle(Pens.Gray, a, h/2 - 20, 40, 40);
g.DrawRectangle(Pens.Red, a, h/2 - 20, 40, 40);
Thread
}
}
}
}
這工作正常,但我不能做任何事情。我如何在後臺運行繪畫事件?
當然,你不能做任何事情,你有一個無限循環。 – Kinetic
你需要獲得一本有關基本動畫技巧的書籍。這不是真的這種類型的基本教程的論壇 – edtheprogrammerguy