public PlayState(IPlayniteAPI api) : base(api) { settings = new PlayStateSettingsViewModel(this); Properties = new GenericPluginProperties { HasSettings = true }; SetExclusionList(); stopwatchList = new List <Tuple <Guid, Stopwatch> >(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMilliseconds(1000); timer.Tick += (src, args) => { timer.Stop(); if (currentSplashWindow != null) { currentSplashWindow.Hide(); currentSplashWindow.Topmost = false; } }; splashWindowViewModel = new SplashWindowViewModel(); }
public SplashManager() { mSplashWindow = new SplashWindow(); viewModel = new SplashWindowViewModel(); viewModel.WindowMinimumWidth = 473.0; viewModel.WindowMinimumHeight = 300.0; mSplashWindow.ViewModel = viewModel; autoResetEvent = new AutoResetEvent(false); }
public override void OnFrameworkInitializationCompleted() { if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { var splashWindow = new SplashWindow(); var swvm = new SplashWindowViewModel(splashWindow); swvm.WorkFinished += OnSplashFinished; splashWindow.DataContext = swvm; desktop.MainWindow = splashWindow; } base.OnFrameworkInitializationCompleted(); }
/// <summary> /// Borrowed this from one of my work apps, it's a good example of using the background worker to handle loading while not locking /// up the UI. If you dig into splashscreen a little, it also has a good example of CB events and how easy they are to use. /// </summary> /// <param name="sender"></param> /// <param name="ev"></param> protected override void OnStartup(object sender, System.Windows.StartupEventArgs ev) { try { //Create an instance of the splashscreenVM SplashWindowViewModel vm = new SplashWindowViewModel(); //Create instance of the background worker, we only need it locally. var bw = new BackgroundWorker(); //Tell the background where what to actually do, we could split this into another method, but it's fine here for now. bw.DoWork += (xs, args) => { //Just some basic logging using log4net. m_log.Error("Starting Application"); //This is an example of caliburns events, we publish an event on the UI thread which is then handled by other classes. //in this case it's handled by the splashscreenviewmodel. IoC.Get <IEventAggregator>().PublishOnUIThread(new LoadingStatusMessage("Beginning Application Setup")); m_log.Info("Starting Data Processing"); }; //Tell the background worker what to do when we've finished DoWork. bw.RunWorkerCompleted += (s, args) => { //Ensure we didn't get any errors in DoWork. if (args.Error != null) { //Log any errors we did, not exactly handled well, but it's fine for now. m_log.Error(args.Error.Message); } //Display the root view, in this case it's mainwindowviewmodel, the view will be found automagically. DisplayRootViewFor <MainWindowViewModel>(); //Close the splashscreen vm.TryClose(); //Case base startup. base.OnStartup(sender, ev); }; //We can now actually start the background worker. bw.RunWorkerAsync(); // starts the background worker //And display the fancy little animated splashscreen IoC.Get <IWindowManager>().ShowWindow(vm); } catch (Exception ex) { m_log.Error(ex); } }