protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); StartupArguments = e.Args; try { #if !THREADED WindowSplash splashWindow = new WindowSplash(); _splashViewModel = new ViewModelWindowSplash(); splashWindow.DataContext = _splashViewModel; _splashViewModel.ProgressText = "Initialising..."; splashWindow.Show(); _mainWindow = new WindowMain(); _mainViewModel = new ViewModelWindowMain(); #else UpgradeSettings(); _threadSplashScreen = new Thread(ExecuteSplashScreen); _threadSplashScreen.SetApartmentState(ApartmentState.STA); _threadSplashScreen.Start(); _mainWindow = new WindowMain(); _mainViewModel = new ViewModelWindowMain(); bool mainWinShowInTaskbar = _mainWindow.ShowInTaskbar; SizeToContent mainWinSizeToContent = _mainWindow.SizeToContent; _mainWindow.ShowInTaskbar = false; _mainWindow.SizeToContent = SizeToContent.Manual; _mainWindow.WindowState = WindowState.Minimized; _mainWindow.Show(); #endif DispatcherHelper.DoEvents(); if (!_mainViewModel.Initialize()) { _mainWindow.Close(); } else { EventHandler handler = null; handler = delegate { _mainViewModel.RequestClose -= handler; _mainWindow.Close(); }; _mainViewModel.RequestClose += handler; _mainWindow.DataContext = _mainViewModel; App.Current.MainWindow = _mainWindow; #if !THREADED _mainWindow.Cursor = Cursors.Arrow; splashWindow.Close(); _mainWindow.Show(); #else _mainWindow.ShowInTaskbar = mainWinShowInTaskbar; _mainWindow.WindowState = WindowState.Normal; _mainWindow.SizeToContent = mainWinSizeToContent; #endif _mainWindow.Activate(); } } finally { if ((_threadSplashScreen != null) && _threadSplashScreen.IsAlive) { _threadSplashScreen.Abort(); } } }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); StartupArguments = e.Args; try { #if !THREADED WindowSplash splashWindow = new WindowSplash(); _splashViewModel = new ViewModelWindowSplash(); splashWindow.DataContext = _splashViewModel; _splashViewModel.ProgressText = "Initialising..."; splashWindow.Show(); _mainWindow = new WindowMain(); _mainViewModel = new ViewModelWindowMain(); #else UpgradeSettings(); _threadSplashScreen = new Thread(ExecuteSplashScreen); _threadSplashScreen.SetApartmentState(ApartmentState.STA); _threadSplashScreen.Start(); _mainWindow = new WindowMain(); _mainViewModel = new ViewModelWindowMain(); bool mainWinShowInTaskbar = _mainWindow.ShowInTaskbar; SizeToContent mainWinSizeToContent = _mainWindow.SizeToContent; _mainWindow.ShowInTaskbar = false; _mainWindow.SizeToContent = SizeToContent.Manual; _mainWindow.WindowState = WindowState.Minimized; _mainWindow.Show(); #endif DispatcherHelper.DoEvents(); if (!_mainViewModel.Initialize()) { _mainWindow.Close(); } else { EventHandler handler = null; handler = delegate { _mainViewModel.RequestClose -= handler; _mainWindow.Close(); }; _mainViewModel.RequestClose += handler; _mainWindow.DataContext = _mainViewModel; App.Current.MainWindow = _mainWindow; #if !THREADED _mainWindow.Cursor = Cursors.Arrow; splashWindow.Close(); _mainWindow.Show(); #else _mainWindow.ShowInTaskbar = mainWinShowInTaskbar; _mainWindow.WindowState = WindowState.Normal; _mainWindow.SizeToContent = mainWinSizeToContent; #endif _mainWindow.Activate(); } } finally { if ((_threadSplashScreen != null) && _threadSplashScreen.IsAlive) _threadSplashScreen.Abort(); } }