public static void Screensaver(int timeOut) { CrossLogger.Current.Debug("Screensaver", "Configuring screensaver, using timeout of " + timeOut.ToString()); Device.StartTimer(TimeSpan.FromSeconds(10), () => { CrossLogger.Current.Debug("Screensaver", "Check if time to show screensaver"); if (App.config.LastActivity.AddSeconds(timeOut) < DateTime.Now && active == false) { CrossLogger.Current.Debug("Screensaver", "Enable Screensaver"); PreviousPage = Application.Current.MainPage; IDim dim = DependencyService.Get <IDim>(); dim.SetBacklight(0.0f); active = true; Application.Current.MainPage = CreatePage(); InfiniteLoop(); dim = null; } return(true); }); }
private static void OnResumeButtonClicked(object sender, EventArgs e) { CrossLogger.Current.Debug("Screensaver", "Button Pressed"); active = false; Application.Current.MainPage = PreviousPage; App.tp.CurrentPage = App.tp.Children[0]; //Revert to first tab when resuming App.config.LastActivity = DateTime.Now; //Update lastactivity to reset Screensaver timer IDim dim = DependencyService.Get <IDim>(); dim.SetBacklight(0.8f); dim = null; }