I used MouseMove event to detect mouse movement, so I could change the visibility of my buttons. After the mouse has stopped moving, the buttons are still there, because I don’t know how and where to count for the time to make those buttons invisible again.
Those buttons are controls on video player in full screen, so any other idea is also welcomed.
private void OnTimedEvent(object source, ElapsedEventArgs e)
{
timer.Stop();
button1.Visibility = Visibility.Hidden;
button2.Visibility = Visibility.Hidden;
}
private void mediaElement1_MouseMove(object sender, MouseEventArgs e)
{
if (!timer.Enabled)
{
timer.Enabled = true;
return;
}
if (timer.Enabled)
{
timer.Interval = 2000;
timer.Start();
button1.Visibility = Visibility.Visible;
button2.Visibility = Visibility.Visible;
timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
}
}
Your best bet would be to utilize some form of timer, such as the
Timerclass. You can then hook up to theElapsedevent and use the handler inside there to count the time elapsed. Once you reach a certain time threshold, you can then hide the buttons. So an example of the code steps would be something like:Timer.Elapsedevent.