public MainWindow() { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.Current.SessionEnding += Current_SessionEnding; //Commands ShowClickedCommand = new SimpleCommand <object, ShowTileViewModel>(OnShowViewClicked); IconClickedCommand = new SimpleCommand <object, object>(IconClicked); TerminateCommand = new SimpleCommand <object, object>(Terminate); //Settings & Theme _setti = Settings.Instance; _currentAccent = ThemeManager.GetAccent(_setti.ThemeAccent); _currentTheme = ThemeManager.GetAppTheme(_setti.ThemeBase); CurrentAccent = _setti.ThemeAccent; updateTimer = new Timer(); //Updater _updater = new UpdateWindow("http://dreamcooled.github.io/sjupdater/latest", true, "SjUpdater.exe", "-uf " + Stats.GetVersionString()); _updater.updateStartedEvent += (a, dsa) => { Terminate(null); Stats.TrackAction(Stats.TrackActivity.AppUpdate); }; //Start! InitializeComponent(); if (Environment.GetCommandLineArgs().Contains("-nogui")) { Hide(); } //Initialize view _viewModel = new MainWindowViewModel(_setti.TvShows); DataContext = _viewModel; //Enhance TreeView with Multiselection Extension //Note: We could also pass a observable collection to the first method, and get changes from the CollectionChanged Event on the observablecollection //But this way (custom event) we get less Events, which speeds up the GUI TreeViewExtensions.SetSelectedItems(ShowTreeView, _selectedEpisodeTreeItems); TreeViewExtensions.AddSelectionChangedListener(ShowTreeView, _selectedEpisodeTreeItems_CollectionChanged); SwitchPage(0); //Autoupdate timer if (_setti.UpdateTime > 0) //Autoupdate enabled { var t = new Timer(_setti.UpdateTime); t.Elapsed += t_Elapsed; t.Start(); } //Inital update Update(); //Stats Stats.StatsUrl = "http://sjupdater.batrick.de/stats"; Stats.AllowCustom = !_setti.NoPersonalData; Stats.TrackAction(Stats.TrackActivity.AppStart); Stats.TrackCustomVariable("Shows", _setti.TvShows.Select(s => s.Name)); if (_setti.CheckForUpdates) { _updater.Show(false, true); updateTimer = new Timer(1000 * 60 * 30); // 30 minutes updateTimer.Elapsed += (o, args) => Dispatcher.Invoke(() => _updater.Show(false, true)); updateTimer.Start(); } }