private void button1_Click(object sender, EventArgs e) { GPLocation loc; content.findLocations("Bratislava"); loc = content.getLocation(0); GPLocationProvider provider = new GPLocationProvider(loc); int nCount = 365; GPGregorianTime startDateA = new GPGregorianTime(loc); GPCalendarResults calA = new GPCalendarResults(); GPCalendarResults calB = new GPCalendarResults(); calA.progressReport = this; calB.progressReport = this; if (startDateA != null) { GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOR; calA.CalculateCalendar(startDateA, nCount); GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOREX; calB.CalculateCalendar(startDateA, nCount); } GPSun.sunPosMethod = GPSun.SUNPOSMETHOD_CALCULATOR; StringBuilder sb = new StringBuilder(); GPCalendarTwoLocResults cals = new GPCalendarTwoLocResults(); cals.CalendarA = calA; cals.CalendarB = calB; FormaterHtml.WriteCompareCalendarHTML(cals, sb); string HtmlText = sb.ToString(); webBrowser1.DocumentText = HtmlText; GPObserver obs = new GPObserver(); obs = loc; GPStrings.pushRich(false); StringBuilder sba = new StringBuilder(); GPJulianTime sunRise, sunNoon, sunSet; for (int i = 0; i < calA.getCount(); i++) { GPCalendarDay cd = calA.get(i); GPCalendarDay cd2 = calB.get(i); GPAstroEngine.CalculateTimeSun(cd.date, loc, out sunRise, out sunNoon, out sunSet); GPGregorianTime gt = new GPGregorianTime(loc); GPCelestialBodyCoordinates pos = GPAstroEngine.sun_coordinate(GPDynamicTime.getUniversalTimeFromDynamicTime(2457012.82313)); GPAstroEngine.calcHorizontal(pos, loc); sunRise.setLocalTimezoneOffset(loc.getTimeZoneOffsetHours()); sba.AppendFormat("{0} {1} {2} \n", cd.date.ToString(), cd.getSunriseTime().getLongTimeString(), cd2.getSunriseTime().getLongTimeString()); gt.setDate(1992, 10, 13); //cd.astrodata.sun.calculateCoordinatesMethodM(gt, 360/24.0); } GPStrings.popRich(); richTextBox1.Text = sba.ToString(); GPGregorianTime t1 = new GPGregorianTime(loc); t1.setDate(2015, 4, 4); double jd = t1.getJulianLocalNoon(); sba.Clear(); for (double d = 0.3; d < 1.0; d += 0.01) { double ml = GPAstroEngine.moon_coordinate(jd + d).eclipticalLongitude; double sl1 = GPAstroEngine.sun_coordinate(jd + d).eclipticalLongitude; double sl2 = GPAstroEngine.sunLongitudeMethodM(jd + d); sba.AppendFormat("{0} : {1} {2} {3}\n", jd + d, ml, sl1, sl2); } richTextBox2.Text = sba.ToString(); }
protected override void Execute() { loc = GPAppHelper.getMyLocation(); //Testing.Report(loc, "gcal13"); //loc1.setLatitudeNorthPositive(48.16); //loc1.setLongitudeEastPositive(17.09); //loc1.setTimeZoneName("Europe/Bratislava"); p_today = new GPGregorianTime(loc); p_today.Today(); /* * Debugger.Log(0,"", String.Format("Location: {0} {1} {2}\n", loc.getFullName(), loc1.getLongitudeString(), loc1.getLatitudeString())); * * double date = p_today.getJulianLocalNoon(); * TEclipse te; * for (int i = 0; i < 30; i++) * { * te = MA.Engine.NextEclipse(ref date, true); * int y, m, d; * MA.Engine.DecodeDateCorrect(date, out y, out m, out d); * Debugger.Log(0, "", String.Format("eclipse:{0} date: {1} {2} {3}\n", te, y, m, d)); * date += 20; * } * * //double a1 = MA.GPMeeusEngine.star_time(2456708.3200) ; * //a1 = MA.GPMeeusEngine.star_time(2452083) - a1; * * * double lat1 = 48.16, lat2 = 120; * double lon1 = 17.09, lon2 = 123; * double dStart = 0.287399999999998; * double dEnd = 0.287799999999998; * GPObserver obs = new GPObserver(); * obs.setLatitudeNorthPositive(lat1).setLongitudeEastPositive(lon1).SetAltitude(0.2); * * GPJulianTime rise, trans, set; * * * GPJulianTime time = new GPJulianTime(); * * time.setLocalJulianDay(2456708.5); * time.setLocalTimezoneOffset(1); * for (int l = 0; l < 40; l++) * { * Log("Julian {0} = {1} / {2} / {3} {4}:{5}:{6}\n", time.GetJulianDay(), time.GetYear(), * time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond()); * time.AddSeconds(79367.6); * } * * //GPGregorianTime gt = new GPGregorianTime(loc); * //gt.setJulianGreenwichTime(time); * //double rise = MA.GPMeeusEngine.Sun_Rise(p_today.GetJulianDetailed() - 0.5, loc.Latitude, -loc.Longitude); * //GPAstroEngine.CalculateTimeSun(gt, obs, out rise, out trans, out set); * * //Log("Rise: {0}, \nTrans:{1}, \nSet:{2}", rise, trans, set); * * //MA.Testing.TestSunCoordinates(); * //MA.Testing.TestSiderealTime(); * //MA.Testing.TestMoonEvents(); * * //GPSun sun = new GPSun(); * //sun.SunCalc(p_today, loc); * TRiseSet kind; * double deltaphi, epsilon, srt; * GPJulianTime dp = new GPJulianTime(); * dp.setLocalJulianDay(2456710.500000); * * obs.setLongitudeEastPositive(-25.858).setLatitudeNorthPositive(-23.983); * srt = 2452081.000000; * * //MA.Testing.TestMoonEclipse(); * * Testing.TestConjunctions(); * * //MA.GPCelestialBodyCoordinates coord = MA.GPMeeusEngine.moon_coordinate(2448724.5); * //double phi, eps; * //MA.GPMeeusEngine.calc_epsilon_phi(2446895.5, out phi, out eps); * //Log("Sidereal time: {0}", MA.GPMeeusEngine.star_time(2446895.5)); * //Log("Epsilon: {0}, phi: {1}", eps, phi); * //Log("Sunrise {0}", sun.rise.LongTimeString); * * return; */ int maxCount = GPUserDefaults.IntForKey("nextfest.days", 16); if (maxCount < 3) { maxCount = 16; GPUserDefaults.SetIntForKey("nextfest.days", maxCount); } bool onlyFast = GPUserDefaults.BoolForKey("nextfest.onlyfast", true); p_cal.CalculateCalendar(p_today, maxCount); List <string> temp = new List <string>(); for (int i = 0; i < p_cal.getCount(); i++) { temp.Clear(); GPCalendarDay vd = p_cal.get(i); if (onlyFast) { if (vd.sEkadasiVrataName.Length > 0) { temp.Add(string.Format(GPStrings.getString(87), vd.sEkadasiVrataName)); } else if (vd.hasEkadasiParana()) { temp.Add(vd.getEkadasiParanaString()); } } else { if (vd.hasEkadasiParana()) { temp.Add(vd.getEkadasiParanaString()); } foreach (GPCalendarDay.Festival fest in vd.Festivals) { if (GPUserDefaults.BoolForKey(fest.ShowSettingItem, true)) { temp.Add(fest.Text); } } } if (temp.Count > 0) { for (int j = 0; j < temp.Count; j++) { GPStringPair dr = new GPStringPair(); if (j == 0) { dr.Name = vd.date.ToString() + " " + GPStrings.getString(150 + vd.date.getDayOfWeek()); } dr.Value = temp[j]; lines.Add(dr); } } } }
public static int FormatCalendarPlusCorePlain(GPCalendarPlusEventsResults calev, StringBuilder fout) { GPCalendarResults daybuff = calev.theCalendar; GPCoreEventResults events = calev.theEvents; //List<string> gstr = GPStrings.getSharedStrings().gstr; int k; string str; GPGregorianTime date = new GPGregorianTime(daybuff.CurrentLocation); GPCalendarDay pvd; GPCalendarDay prevd; GPCalendarDay nextd; int nPrevMasa = -1; int nPrevMonth = -1; if (events.b_sorted == false) { events.Sort(true); } StringBuilder lineA = new StringBuilder(); StringBuilder lineB = new StringBuilder(); for (k = 0; k < daybuff.getCount(); k++) { prevd = daybuff.get(k - 1); pvd = daybuff.get(k); nextd = daybuff.get(k + 1); if (pvd != null) { bool writeHeaders = false; if (nPrevMasa != pvd.astrodata.nMasa && GPDisplays.Calendar.MasaHeader()) { str = string.Format("{0} {1}", pvd.getMasaLongName(), ((nPrevMasa == GPMasa.ADHIKA_MASA) ? GPStrings.getString(109) : "")); fout.AppendLine(GPAppHelper.CenterString(str, 80)); fout.AppendLine(GPAppHelper.CenterString(pvd.getGaurabdaYearLongString(), 80)); fout.AppendLine(GPAppHelper.CenterString(pvd.date.getLocation().getFullName(), 80)); fout.AppendLine(GPAppHelper.CenterString(string.Format("{0}: {1}", GPStrings.getString(12), pvd.date.getLocation().getTimeZone().getFullName()), 80)); fout.AppendLine(); nPrevMasa = pvd.astrodata.nMasa; writeHeaders = true; } else if (nPrevMonth != pvd.date.getMonth() && GPDisplays.Calendar.MonthHeader()) { fout.AppendLine(GPAppHelper.CenterString(string.Format("{0} {1}", GPStrings.getString(759 + pvd.date.getMonth()), pvd.date.getYear()), 80)); fout.AppendLine(GPAppHelper.CenterString(pvd.date.getLocation().getFullName(), 80)); fout.AppendLine(GPAppHelper.CenterString(string.Format("{0}: {1}", GPStrings.getString(12), pvd.date.getLocation().getTimeZone().getFullName()), 80)); fout.AppendLine(); nPrevMonth = pvd.date.getMonth(); writeHeaders = true; } if (writeHeaders) { int len = fout.Length; fout.Append(" "); fout.Append(GPStrings.getString(985).PadRight(16)); fout.Append(GPStrings.getString(986).ToUpper().PadRight(30)); if (GPDisplays.Calendar.PaksaInfoVisible()) { fout.Append(GPStrings.getString(20).ToUpper().PadRight(6)); } else { fout.Append(string.Empty.PadRight(6)); } if (GPDisplays.Calendar.YogaVisible()) { fout.Append(GPStrings.getString(104).ToUpper().PadRight(10)); } if (GPDisplays.Calendar.NaksatraVisible()) { fout.Append(GPStrings.getString(15).ToUpper().PadRight(15)); } if (GPDisplays.Calendar.FastingFlagVisible()) { fout.Append(GPStrings.getString(987).ToUpper().PadRight(5)); } if (GPDisplays.Calendar.RasiVisible()) { fout.Append(GPStrings.getString(105).ToUpper().PadRight(15)); } fout.AppendLine(); len = fout.Length - len; fout.AppendLine(string.Empty.PadLeft(len, '-')); } AvcGetOldCalendarDayText(pvd, fout, prevd, nextd); fout.AppendLine(); lineA.Remove(0, lineA.Length); lineB.Remove(0, lineB.Length); List <GPStringPair> recs = events.ExtractRecordsForDate(pvd.date); foreach (GPStringPair rec in recs) { lineA.Append(rec.Name); lineB.Append(rec.Value); int tosize = Math.Max(lineA.Length, lineB.Length) + 2; while (lineA.Length < tosize) { lineA.Append(' '); } while (lineB.Length < tosize) { lineB.Append(' '); } } fout.Append(string.Empty.PadLeft(17, ' ')); fout.AppendLine(lineA.ToString()); fout.Append(string.Empty.PadLeft(17, ' ')); fout.AppendLine(lineB.ToString()); fout.AppendLine(); } date.setDayHours(0.0); date.NextDay(); } return(1); }