圆形应用程序中的背景颜色不改变
我正在我编写的一个简单的背景颜色更改程序中使用视觉控件和颜色。我还想合并圆形应用程序窗口,这是通过创建一个被黑色包围的实心圆的位图并使黑色透明来实现的。现在我的背景色不再循环。谁能告诉我如何解决这个问题。我将包含我的代码以防万一它有帮助,但我认为这是一个表单属性问题。感谢您的帮助!
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Point mouse_offset;
public int c;
private void button1_Click(object sender, EventArgs e)
{
using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
{
synth.Speak("This is a test of the emergency see sharp broadcasting network!");
synth.Speak("The man to the left is actually trying to dance without graphics capabilities");
}
while (Visible)
{
using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
{
synth.Speak("Flash dance commencing in three. two. one.");
}
while (Visible)
{
for (int c = 0; c < 255 && Visible; c++)
{
this.BackColor = Color.FromArgb(c, 255 - c, c);
Application.DoEvents();
//slow();
}
for (int c = 255; c > 0 && Visible; c--)
{
this.BackColor = Color.FromArgb(c, 255 - c, c);
Application.DoEvents();
//slow();
}
}
}
}
public static void slow()
{
System.Threading.Thread.Sleep(3);
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
mouse_offset = new Point(-e.X, -e.Y);
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point mousePos = Control.MousePosition;
mousePos.Offset(mouse_offset.X, mouse_offset.Y);
Location = mousePos;
}
}
}
}
I'm playing around with visual controls and colors in a simple background color changing program I've written. I also wanted to incorporate the circular application window, which I did by creating a bitmap of a solid circle surrounded by black and making the black transparent. Now my back ground color doesn't loop. Can anyone tell me how to fix this. Ill include my code just in case it helps but I think this is a form properties problem. Thanks for any help!
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Point mouse_offset;
public int c;
private void button1_Click(object sender, EventArgs e)
{
using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
{
synth.Speak("This is a test of the emergency see sharp broadcasting network!");
synth.Speak("The man to the left is actually trying to dance without graphics capabilities");
}
while (Visible)
{
using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
{
synth.Speak("Flash dance commencing in three. two. one.");
}
while (Visible)
{
for (int c = 0; c < 255 && Visible; c++)
{
this.BackColor = Color.FromArgb(c, 255 - c, c);
Application.DoEvents();
//slow();
}
for (int c = 255; c > 0 && Visible; c--)
{
this.BackColor = Color.FromArgb(c, 255 - c, c);
Application.DoEvents();
//slow();
}
}
}
}
public static void slow()
{
System.Threading.Thread.Sleep(3);
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
mouse_offset = new Point(-e.X, -e.Y);
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point mousePos = Control.MousePosition;
mousePos.Offset(mouse_offset.X, mouse_offset.Y);
Location = mousePos;
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次您更改组件的外观并想要显示此更改时,请调用
这会强制组件重新绘制自身。现在您已经了解了,有多种方法可以优化重绘,但我认为上述内容应该可以帮助您入门。
Every time you have changed the looks of a component and want to display this change, call
This forces the conponent to redraw itself. Now that you're there, there are a number of ways to optimize redraws, but I think the above should get you started.