private void Window_Closed(object sender, EventArgs e)
 {
     //In the case the user has a schedule with Spotify events, lost connection and just reconnected using the Options window,
     //Reinitialize the SpotifyEventTimer. Call this function on all close events, even if the user click cancel or the X button.
     //Initialize also stops the timer if there is no connection, in case the user just disconnected.
     SpotifyEventTimer.Initialize();
 }
Beispiel #2
0
        public static void NormalStartup(StartupEventArgs startupEventArgs)
        {
            var silent = false;

            if (startupEventArgs != null && startupEventArgs.Args.Length > 0)
            {
                silent = startupEventArgs.Args[0].Equals("-s");
            }

            try
            {
                UserSettings.LoadSettings();
            }
            catch (SettingsFileJsonException ex)
            {
                _logger.Fatal("Corrupt settings file found", ex);
                PopupCreator.Error(string.Format(AppResources.CorruptSettings, UserSettings.SettingsFolder + "Settings.json"));
                return;
            }

            if (!string.IsNullOrEmpty(UserSettings.Settings.UserLocale))
            {
                Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo(UserSettings.Settings.UserLocale);
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(UserSettings.Settings.UserLocale);
            }

            UserSettings.Settings.ResetOperationModes();

            SunTimesUpdater.UpdateSunTimes();

            OrchestratorCollection.Initialize();

            SpotifyEventTimer.Initialize();

            var mainWindow = new MainWindow();

            if (!silent)
            {
                mainWindow.Show();
            }

            mainWindow.Initialize();

            CheckForUpdate();
        }