Пример #1
0
        public static AyaInfo GetNextAyaInfoFromCurrent(AyaInfo currentAyaInfo)
        {
            AyaInfo result = new AyaInfo();

            if (currentAyaInfo.suraNumber == 114 && currentAyaInfo.ayaNumber == 6)
            {
                result.suraNumber = currentAyaInfo.suraNumber;
                result.ayaNumber  = currentAyaInfo.ayaNumber;
            }
            else
            {
                if (currentAyaInfo.ayaNumber < QuranArrayHelper.suraNumAyas[currentAyaInfo.suraNumber - 1])
                {
                    result.suraNumber = currentAyaInfo.suraNumber;
                    result.ayaNumber  = currentAyaInfo.ayaNumber + 1;
                }
                else
                {
                    result.suraNumber = currentAyaInfo.suraNumber + 1;
                    result.ayaNumber  = 1;
                }
            }

            return(result);
        }
Пример #2
0
        public static string FileNameForAya(AyaInfo aya)
        {
            var suraStr = ThreeDigit(aya.suraNumber.ToString());
            var ayaStr  = ThreeDigit(aya.ayaNumber.ToString());

            return(string.Format("{0}{1}.mp3", suraStr, ayaStr));
        }
Пример #3
0
        public static AyaInfo GetPreviousAyaInfoFromCurrent(AyaInfo currentAyaInfo)
        {
            AyaInfo result = new AyaInfo();

            if (currentAyaInfo.suraNumber == 1 && currentAyaInfo.ayaNumber == 1)
            {
                result.suraNumber = currentAyaInfo.suraNumber;
                result.ayaNumber  = currentAyaInfo.ayaNumber;
            }
            else
            {
                if (currentAyaInfo.ayaNumber > 1)
                {
                    result.suraNumber = currentAyaInfo.suraNumber;
                    result.ayaNumber  = currentAyaInfo.ayaNumber - 1;
                }
                else
                {
                    result.suraNumber = currentAyaInfo.suraNumber - 1;
                    result.ayaNumber  = QuranArrayHelper.suraNumAyas[result.suraNumber - 1];
                }
            }

            return(result);
        }
Пример #4
0
        private int GetGapForAya(AyaInfo aya, DynamicGap dynamicGap, AyaInfo nextAya, bool isRevision)
        {
            var    currentAyaFile     = FullAyaFileName(FileNameForAya(aya));
            var    nextAyaFile        = FullAyaFileName(FileNameForAya(nextAya));
            var    currentAyaDuration = GetMediaDuration(currentAyaFile);
            var    nextAyaDuration    = GetMediaDuration(nextAyaFile);
            var    usedDuration       = isRevision ? nextAyaDuration : currentAyaDuration;
            double result;
            int    minGap = 1;

            switch (dynamicGap)
            {
            case DynamicGap.AyaDuration20Percent:
                result = usedDuration * 0.2f;
                break;

            case DynamicGap.AyaDuration40Percent:
                result = usedDuration * 0.4f;
                break;

            case DynamicGap.AyaDuration60Percent:
                result = usedDuration * 0.6f;
                break;

            case DynamicGap.AyaDuration80Percent:
                result = usedDuration * 0.8f;
                break;

            case DynamicGap.AyaDurationOne:
                result = usedDuration * 1f;
                break;

            case DynamicGap.AyaDuration120Percent:
                result = usedDuration * 1.2f;
                break;

            case DynamicGap.AyaDuration140Percent:
                result = usedDuration * 1.4f;
                break;

            case DynamicGap.AyaDuration160Percent:
                result = usedDuration * 1.6f;
                break;

            case DynamicGap.AyaDuration200Percent:
                result = usedDuration * 2f;
                break;

            case DynamicGap.NoGap:
            default:
                result = 0;
                minGap = 0;
                break;
            }

            return(Math.Max(minGap, (int)(result + 0.5)));
        }
Пример #5
0
        private void DownloadAyaIfNeeded(AyaInfo ayaInfo)
        {
            var ayaLocalFile = FullAyaFileName(FileNameForAya(ayaInfo));

            if (File.Exists(ayaLocalFile))
            {
                return;
            }

            using (var client = new WebClient())
            {
                downloadCompleted = false;
                client.DownloadProgressChanged += Client_DownloadProgressChanged;
                client.DownloadFileCompleted   += Client_DownloadFileCompleted;
                client.DownloadFileAsync(new Uri(RecitersUtility.GetURLForAyah(reciter, ayaInfo.suraNumber, ayaInfo.ayaNumber)), ayaLocalFile);
                while (downloadCompleted == false && Processing)
                {
                    Application.DoEvents();
                }
            }
        }
Пример #6
0
        static List <AyaInfo> GetRangeAyaList(AyaRange ayaRange)
        {
            var result      = new List <AyaInfo>();
            var currentSura = ayaRange.startAyaInfo.suraNumber;
            var currentAya  = ayaRange.startAyaInfo.ayaNumber;

            do
            {
                result.Add(AyaInfo.Create(currentSura, currentAya));

                if (currentAya < QuranArrayHelper.suraNumAyas[currentSura - 1])
                {
                    currentAya++;
                }
                else
                {
                    currentSura++;
                    currentAya = 1;
                }
            } while (AyaUtil.AyaTotalRank(AyaInfo.Create(currentSura, currentAya)) <= AyaUtil.AyaTotalRank(ayaRange.endAyaInfo));

            return(result);
        }
Пример #7
0
 public static AyaInfo MaximumAyaRange(AyaInfo ayaInfo1, AyaInfo ayaInfo2)
 {
     return(AyaTotalRank(ayaInfo1) > AyaTotalRank(ayaInfo2) ? ayaInfo1 : ayaInfo2);
 }
Пример #8
0
 public static int AyaTotalRank(AyaInfo info)
 {
     return((info.suraNumber * 1000) + info.ayaNumber);
 }
 public bool EqualsAya(AyaInfo info)
 {
     return(info.ayaNumber == ayaNumber && info.suraNumber == suraNumber);
 }