自己写了一段代码(windows窗体应用程序),主要用于实现风车的转动,但出现了一点问题,求助。。
***********************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Timers;
using System.Threading;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace 大风车
{
public partial class Form1 : Form
{
public int i = 0;
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e) //退出
{
Application.Exit();
//this.Close();
/* if (MessageBox.Show("Do you want to exit?", "My Application",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
{
Application.Exit();
}*/
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show("你真的要退出应用程序吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button3) == DialogResult.No)
e.Cancel = true;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e) //开始
{
this.timer1.Start();
this.timer1_Tick(sender, null);
this.axWindowsMediaPlayer1.URL = "E://音乐//大风车.mp3";
this.axWindowsMediaPlayer1.Ctlcontrols.play();
this.pictureBox1.Refresh();
}
public void ExitApplication()
{
}
private void button2_Click(object sender, EventArgs e) //暂停
{
this.timer1.Stop();
this.axWindowsMediaPlayer1.Ctlcontrols.pause();
}
public void pictureBox1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.Clear(Color.Black);
SolidBrush mybrush = new SolidBrush(Color.Blue);
e.Graphics.FillPie(mybrush,Convert.ToInt32(220 - Math.Sin(6 * i) * 60), Convert.ToInt32(130 - Math.Cos(i * 6) * 60), 40, 60, -90 - i * 20, 180);
// e.Graphics.FillPie(mybrush, Convert.ToInt32(188 - Math.Sin(20 * i) * 60), Convert.ToInt32(86 - Math.Cos(i * 20) * 60), 40, 60, -90 -20, 180);
mybrush.Color = Color.Red;
e.Graphics.FillPie(mybrush, Convert.ToInt32(240 - Math.Cos(6 * i) * 60), Convert.ToInt32(110 + Math.Sin(i * 6) * 60), 60, 40, -180 - i * 20, 180);
mybrush.Color = Color.Green;
e.Graphics.FillPie(mybrush, Convert.ToInt32(160 + Math.Cos(6 * i) * 60), Convert.ToInt32(130- Math.Sin(i * 6) * 60), 40, 60, -270 - i * 20, 180 );
mybrush.Color = Color.Yellow;
e.Graphics.FillPie(mybrush, Convert.ToInt32(240 + Math.Sin(6 * i) * 60), Convert.ToInt32(50 + Math.Cos(i * 6) * 60), 60, 40, -360 - i * 20, 180 );
}
private void timer1_Tick(object sender, EventArgs e)
{
this.pictureBox1.Refresh();
i++;
}
private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
{
}
private void trackBar1_Scroll(object sender, EventArgs e)
{
this.timer1.Interval = this.trackBar1.Value;
}
}
}
****************************************