vendredi 3 avril 2015

C# - Gradually filling a rectangle using a timer and a trackbar to control the speed

I am having issues trying to figure out how to fill a rectangle by using the trackbar value to control the speed of the fill. Imagine water flowing into a cup, so the water pours into the cup but the speed of the water flow is controled by the trackbar's value. I can't get it to fill from the bottom up. It starts from the top down, which I need it to fill from the bottom up instead. My code is below:



private void trackBar_Scroll(object sender, EventArgs e)
{
trackBarSpeed = trackBar.Value;

}

private void tmrTimer_Tick(object sender, EventArgs e)
{
timerCounter++;

Graphics graphics = CreateGraphics();
Rectangle rectangle = new Rectangle(81, 201, 219, (10 + timerCounter) * trackBarSpeed);

graphics.FillRectangle(new SolidBrush(colour), rectangle);
}

Aucun commentaire:

Enregistrer un commentaire