AyahIncrementer.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. using System;
  5. using System.Collections;
  6. namespace QuranCalc
  7. {
  8. public class AyahIncrementer
  9. {
  10. public static bool Finished = false;
  11. private ArrayList list = new ArrayList(0);
  12. private string[] array {
  13. get {
  14. try
  15. {
  16. return Array.ConvertAll<object, string> (list.ToArray (), a => (string)a);
  17. }
  18. catch(Exception e) {
  19. Traceback.Write ("At string[] array (class AyahIncrementer):");
  20. throw e;
  21. }
  22. }
  23. }
  24. public static int[] AyahCounts = new int[] { 7, 286, 200, 176, 120, 165, 206, 75, 129, 109, 123, 111, 43, 52, 99, 128, 111, 110, 98, 135, 112, 78, 118, 64, 77, 227, 93, 88, 69, 60, 34, 30, 73, 54, 45, 83, 182, 88, 75, 85, 54, 53, 89, 59, 37, 35, 38, 29, 18, 45, 60, 49, 62, 55, 78, 96, 29, 22, 24, 13, 14, 11, 11, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56, 40, 31, 50, 40, 46, 42, 29, 19, 36, 25, 22, 17, 19, 26, 30, 20, 15, 21, 11, 8, 8, 19, 5, 8, 8, 11, 11, 8, 3, 9, 5, 4, 7, 3, 6, 3, 5, 4, 5, 6 };
  25. public AyahIncrementer ()
  26. {
  27. try
  28. {
  29. for (int i = 0; i < 114; i++) {
  30. for (int j = 1; j <= AyahCounts[i]; j++) {
  31. list.Add (MainClass.SurahNames[i] + " " + j);
  32. }
  33. }
  34. }
  35. catch(Exception e) {
  36. Traceback.Write ("At AyahIncrementer() (class AyahIncrementer):");
  37. throw e;
  38. }
  39. }
  40. private int AyahNumber = 0;
  41. public void Increment(int value)
  42. {
  43. try
  44. {
  45. if(AyahNumber + value > 6235)
  46. Finished = true;
  47. AyahNumber = (AyahNumber + value) % 6236;
  48. return;
  49. }
  50. catch(Exception e) {
  51. Traceback.Write ("At void Increment(int) (class AyahIncrementer):");
  52. throw e;
  53. }
  54. }
  55. public string LastAyah {
  56. get {
  57. try
  58. {
  59. return array [AyahNumber - 1];
  60. }
  61. catch(Exception e) {
  62. Traceback.Write ("At string LastAyah (class AyahIncrementer)");
  63. throw e;
  64. }
  65. }
  66. }
  67. public string NextAyah {
  68. get {
  69. try
  70. {
  71. return array [AyahNumber];
  72. }
  73. catch(Exception e) {
  74. Traceback.Write ("At string NextAyah (class AyahIncrementer)");
  75. throw e;
  76. }
  77. }
  78. }
  79. }
  80. }