如何在我的 WPF 应用程序中执行屏幕保护程序之类的操作?
我有一个 WPF 应用程序,主窗口中有 3 个不同的用户控件,但当时只有其中一个可见。这就像拥有 3 个不同的页面,您可以根据需要从一个页面切换到另一个页面。第一页就像一个开始屏幕。其次是“普遍看法”。第三页显示详细信息。 使用情节提要可以很好地在它们之间进行切换。我只是使可见页面不可见(不透明度为零)并将其移出可见窗口区域,然后将新页面移入可见窗口区域并使其可见。到目前为止一切顺利......(希望你明白我想告诉你的事情^^)
但是如果有像屏幕保护模式这样的东西那就太好了。我想要的是: 当用户在 2 分钟内没有执行任何操作时,应该运行 Storyboard,将您带回到开始屏幕视图。
这将如何运作?
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??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 DispatcherTimer 来跟踪应用程序空闲时间。只要您处于除“开始屏幕”之外的屏幕中,就启动此计时器。每当窗口有鼠标事件时,将计时器重置为零。将计时器持续时间设置为 2 分钟,以便在计时器回调时使开始屏幕可见。
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.