حصلت على كود لمواقيت الصلاة من الأنترنت ولكنى لا أعرف كيف أحصل على قيم الدوال فى label or textBox
الكود:
'--------------------- Copyright Block ----------------------
'
'
'PrayTime.cs: Prayer Times Calculator (ver 1.2)
'Copyright © 2007-2010 PrayTimes.org
'
'C# Code By: Jandost Khoso
'Original JS Code By: Hamid Zarrabi-Zadeh
'
'License: GNU LGPL v3.0
'
'TERMS OF USE:
' Permission is granted to use this code, with or
' without modification, in any website or application
' provided that credit is given to the original work
' with a link back to PrayTimes.org.
'
'This program is distributed in the hope that it will
'be useful, but WITHOUT ANY WARRANTY.
'
'PLEASE DO NOT REMOVE THIS COPYRIGHT BLOCK.
'
'
Public Class PrayTime
'------------------------ Constants --------------------------
' Calculation Methods
Public Shared Jafari As Integer = 0
' Ithna Ashari
Public Shared Karachi As Integer = 1
' University of Islamic Sciences, Karachi
Public Shared ISNA As Integer = 2
' Islamic Society of North America (ISNA)
Public Shared MWL As Integer = 3
' Muslim World League (MWL)
Public Shared Makkah As Integer = 4
' Umm al-Qura, Makkah
Public Shared Egypt As Integer = 5
' Egyptian General Authority of Survey
Public Shared [Custom] As Integer = 6
' Custom Setting
Public Shared Tehran As Integer = 7
' Institute of Geophysics, University of Tehran
' Juristic Methods
Public Shared Shafii As Integer = 0
' Shafii (standard)
Public Shared Hanafi As Integer = 1
' Hanafi
' Adjusting Methods for Higher Latitudes
Public Shared None As Integer = 0
' No adjustment
Public Shared MidNight As Integer = 1
' middle of night
Public Shared OneSeventh As Integer = 2
' 1/7th of night
Public Shared AngleBased As Integer = 3
' angle/60th of night
' Time Formats
Public Shared Time24 As Integer = 0
' 24-hour format
Public Shared Time12 As Integer = 1
' 12-hour format
Public Shared Time12NS As Integer = 2
' 12-hour format with no suffix
Public Shared Floating As Integer = 3
' floating point number
' Time Names
Public Shared timeNames As [string]() = {"Fajr", "Sunrise", "Dhuhr", "Asr", "Sunset", "Maghrib", _
"Isha"}
Shared InvalidTime As [string] = "----"
' The string used for inv
'---------------------- Global Variables --------------------
Private calcMethod As Integer = 3
' caculation method
Private asrJuristic As Integer
' Juristic method for Asr
Private dhuhrMinutes As Integer = 0
' minutes after mid-day for Dhuhr
Private adjustHighLats As Integer = 1
' adjusting method for higher latitudes
Private timeFormat As Integer = 0
' time format
Private lat As Double
' latitude
Private lng As Double
' longitude
Private timeZone As Integer
' time-zone
Private JDate As Double
' Julian date
Private times As Integer()
'--------------------- Technical Settings --------------------
Private numIterations As Integer = 1
' number of iterations needed to compute times
'------------------- Calc Method Parameters --------------------
Private methodParams As Double()()
Public Sub New()
times = New Integer(6) {}
methodParams = New Double(7)() {}
Me.methodParams(Jafari) = New Double() {16, 0, 4, 0, 14}
Me.methodParams(Karachi) = New Double() {18, 1, 0, 0, 18}
Me.methodParams(ISNA) = New Double() {15, 1, 0, 0, 15}
Me.methodParams(MWL) = New Double() {18, 1, 0, 0, 17}
Me.methodParams(Makkah) = New Double() {18.5, 1, 0, 1, 90}
Me.methodParams(Egypt) = New Double() {19.5, 1, 0, 0, 17.5}
Me.methodParams(Tehran) = New Double() {17.7, 0, 4.5, 0, 14}
Me.methodParams([Custom]) = New Double() {18, 1, 0, 0, 17}
End Sub
' return prayer times for a given date
Public Function getPrayerTimes(ByVal year As Integer, ByVal month As Integer, ByVal day As Integer, ByVal latitude As Double, ByVal longitude As Double, ByVal timeZone As Integer) As [string]()
Return Me.getDatePrayerTimes(year, month + 1, day, latitude, longitude, timeZone)
End Function
' set the calculation method
Public Sub setCalcMethod(ByVal methodID As Integer)
Me.calcMethod = methodID
End Sub
' set the juristic method for Asr
Public Sub setAsrMethod(ByVal methodID As Integer)
If methodID < 0 OrElse methodID > 1 Then
Return
End If
Me.asrJuristic = methodID
End Sub
' set the angle for calculating Fajr
Public Sub setFajrAngle(ByVal angle As Double)
Me.setCustomParams(New Integer() {CInt(Math.Truncate(angle)), -1, -1, -1, -1})
End Sub
' set the angle for calculating Maghrib
Public Sub setMaghribAngle(ByVal angle As Double)
Me.setCustomParams(New Integer() {-1, 0, CInt(Math.Truncate(angle)), -1, -1})
End Sub
' set the angle for calculating Isha
Public Sub setIshaAngle(ByVal angle As Double)
Me.setCustomParams(New Integer() {-1, -1, -1, 0, CInt(Math.Truncate(angle))})
End Sub
' set the minutes after mid-day for calculating Dhuhr
Public Sub setDhuhrMinutes(ByVal minutes As Integer)
Me.dhuhrMinutes = minutes
End Sub
' set the minutes after Sunset for calculating Maghrib
Public Sub setMaghribMinutes(ByVal minutes As Integer)
Me.setCustomParams(New Integer() {-1, 1, minutes, -1, -1})
End Sub
' set the minutes after Maghrib for calculating Isha
Public Sub setIshaMinutes(ByVal minutes As Integer)
Me.setCustomParams(New Integer() {-1, -1, -1, 1, minutes})
End Sub
' set custom values for calculation parameters
Public Sub setCustomParams(ByVal param As Integer())
For i As Integer = 0 To 4
If param(i) = -1 Then
Me.methodParams([Custom])(i) = Me.methodParams(Me.calcMethod)(i)
Else
Me.methodParams([Custom])(i) = param(i)
End If
Next
Me.calcMethod = [Custom]
End Sub
' set adjusting method for higher latitudes
Public Sub setHighLatsMethod(ByVal methodID As Integer)
Me.adjustHighLats = methodID
End Sub
' set the time format
Public Sub setTimeFormat(ByVal timeFormat As Integer)
Me.timeFormat = timeFormat
End Sub
' convert float hours to 24h format
Public Function floatToTime24(ByVal time As Double) As [string]
If time < 0 Then
Return InvalidTime
End If
time = Me.FixHour(time + 0.5 / 60)
' add 0.5 minutes to round
Dim hours As Double = Math.Floor(time)
Dim minutes As Double = Math.Floor((time - hours) * 60)
Return Me.twoDigitsFormat(CInt(Math.Truncate(hours))) & ":" & Me.twoDigitsFormat(CInt(Math.Truncate(minutes)))
End Function
' convert float hours to 12h format
Public Function floatToTime12(ByVal time As Double, ByVal noSuffix As Boolean) As [string]
If time < 0 Then
Return InvalidTime
End If
time = Me.FixHour(time + 0.5 / 60)
' add 0.5 minutes to round
Dim hours As Double = Math.Floor(time)
Dim minutes As Double = Math.Floor((time - hours) * 60)
Dim suffix As [string] = If(hours >= 12, " pm", " am")
hours = (hours + 12 - 1) Mod 12 + 1
Return CInt(Math.Truncate(hours)) & ":" & Me.twoDigitsFormat(CInt(Math.Truncate(minutes))) & (If(noSuffix, "", suffix))
End Function
' convert float hours to 12h format with no suffix
Public Function floatToTime12NS(ByVal time As Double) As [string]
Return Me.floatToTime12(time, True)
End Function
'---------------------- Compute Prayer Times -----------------------
' return prayer times for a given date
Public Function getDatePrayerTimes(ByVal year As Integer, ByVal month As Integer, ByVal day As Integer, ByVal latitude As Double, ByVal longitude As Double, ByVal timeZone As Integer) As [string]()
Me.lat = latitude
Me.lng = longitude
Me.timeZone = timeZone
Me.JDate = Me.JulianDate(year, month, day) - longitude / (15 * 24)
Return Me.computeDayTimes()
End Function
' compute declination angle of sun and equation of time
Public Function sunPosition(ByVal jd As Double) As Double()
Dim D__1 As Double = jd - 2451545.0
Dim g As Double = Me.FixAngle(357.529 + 0.98560028 * D__1)
Dim q As Double = Me.FixAngle(280.459 + 0.98564736 * D__1)
Dim L As Double = Me.FixAngle(q + 1.915 * Me.dsin(g) + 0.02 * Me.dsin(2 * g))
Dim R As Double = 1.00014 - 0.01671 * Me.dcos(g) - 0.00014 * Me.dcos(2 * g)
Dim e As Double = 23.439 - 0.00000036 * D__1
Dim d__2 As Double = Me.darcsin(Me.dsin(e) * Me.dsin(L))
Dim RA As Double = Me.darctan2(Me.dcos(e) * Me.dsin(L), Me.dcos(L)) / 15
RA = Me.FixHour(RA)
Dim EqT As Double = q / 15 - RA
Return New Double() {d__2, EqT}
End Function
' compute equation of time
Public Function equationOfTime(ByVal jd As Double) As Double
Return Me.sunPosition(jd)(1)
End Function
' compute declination angle of sun
Public Function sunDeclination(ByVal jd As Double) As Double
Return Me.sunPosition(jd)(0)
End Function
' compute mid-day (Dhuhr, Zawal) time
Public Function computeMidDay(ByVal t__1 As Double) As Double
Dim T__2 As Double = Me.equationOfTime(Me.JDate + t__1)
Dim Z As Double = Me.FixHour(12 - T__2)
Return Z
End Function
' compute time for a given angle G
Public Function computeTime(ByVal G As Double, ByVal t As Double) As Double
'System.out.println("G: "+G);
Dim D As Double = Me.sunDeclination(Me.JDate + t)
Dim Z As Double = Me.computeMidDay(t)
Dim V As Double = (CDbl(1) / 15) * Me.darccos((-Me.dsin(G) - Me.dsin(D) * Me.dsin(Me.lat)) / (Me.dcos(D) * Me.dcos(Me.lat)))
Return Z + (If(G > 90, -V, V))
End Function
' compute the time of Asr
Public Function computeAsr(ByVal [step] As Integer, ByVal t As Double) As Double
' Shafii: step=1, Hanafi: step=2
Dim D As Double = Me.sunDeclination(Me.JDate + t)
Dim G As Double = -Me.darccot([step] + Me.dtan(Math.Abs(Me.lat - D)))
Return Me.computeTime(G, t)
End Function
'---------------------- Compute Prayer Times -----------------------
' compute prayer times at given julian date
Public Function computeTimes(ByVal times As Double()) As Double()
Dim t As Double() = Me.dayPortion(times)
Dim Fajr As Double = Me.computeTime(180 - Me.methodParams(Me.calcMethod)(0), t(0))
Dim Sunrise As Double = Me.computeTime(180 - 0.833, t(1))
Dim Dhuhr As Double = Me.computeMidDay(t(2))
Dim Asr As Double = Me.computeAsr(1 + Me.asrJuristic, t(3))
Dim Sunset As Double = Me.computeTime(0.833, t(4))
Dim Maghrib As Double = Me.computeTime(Me.methodParams(Me.calcMethod)(2), t(5))
Dim Isha As Double = Me.computeTime(Me.methodParams(Me.calcMethod)(4), t(6))
Return New Double() {Fajr, Sunrise, Dhuhr, Asr, Sunset, Maghrib, Isha}
End Function
' adjust Fajr, Isha and Maghrib for locations in higher latitudes
Public Function adjustHighLatTimes(ByVal times As Double()) As Double()
Dim nightTime As Double = Me.GetTimeDifference(times(4), times(1))
' sunset to sunrise
' Adjust Fajr
Dim FajrDiff As Double = Me.nightPortion(Me.methodParams(Me.calcMethod)(0)) * nightTime
If Me.GetTimeDifference(times(0), times(1)) > FajrDiff Then
times(0) = times(1) - FajrDiff
End If
' Adjust Isha
Dim IshaAngle As Double = If((Me.methodParams(Me.calcMethod)(3) = 0), Me.methodParams(Me.calcMethod)(4), 18)
Dim IshaDiff As Double = Me.nightPortion(IshaAngle) * nightTime
If Me.GetTimeDifference(times(4), times(6)) > IshaDiff Then
times(6) = times(4) + IshaDiff
End If
' Adjust Maghrib
Dim MaghribAngle As Double = If((methodParams(Me.calcMethod)(1) = 0), Me.methodParams(Me.calcMethod)(2), 4)
Dim MaghribDiff As Double = Me.nightPortion(MaghribAngle) * nightTime
If Me.GetTimeDifference(times(4), times(5)) > MaghribDiff Then
times(5) = times(4) + MaghribDiff
End If
Return times
End Function
' the night portion used for adjusting times in higher latitudes
Public Function nightPortion(ByVal angle As Double) As Double
Dim val As Double = 0
If Me.adjustHighLats = AngleBased Then
val = 1.0 / 60.0 * angle
End If
If Me.adjustHighLats = MidNight Then
val = 1.0 / 2.0
End If
If Me.adjustHighLats = OneSeventh Then
val = 1.0 / 7.0
End If
Return val
End Function
Public Function dayPortion(ByVal times As Double()) As Double()
For i As Integer = 0 To times.Length - 1
times(i) /= 24
Next
Return times
End Function
' compute prayer times at given julian date
Public Function computeDayTimes() As [string]()
Dim times As Double() = {5, 6, 12, 13, 18, 18, _
18}
'default times
For i As Integer = 0 To Me.numIterations - 1
times = Me.computeTimes(times)
Next
times = Me.adjustTimes(times)
Return Me.adjustTimesFormat(times)
End Function
' adjust times in a prayer time array
Public Function adjustTimes(ByVal times As Double()) As Double()
For i As Integer = 0 To 6
times(i) += Me.timeZone - Me.lng / 15
Next
times(2) += Me.dhuhrMinutes \ 60
'Dhuhr
If Me.methodParams(Me.calcMethod)(1) = 1 Then
' Maghrib
times(5) = times(4) + Me.methodParams(Me.calcMethod)(2) / 60.0
End If
If Me.methodParams(Me.calcMethod)(3) = 1 Then
' Isha
times(6) = times(5) + Me.methodParams(Me.calcMethod)(4) / 60.0
End If
If Me.adjustHighLats <> None Then
times = Me.adjustHighLatTimes(times)
End If
Return times
End Function
Public Function adjustTimesFormat(ByVal times As Double()) As [string]()
Dim formatted As [string]() = New [string](times.Length - 1) {}
If Me.timeFormat = Floating Then
For i As Integer = 0 To times.Length - 1
formatted(i) = times(i) & ""
Next
Return formatted
End If
For i As Integer = 0 To 6
If Me.timeFormat = Time12 Then
formatted(i) = Me.floatToTime12(times(i), True)
ElseIf Me.timeFormat = Time12NS Then
formatted(i) = Me.floatToTime12NS(times(i))
Else
formatted(i) = Me.floatToTime24(times(i))
End If
Next
Return formatted
End Function
'---------------------- Misc Functions -----------------------
' compute the difference between two times
Public Function GetTimeDifference(ByVal c1 As Double, ByVal c2 As Double) As Double
Dim diff As Double = Me.FixHour(c2 - c1)
Return diff
End Function
' add a leading 0 if necessary
Public Function twoDigitsFormat(ByVal num As Integer) As [string]
Return If((num < 10), "0" & num, num & "")
End Function
'---------------------- Julian Date Functions -----------------------
' calculate julian date from a calendar date
Public Function JulianDate(ByVal year As Integer, ByVal month As Integer, ByVal day As Integer) As Double
If month <= 2 Then
year -= 1
month += 12
End If
Dim A As Double = CDbl(Math.Floor(year / 100.0))
Dim B As Double = 2 - A + Math.Floor(A / 4)
Dim JD As Double = Math.Floor(365.25 * (year + 4716)) + Math.Floor(30.6001 * (month + 1)) + day + B - 1524.5
Return JD
End Function
'---------------------- Time-Zone Functions -----------------------
' detect daylight saving in a given date
Public Function UseDayLightSaving(ByVal year As Integer, ByVal month As Integer, ByVal day As Integer) As Boolean
Return System.TimeZone.CurrentTimeZone.IsDaylightSavingTime(New DateTime(year, month, day))
End Function
' ---------------------- Trigonometric Functions -----------------------
' degree sin
Public Function dsin(ByVal d As Double) As Double
Return Math.Sin(Me.DegreeToRadian(d))
End Function
' degree cos
Public Function dcos(ByVal d As Double) As Double
Return Math.Cos(Me.DegreeToRadian(d))
End Function
' degree tan
Public Function dtan(ByVal d As Double) As Double
Return Math.Tan(Me.DegreeToRadian(d))
End Function
' degree arcsin
Public Function darcsin(ByVal x As Double) As Double
Return Me.RadianToDegree(Math.Asin(x))
End Function
' degree arccos
Public Function darccos(ByVal x As Double) As Double
Return Me.RadianToDegree(Math.Acos(x))
End Function
' degree arctan
Public Function darctan(ByVal x As Double) As Double
Return Me.RadianToDegree(Math.Atan(x))
End Function
' degree arctan2
Public Function darctan2(ByVal y As Double, ByVal x As Double) As Double
Return Me.RadianToDegree(Math.Atan2(y, x))
End Function
' degree arccot
Public Function darccot(ByVal x As Double) As Double
Return Me.RadianToDegree(Math.Atan(1 / x))
End Function
' Radian to Degree
Public Function RadianToDegree(ByVal radian As Double) As Double
Return (radian * 180.0) / Math.PI
End Function
' degree to radian
Public Function DegreeToRadian(ByVal degree As Double) As Double
Return (degree * Math.PI) / 180.0
End Function
Public Function FixAngle(ByVal angel As Double) As Double
angel = angel - 360.0 * (Math.Floor(angel / 360.0))
angel = If(angel < 0, angel + 360.0, angel)
Return angel
End Function
' range reduce hours to 0..23
Public Function FixHour(ByVal hour As Double) As Double
hour = hour - 24.0 * (Math.Floor(hour / 24.0))
hour = If(hour < 0, hour + 24.0, hour)
Return hour
End Function
Private Sub PrayTime_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim showPrayerTimes = times
Fajr_Label.Text = showPrayerTimes(0)
End Sub
End Class