Exemple #1
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            LoggingService.Log("Meridian v" + Assembly.GetExecutingAssembly().GetName().Version + " started. OS: " + Environment.OSVersion);

            DispatcherHelper.Initialize();

            Settings.Load();

            if (Settings.Instance.SendStats)
            {
                YandexMetrica.Start(19168); //Yandex Metrica
            }

            System.Threading.Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo(Settings.Instance.Language);
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;

            if (Settings.Instance.Accounts.Count == 0)
            {
                Settings.Instance.Accounts.Add(new Account()
                {
                    Id = "vk", Title = MainResources.SettingsAccountsVk
                });
                Settings.Instance.Accounts.Add(new Account()
                {
                    Id = "lasfm", Title = MainResources.SettingsAccountsLastFm
                });
            }

            ServiceLocator.DataBaseService.Initialize();

            if (Settings.Instance.NeedClean)
            {
                ViewModelLocator.UpdateService.Clean();

                Settings.Instance.NeedClean = false;
            }

            switch (Settings.Instance.AccentColor)
            {
            case "Red":
            case "Emerald":
            case "Magenta":
            case "Mango":
            case "Sea":
            case "Sky":
            case "Purple":
            case "Pink":
                Resources.MergedDictionaries[0].Source = new Uri(string.Format("/Resources/Themes/Accents/{0}.xaml", Settings.Instance.AccentColor), UriKind.Relative);
                break;

            default:
                Resources.MergedDictionaries[0].Source = new Uri("/Resources/Themes/Accents/Blue.xaml", UriKind.Relative);
                break;
            }

            switch (Settings.Instance.Theme)
            {
            case "Light":
            case "Dark":
            case "Graphite":
            case "Accent":
                Resources.MergedDictionaries[1].Source = new Uri(string.Format("/Resources/Themes/{0}.xaml", Settings.Instance.Theme), UriKind.Relative);
                break;

            default:
                Resources.MergedDictionaries[1].Source = new Uri("/Resources/Themes/Light.xaml", UriKind.Relative);
                break;
            }

            if (Settings.Instance.CheckForUpdates)
            {
                ViewModelLocator.UpdateService.CheckUpdates();
            }

            if (Settings.Instance.EnableTrayIcon)
            {
                AddTrayIcon();
            }

            ViewModelLocator.Vkontakte.UseHttps = Settings.Instance.UseHttps;

            AudioService.Load();
        }