I have a class and im doing the calculation if the user move the mouse wheel up make the frames per second higher.
If the user move the mouse wheel down lower. Up i mean 20,30,40 fps....Down 40,30,20...
Now i set it to 60 fps:
class PbsWheel { public PbsWheel(AnimatedPictureBox.AnimatedPictureBoxs[] pbs, AnimatedPictureBox.AnimatedPictureBoxs pb, int delta,Label label2) { for (int i = 0; i < pbs.Length; i++) { if (delta > 0) { label2.Text = (pbs[i].AnimationInterval += 1000 / 60).ToString(); } else { label2.Text = (pbs[i].AnimationInterval -= 1000 / 60).ToString(); } } } }
pbs is array of pictureBoxes and in the class AnimatedPictureBox i create a timer for each pictureBox and animate loop in each pictureBox images.
class AnimatedPictureBox { public class AnimatedPictureBoxs : PictureBox { public static bool images; List<string> imageFilenames; Timer t = new Timer(); public AnimatedPictureBoxs() { images = false; AnimationInterval = 10; t.Tick += Tick_Animate; } public int AnimationInterval { get { return t.Interval; } set { t.Interval = value; } } public void Animate(List<string> imageFilenames) { this.imageFilenames = imageFilenames; t.Start(); } public void StopAnimate() { t.Stop(); i = 0; } int i; private void Tick_Animate(object sender, EventArgs e) { if (images == true) { imageFilenames = null; } if (imageFilenames == null) { return; } else { try { if (i >= imageFilenames.Count) { i = 0; } else { Load(imageFilenames[i]); i = (i + 1) % imageFilenames.Count; } } catch (Exception err) { } } } }
I set the AnimationInterval to 10
I want in the mouse wheel class when the user move the mouse wheel up it will move by 10 frames per second.
I want that when the program is running the defalu speed will be 40fps and it will be the maximum.
From the the user can go down by 10...40,30,20,10 and 10 is the minimum.
Then up again to 40.
1. How do i use the AnimationInterval with the PbsWheel class so when i move the mouse wheel it will move by 10fps up/down ?
2. Is it logic to jump by 10 and limit it to 40fps max and 10fps min ? If not then show me in my code what should i set it to.
The AnimationInterval variable is set to 10 and its by Miliseconds.