public MainWindow() { Instance = this; InitializeComponent(); _helper = ServiceProvider.Get <MainWindowHelper>(); _helper.MainViewModel.Init(!App.CmdOptions.NoPersist, !App.CmdOptions.Reset); _helper.HotkeySetup.Setup(); _helper.TimerModel.Init(); Loaded += (Sender, Args) => { RepositionWindowIfOutside(); ServiceProvider.Get <WebcamPage>().SetupPreview(); _helper.HotkeySetup.ShowUnregistered(); }; if (App.CmdOptions.Tray || _helper.Settings.Tray.MinToTrayOnStartup) { Hide(); } Closing += (Sender, Args) => { if (!TryExit()) { Args.Cancel = true; } }; // Register to bring this instance to foreground when other instances are launched. SingleInstanceManager.StartListening(WakeApp); }