private const int SPLASH_FADE_TIME = 500; // Miliseconds #endregion Fields #region Methods /// <summary> /// It loads the splash screen /// </summary> /// <param name="e"></param> protected override void OnStartup(StartupEventArgs e) { // Step 1 - Load the splash screen SplashScreen splash = new SplashScreen("Images/transcoderLogo.png"); splash.Show(false, true); // Step 2 - Start a stop watch Stopwatch timer = new Stopwatch(); timer.Start(); // Step 3 - Load your LoginWindow but don't show it yet base.OnStartup(e); LoginWindow main = new LoginWindow(); // testControlsPage main = new testControlsPage(); // Step 4 - Make sure that the splash screen lasts at least two seconds timer.Stop(); int remainingTimeToShowSplash = MINIMUM_SPLASH_TIME - (int)timer.ElapsedMilliseconds; if (remainingTimeToShowSplash > 0) Thread.Sleep(remainingTimeToShowSplash); // Step 5 - show the page splash.Close(TimeSpan.FromMilliseconds(SPLASH_FADE_TIME)); main.Show(); }
private void LogoutButton_Click(object sender, RoutedEventArgs e) { #region // User settings for resize var userPrefs = new UserPreferences(); this.Height = userPrefs.WindowHeight; this.Width = userPrefs.WindowWidth; this.Top = userPrefs.WindowTop; this.Left = userPrefs.WindowLeft; this.WindowState = userPrefs.WindowState; #endregion // if the user clicks the window close x button: if (MessageBox.Show("Are you sure that you want to logout?", "Logout", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { LoginWindow lw = new LoginWindow(); lw.Show(); this.Hide(); // do not forget to reset this page before hide. } }