Exemple #1
0
        /// <summary>
        /// Creates Quran DB directory.
        /// </summary>
        /// <returns></returns>
        public static async Task MakeQuranDatabaseDirectory()
        {
            if (BaseFolder == null)
            {
                throw new ArgumentNullException("BaseFolder");
            }

            if (DatabaseFolder == null)
            {
                var databaseFolder = await BaseFolder.TryGetItemAsync(DatabaseDirectory);

                if (databaseFolder == null)
                {
                    databaseFolder = await BaseFolder.CreateFolderAsync(DatabaseDirectory);
                }
                DatabaseFolder = databaseFolder as StorageFolder;
            }

            if (DatabaseFolder == null)
            {
                throw new InvalidOperationException("Unable to create a database folder.");
            }

            StorageFolder installationFolder = Package.Current.InstalledLocation;
            StorageFolder assetsFolder       = await installationFolder.GetFolderAsync("Assets");

            StorageFile arabicDatabase = await assetsFolder.GetFileAsync(QuranDatabaseName);

            await arabicDatabase.CopyAsync(DatabaseFolder, QuranDatabaseName, NameCollisionOption.ReplaceExisting);

            ArabicDatabase = await DatabaseFolder.GetFileAsync(QuranDatabaseName);
        }
Exemple #2
0
        /// <summary>
        /// Creates Quran root directory.
        /// </summary>
        /// <returns></returns>
        public async static Task MakeQuranDirectory(ScreenInfo qsi)
        {
            if (qsi == null)
            {
                throw new ArgumentNullException(nameof(qsi));
            }

            if (BaseFolder == null)
            {
                BaseFolder = ApplicationData.Current.LocalFolder;
                var quranBaseFolder = await BaseFolder.TryGetItemAsync(QuranBase);

                if (quranBaseFolder == null)
                {
                    quranBaseFolder = await BaseFolder.CreateFolderAsync(QuranBase);
                }
                BaseFolder = quranBaseFolder as StorageFolder;
            }

            if (BaseFolder == null)
            {
                throw new InvalidOperationException("Unable to create a base folder.");
            }

            if (ImageFolder == null)
            {
                var imageFolderName = "width" + qsi.GetWidthParam();
                var quranBaseFolder = await BaseFolder.TryGetItemAsync(imageFolderName);

                if (quranBaseFolder == null)
                {
                    quranBaseFolder = await BaseFolder.CreateFolderAsync(imageFolderName);
                }
                ImageFolder = quranBaseFolder as StorageFolder;
            }

            if (ImageFolder == null)
            {
                throw new InvalidOperationException("Unable to create a base image folder.");
            }
        }