mahin.m
یک شنبه 04 اردیبهشت 1390, 03:16 صبح
سلام دوستان
برنامه ای نوشتم که در اونیک لوزی و 3 دایره در حال حرکتند.
حالا میخوام این دایره های در حال حرکت رنگ هاشون به ترتیب تغییرکنه.
ممنونم میشم اگه کمککنید.
کد ها به این ترتیبه :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace shape
{
publicpartialclassForm1 : Form
{
privateint xPosition = 940;
public Form1()
{
InitializeComponent();
}
privatevoid Redraw()
{
int l = xPosition;
Bitmap bm = newBitmap(940, 480);
Graphics gr = Graphics.FromImage(bm);
Point[] points1 = { newPoint(l, 50), newPoint(l + 20, 40), newPoint(l + 40, 50), newPoint(l + 20, 60) };
gr.DrawPolygon(Pens.Red, points1);
gr.DrawEllipse(Pens.Blue, l + 40, 40, 15, 15);
gr.DrawEllipse(Pens.Orange, l + 55, 40, 15, 15);
gr.DrawEllipse(Pens.Green, l + 70, 40, 15, 15);
pictureBox1.Width = bm.Width;
pictureBox1.Height = bm.Height;
pictureBox1.BackgroundImage = bm;
}
privatevoid Form1_Load(object sender, EventArgs e)
{
}
privatevoid timer1_Tick(object sender, EventArgs e)
{
xPosition--;
if (xPosition < -10)
xPosition = 940;
Redraw();
}
}
}
برنامه ای نوشتم که در اونیک لوزی و 3 دایره در حال حرکتند.
حالا میخوام این دایره های در حال حرکت رنگ هاشون به ترتیب تغییرکنه.
ممنونم میشم اگه کمککنید.
کد ها به این ترتیبه :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace shape
{
publicpartialclassForm1 : Form
{
privateint xPosition = 940;
public Form1()
{
InitializeComponent();
}
privatevoid Redraw()
{
int l = xPosition;
Bitmap bm = newBitmap(940, 480);
Graphics gr = Graphics.FromImage(bm);
Point[] points1 = { newPoint(l, 50), newPoint(l + 20, 40), newPoint(l + 40, 50), newPoint(l + 20, 60) };
gr.DrawPolygon(Pens.Red, points1);
gr.DrawEllipse(Pens.Blue, l + 40, 40, 15, 15);
gr.DrawEllipse(Pens.Orange, l + 55, 40, 15, 15);
gr.DrawEllipse(Pens.Green, l + 70, 40, 15, 15);
pictureBox1.Width = bm.Width;
pictureBox1.Height = bm.Height;
pictureBox1.BackgroundImage = bm;
}
privatevoid Form1_Load(object sender, EventArgs e)
{
}
privatevoid timer1_Tick(object sender, EventArgs e)
{
xPosition--;
if (xPosition < -10)
xPosition = 940;
Redraw();
}
}
}