/// <summary> /// Expire the Splash Screen /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void splashScreenTimer_Tick(object sender, EventArgs e) { Debug.WriteLine(new LogMessage("timer_Tick", "Loading next layout after splashscreen")); System.Windows.Forms.Timer timer = (System.Windows.Forms.Timer)sender; timer.Stop(); timer.Dispose(); _schedule.NextLayout(); }
/// <summary> /// Change to the next layout /// <param name="scheduleItem"></param> /// </summary> private void ChangeToNextLayout(ScheduleItem scheduleItem) { Debug.WriteLine("ChangeToNextLayout: called", "MainWindow"); if (ApplicationSettings.Default.PreventSleep) { try { SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); } catch { Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Unable to set Thread Execution state"), LogType.Info.ToString()); } } try { // Destroy the Current Layout try { if (this.currentLayout != null) { Debug.WriteLine("ChangeToNextLayout: stopping the current Layout", "MainWindow"); this.currentLayout.Stop(); DestroyLayout(this.currentLayout); Debug.WriteLine("ChangeToNextLayout: stopped and removed the current Layout", "MainWindow"); } } catch (Exception e) { // Force collect all controls this.Scene.Children.Clear(); Trace.WriteLine(new LogMessage("MainForm", "ChangeToNextLayout: Destroy Layout Failed. Exception raised was: " + e.Message), LogType.Info.ToString()); throw e; } // Prepare the next layout try { this.currentLayout = PrepareLayout(scheduleItem); // We have loaded a layout background and therefore are no longer showing the splash screen // Remove the Splash Screen Image RemoveSplashScreen(); // Start the Layout. StartLayout(this.currentLayout); } catch (ShowSplashScreenException) { // Pass straight out to show the splash screen throw; } catch (Exception e) { Trace.WriteLine(new LogMessage("MainForm", "ChangeToNextLayout: Prepare/Start Layout Failed. Exception raised was: " + e.Message), LogType.Info.ToString()); // Remove the Layout again if (this.currentLayout != null) { DestroyLayout(this.currentLayout); } // Pass out throw; } } catch (ShowSplashScreenException) { // Specifically asked to show the splash screen. if (!_showingSplash) { ShowSplashScreen(10); } } catch (Exception ex) { Trace.WriteLine(new LogMessage("MainForm", "ChangeToNextLayout: Layout Change to " + scheduleItem.layoutFile + " failed. Exception raised was: " + ex.Message), LogType.Error.ToString()); // We could not prepare or start this Layout, so we ought to remove it from the Schedule. _schedule.RemoveLayout(scheduleItem); // Do we have more than one Layout in our Schedule which we can try? if (_schedule.ActiveLayouts > 1) { _schedule.NextLayout(); } else if (scheduleItem != _schedule.GetDefaultLayout() && !_schedule.GetDefaultLayout().IsSplash()) { // Can we show the default layout? try { currentLayout = PrepareLayout(_schedule.GetDefaultLayout()); // We have loaded a layout background and therefore are no longer showing the splash screen // Remove the Splash Screen Image RemoveSplashScreen(); // Start the Layout. StartLayout(this.currentLayout); } catch { Trace.WriteLine(new LogMessage("MainForm", "ChangeToNextLayout: Failed to show the default layout. Exception raised was: " + ex.Message), LogType.Error.ToString()); ShowSplashScreen(10); } } else { ShowSplashScreen(10); } } }
/// <summary> /// Change to the next layout /// <param name="scheduleItem"></param> /// </summary> private void ChangeToNextLayout(ScheduleItem scheduleItem) { Debug.WriteLine("ChangeToNextLayout: called", "MainWindow"); if (ApplicationSettings.Default.PreventSleep) { try { SetThreadExecutionState(EXECUTION_STATE.ES_DISPLAY_REQUIRED | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_CONTINUOUS); } catch { Trace.WriteLine(new LogMessage("MainForm - ChangeToNextLayout", "Unable to set Thread Execution state"), LogType.Info.ToString()); } } try { // Destroy the Current Layout try { if (this.currentLayout != null) { Debug.WriteLine("ChangeToNextLayout: stopping the current Layout", "MainWindow"); this.currentLayout.Stop(); DestroyLayout(this.currentLayout); Debug.WriteLine("ChangeToNextLayout: stopped and removed the current Layout", "MainWindow"); } } catch (Exception e) { // Force collect all controls this.Scene.Children.Clear(); Trace.WriteLine(new LogMessage("MainForm", "ChangeToNextLayout: Destroy Layout Failed. Exception raised was: " + e.Message), LogType.Info.ToString()); throw e; } // Prepare the next layout try { this.currentLayout = PrepareLayout(scheduleItem); // We have loaded a layout background and therefore are no longer showing the splash screen // Remove the Splash Screen Image RemoveSplashScreen(); // Start the Layout. StartLayout(this.currentLayout); } catch (DefaultLayoutException) { throw; } catch (Exception e) { Trace.WriteLine(new LogMessage("MainForm", "ChangeToNextLayout: Prepare/Start Layout Failed. Exception raised was: " + e.Message), LogType.Info.ToString()); // Remove the Layout again if (this.currentLayout != null) { DestroyLayout(this.currentLayout); } throw; } } catch (Exception ex) { if (!(ex is DefaultLayoutException)) { Trace.WriteLine(new LogMessage("MainForm", "ChangeToNextLayout: Layout Change to " + scheduleItem.layoutFile + " failed. Exception raised was: " + ex.Message), LogType.Error.ToString()); } // Do we have more than one Layout in our schedule? if (_schedule.ActiveLayouts > 1) { _schedule.NextLayout(); } else { if (!_showingSplash) { ShowSplashScreen(); } // In 10 seconds fire the next layout DispatcherTimer timer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 10) }; timer.Tick += new EventHandler(splashScreenTimer_Tick); timer.Start(); } } }