I have a value int -can be retrieved as
intopacitylevel- that controls opacity of an element on a Form. When I run my application, the value is set to a number of the random range 1 - 255.
How could I put the following together as a mousewheel solution in c#?: What I want is, moving the mwheel up or down will constantly change the opacity value to the minimum or maximum value depending on mwheel movement direction by adding/subtracting 1 to the current value every 1ms.
This behaviour precisely:
For up direction, stop value increase only when the mwheel was moved to the next spot upwards or when the value is at the maximum 255. For down direction, stop value decrease only when the mwheel was moved to the next spot downwards or when the value is at the minimum 1.
This .gif shows the result I want:
at this place was a picture in the past
What I have tried:
I'm new to c#, and I'm not very certain or very flexible with the options I have yet.
At the first place I'm unsure how I should define the specific mousewheel rules and combined with a timer?/flag? to decrease/increase a value correctly.
I think I figured out a way to check if mousewheel moved up or down at least.
I'm not sure if it makes a lot sense to start like that, but this was my first approach in the right direction eventually.
private void Form1_MouseWheel(object sender, MouseEventArgs e)
{
int mousedeltaval = e.Delta / 120
if (mousedeltaval == 1)
{
}
if (mousedeltaval == -1)
{
}
}