public static bool InstallDictionary(string filePath)
        {
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            HaveInstalledEnum?entity = null;

            switch (fileName)
            {
            case "Life More Abundant – Interpreting Bible Prophecy":
                entity = HaveInstalledEnum.LifeMoreAbundant;

                break;

            default: return(false);
            }

            DownloadedDictionaryLoader.InsertDictionary(entity.Value, filePath);

            return(true);
        }
示例#2
0
        private bool TryDownload()
        {
            try
            {
                bool openDirectory = false;

                bool restart = false;

                string basePath = Paths.KnownFolder(KnownFolders.KnownFolder.Downloads);

                using (DownloadWebClient client = new DownloadWebClient())
                {
                    client.UseDefaultCredentials = false;

                    foreach (RepositoryContent repository in this.GetSelectedRepositories())
                    {
                        string fullName = Path.Combine(basePath, repository.Name);

                        client.DownloadFile(repository.DownloadUrl, fullName);

                        if (repository.Path.StartsWith("Bibles/"))
                        {
                            restart = true;

                            if (DownloadedBibleLoader.LoadBible(fullName))
                            {
                                File.Delete(fullName);
                            }
                        }
                        else if (repository.Path.StartsWith("Translations/"))
                        {
                            restart = true;

                            if (LoadTranslations.LoadFile(fullName))
                            {
                                File.Delete(fullName);
                            }
                        }
                        else if (repository.Path.StartsWith("Studies/"))
                        {
                            ImportBibleStudy studyImport = new ImportBibleStudy();

                            if (studyImport.ImportStudy(fullName))
                            {
                                File.Delete(fullName);
                            }
                        }
                        else if (repository.Path.StartsWith("Concordances/"))
                        {
                            ImportConcordance concordance = new ImportConcordance();

                            if (concordance.Import(fullName))
                            {
                                File.Delete(fullName);
                            }
                        }
                        else if (repository.Path.StartsWith("Dictionaries/"))
                        {
                            if (DownloadedDictionaryLoader.InstallDictionary(fullName))
                            {
                                File.Delete(fullName);

                                restart = true;
                            }
                        }
                        else
                        {
                            openDirectory = true;
                        }
                    }
                }

                if (openDirectory)
                {
                    Process.Start(basePath);
                }

                if (restart)
                {
                    string message = "Bibles need to restart. Would you like to restart now?";

                    if (MessageDisplay.Show(message, "Restart", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
                    {
                        return(true);
                    }

                    ProcessStartInfo Info = new ProcessStartInfo();

                    Info.Arguments = "/C choice /C Y /N /D Y /T 1 & START \"\" \"" + Assembly.GetEntryAssembly().Location + "\"";

                    Info.WindowStyle = ProcessWindowStyle.Hidden;

                    Info.CreateNoWindow = true;

                    Info.FileName = "cmd.exe";

                    Process.Start(Info);

                    Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception err)
            {
                this.Dispatcher.Invoke(() =>
                {
                    ErrorLog.ShowError(err);
                });

                return(false);
            }

            return(true);
        }