views:

36

answers:

1

Hi,

I have an WPF-Application with 3 different UserControls in the MainWindow and only one of these is visible at the time. It's like having 3 different pages and you able to switch from one page to another when you like it. First page is like a start-screen. Second is like the "general view". And the third page shows details. Switching between them works fine with Storyboard. I just make the visible page invisible (opacity to zero) and move it out of the visible window- area and move the new page into the visible window-area and make it visible. So far so good... (Hope you understood what I wanted to tell^^)

But it would be nice to have something like a screensaver-mode. What I want is: When a user does nothing for , lets says, 2 minutes, then the Storyboard should be run that brings you back to the startscreen-view.

How would this work??

+1  A: 

You can use DispatcherTimer to track the Application Idle time. Start this timer whenever you are in the screens except StartScreen. Reset the timer to zero whenever the window have mouse events. Set Timer duration to 2 mins, so that on timer callback make the startscreen visible.

Ragunathan
Thank you for your fast answer. I'll try that.
So it works. But it's a bit complicated. My Application is a Microsoft Surface Application. And I do not have mouse events, but I have Contact-Events. My new question: If I understand you correctly, do I have to stick this "timer.Stop(); timer.Start();"-thing to each event in each of my usercontrols? I could do that but thats quite a lot of writing and it seems not to be elegant. Would there be an easier way do to this?
If you using in Surface then it is pretty simple. Just use the PreviewContactDown event in the mainwindow to reset the timer.
Ragunathan
I forget the mention onething you can use ApplicationLauncher.InactivityTimeoutOccurred event, This will sync up with the Surface shell inactivity time.
Ragunathan
Thank you very very much! It works great!! Exactly what I wanted!