Beispiel #1
0
 public GPCalendarDay GetDayWithOffset(int i)
 {
     if (resultCalendar != null && indexInArray >= 0)
     {
         return(resultCalendar.get(indexInArray + i));
     }
     return(null);
 }
Beispiel #2
0
        public static void FormatTodayInfoRtf(GPGregorianTime vc, GPLocationProvider loc, StringBuilder str)
        {
            string str2, str3 = string.Empty;

            GPCalendarResults db = new GPCalendarResults();

            GPGregorianTime vc2 = new GPGregorianTime(vc);

            vc2.PreviousDay();
            vc2.PreviousDay();
            vc2.PreviousDay();
            vc2.PreviousDay();
            db.CalculateCalendar(vc2, 9);

            int           i = db.FindDate(vc);
            GPCalendarDay p = db.get(i);

            if (p == null)
            {
                return;
            }

            str.Remove(0, str.Length);
            AppendRtfHeader(str);
            str2 = string.Format("\\f2\\fs{0} {1} ", g_HeaderSize, GPAppHelper.getDateText(vc));
            str.Append(str2);

            str.AppendFormat("\\par\\f2\\fs{0} {{\\fs{1} {2}}\\line {3} ({4}, {5}, {6}: {7})",
                             g_TextSize, g_TextSize + 4, getSharedStringRtf(p.date.getDayOfWeek()), loc.getFullName(), loc.getLocation(0).getLatitudeString(),
                             loc.getLocation(0).getLongitudeString(), getSharedStringRtf(12),
                             loc.getLocation(0).getTimeZoneName());
            str.AppendLine("\\par");
            str.AppendLine("\\par");
            str.AppendFormat("  {0}, {1}", p.getTithiName(), p.getPaksaName());
            str.AppendLine("\\par");
            str.AppendFormat("  {0}, {1}", p.getMasaLongName(), p.getGaurabdaYearLongString());
            str.AppendLine("\\par");
            str.AppendLine("\\par");


            // adding mahadvadasi
            // adding spec festivals

            foreach (GPCalendarDay.Festival fest in p.CompleteFestivalList(db.get(i - 1), db.get(i + 1)))
            {
                if (GPUserDefaults.BoolForKey(fest.ShowSettingItem, true))
                {
                    if (fest.ShowSettingItem == GPDisplays.Keys.CalendarSankranti)
                    {
                        str.AppendLine(fest.Text.PadLeft((80 + str2.Length) / 2, '-').PadRight(80, '-'));
                        str.AppendLine("\\par");
                    }
                    else
                    {
                        str.Append("\\tab");
                        str.Append(fest.Text);
                        str.AppendLine("\\par");
                    }
                }
            }

            str.AppendLine("\\par");


            if (GPDisplays.Today.BrahmaMuhurtaVisible())
            {
                str.AppendLine("\\par");
                str.AppendFormat("{0} {1}", getSharedStringRtf(988), p.astrodata.sun.arunodaya.getShortMuhurtaRange(0));
            }

            if (GPDisplays.Today.SunriseVisible())
            {
                str.AppendLine("\\par");
                str.AppendFormat("{0} {1} ", getSharedStringRtf(51), p.astrodata.sun.rise.getShortTimeString());
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1} ", getSharedStringRtf(989), p.astrodata.sun.rise.getShortSandhyaRange());
                }
                str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.AppendLine("\\par");
            }
            if (GPDisplays.Today.NoonVisible())
            {
                str2 = string.Format("{0} {1} ", getSharedStringRtf(857), p.astrodata.sun.noon.getShortTimeString());
                str.Append(str2);
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1} ", getSharedStringRtf(989), p.astrodata.sun.noon.getShortSandhyaRange());
                }
                str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.AppendLine("\\par");
            }
            if (GPDisplays.Today.SunsetVisible())
            {
                str.AppendFormat("{0}  {1} ", getSharedStringRtf(52), p.astrodata.sun.set.getShortTimeString());
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1} ", getSharedStringRtf(989), p.astrodata.sun.set.getShortSandhyaRange());
                }
                str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.AppendLine("\\par");
            }
            if (GPDisplays.Today.SunriseInfo())
            {
                str.AppendLine("\\par");
                str.Append(getSharedStringRtf(990));
                str.AppendLine("\\par");
                str.AppendFormat("   {1} {2}", GPNaksatra.getName(p.astrodata.nNaksatra), getSharedStringRtf(15));
                if (GPDisplays.Today.NaksatraPadaVisible())
                {
                    str.AppendFormat(", {0} {1} ({2})", p.astrodata.nNaksatraElapse, getSharedStringRtf(993), getSharedStringRtf(811 + p.getNaksatraPada()));
                }
                if (GPDisplays.Today.RasiOfMoonVisible())
                {
                    str.AppendFormat(", {0}: {1}", getSharedStringRtf(991), GPSankranti.getName(p.astrodata.nMoonRasi));
                }
                str.AppendFormat(", {0} {1}", GPYoga.getName(p.astrodata.nYoga), getSharedStringRtf(104));
                str.AppendLine("\\par");
                str.AppendFormat("  {0} {1}", getSharedStringRtf(992), GPSankranti.getName(p.astrodata.nSunRasi));
                str.AppendLine("\\par");
            }
            /* END GCAL 1.4.3 */

            AddNoteRtf(str);
        }
Beispiel #3
0
        public static int FormatCalendarRtf(GPCalendarResults daybuff, StringBuilder m_text)
        {
            int           k;
            int           bShowColumnHeaders = 0;
            String        str;
            StringBuilder dayText = new StringBuilder();

            GPCalendarDay pvd, prevd, nextd;
            int           lastmasa  = -1;
            int           lastmonth = -1;
            bool          bCalcMoon = GPDisplays.Calendar.TimeMoonriseVisible() || GPDisplays.Calendar.TimeMoonsetVisible();

            m_text.Remove(0, m_text.Length);

            AppendRtfHeader(m_text);

            for (k = 0; k < daybuff.m_vcCount; k++)
            {
                prevd = daybuff.get(k - 1);
                pvd   = daybuff.get(k);
                nextd = daybuff.get(k + 1);

                if (pvd != null)
                {
                    bShowColumnHeaders = 0;
                    if (GPDisplays.Calendar.MasaHeader() && (pvd.astrodata.nMasa != lastmasa))
                    {
                        if (bShowColumnHeaders == 0)
                        {
                            m_text.Append("\\par ");
                        }
                        bShowColumnHeaders = 1;
                        //				m_text.Append("\\par\r\n";
                        str = string.Format("\\par \\pard\\f2\\fs{0}\\qc {1}, {2}", g_Header2Size, pvd.getMasaLongName(), pvd.getGaurabdaYearLongString());
                        if ((pvd.astrodata.nMasa == GPMasa.ADHIKA_MASA) && ((lastmasa >= GPMasa.SRIDHARA_MASA) && (lastmasa <= GPMasa.DAMODARA_MASA)))
                        {
                            str += "\\line ";
                            str += getSharedStringRtf(128);
                        }
                        m_text.Append(str);
                        lastmasa = pvd.astrodata.nMasa;
                    }

                    if (GPDisplays.Calendar.MonthHeader() && (pvd.date.getMonth() != lastmonth))
                    {
                        if (bShowColumnHeaders == 0)
                        {
                            m_text.Append("\\par ");
                        }
                        bShowColumnHeaders = 1;
                        m_text.AppendFormat("\\par\\pard\\f2\\qc\\fs{0}\r\n", g_Header2Size);
                        m_text.AppendFormat("{0} {1}", getSharedStringRtf(759 + pvd.date.getMonth()), pvd.date.getYear());
                        lastmonth = pvd.date.getMonth();
                    }

                    if (pvd.Travelling != null)
                    {
                        m_text.AppendFormat("\\par\\pard\\f2\\qc\\fs{0}\r\n", g_Header2Size);
                        m_text.AppendFormat("{0}", getSharedStringRtf(1030));
                        GPLocationChange lastLocChange = null;
                        foreach (GPLocationChange lc in pvd.Travelling)
                        {
                            if (lastLocChange != lc)
                            {
                                m_text.Append("\\par\\pard\\qc\\cf2\\fs22 ");
                                m_text.AppendFormat("{0} -> {1}", lc.LocationA.getFullName(), lc.LocationB.getFullName());
                                lastLocChange = lc;
                            }
                        }
                    }
                    if (pvd.FlagNewLocation)
                    {
                        m_text.AppendFormat("\\par\\pard\\f2\\qc\\fs{0}\r\n", g_Header2Size);
                        m_text.Append(GPStrings.getString(9));
                        m_text.Append("\\par\\pard\\qc\\cf2\\fs22 ");
                        m_text.Append(pvd.date.getLocation().getFullName());
                    }

                    // print location text
                    if (bShowColumnHeaders != 0)
                    {
                        m_text.Append("\\par\\pard\\qc\\cf2\\fs22 ");
                        m_text.Append(pvd.date.getLocation().getFullName());
                    }

                    if (bShowColumnHeaders != 0)
                    {
                        m_text.AppendFormat("\\par\\pard\\fs{0}\\qc {1}", g_NoteSize, GPFileHelper.FileVersion);
                        m_text.AppendLine("\\par\\par");
                    }


                    if (bShowColumnHeaders != 0)
                    {
                        int tabStop = 5760 * g_TextSize / 24;
                        str = string.Format("\\pard\\tx{0}\\tx{1} ", 2000 * g_TextSize / 24, tabStop);
                        m_text.Append(str);
                        if (GPDisplays.Calendar.PaksaInfoVisible())
                        {
                            tabStop += 990 * g_TextSize / 24;
                            str      = string.Format("\\tx{0}", tabStop);
                            m_text.Append(str);
                        }
                        if (GPDisplays.Calendar.YogaVisible())
                        {
                            tabStop += 1720 * g_TextSize / 24;
                            str      = string.Format("\\tx{0}", tabStop);
                            m_text.Append(str);
                        }
                        if (GPDisplays.Calendar.NaksatraVisible())
                        {
                            tabStop += 1800 * g_TextSize / 24;
                            str      = string.Format("\\tx{0}", tabStop);
                            m_text.Append(str);
                        }
                        if (GPDisplays.Calendar.FastingFlagVisible())
                        {
                            tabStop += 750 * g_TextSize / 24;
                            str      = string.Format("\\tx{0}", tabStop);
                            m_text.Append(str);
                        }
                        if (GPDisplays.Calendar.RasiVisible())
                        {
                            tabStop += 1850 * g_TextSize / 24;
                            str      = string.Format("\\tx{0}", tabStop);
                            m_text.Append(str);
                        }
                        // paksa width 990
                        // yoga width 1720
                        // naks width 1800
                        // fast width 990
                        // rasi width 1850
                        m_text.Append(str);
                        str = string.Format("{{\\highlight15\\cf7\\fs{0}\\b {1}\\tab {2}", g_NoteSize, getSharedStringRtf(985).ToUpper(), getSharedStringRtf(986).ToUpper());
                        m_text.Append(str);
                        if (GPDisplays.Calendar.PaksaInfoVisible())
                        {
                            m_text.Append("\\tab ");
                            m_text.Append(getSharedStringRtf(20).ToUpper());
                        }
                        if (GPDisplays.Calendar.YogaVisible())
                        {
                            m_text.Append("\\tab ");
                            m_text.Append(getSharedStringRtf(104).ToUpper());
                        }
                        if (GPDisplays.Calendar.NaksatraVisible())
                        {
                            m_text.Append("\\tab ");
                            m_text.Append(getSharedStringRtf(15).ToUpper());
                        }
                        if (GPDisplays.Calendar.FastingFlagVisible())
                        {
                            m_text.Append("\\tab ");
                            m_text.Append(getSharedStringRtf(987).ToUpper());
                        }
                        if (GPDisplays.Calendar.RasiVisible())
                        {
                            m_text.Append("\\tab ");
                            m_text.Append(getSharedStringRtf(105).ToUpper());
                        }
                        m_text.Append("}");
                    }
                    str = string.Format("\\fs{0} ", g_TextSize);
                    m_text.Append(str);

                    FormatCalendarDayRtf(pvd, dayText, prevd, nextd);

                    if (!GPDisplays.Calendar.HideEmptyDays() || dayText.Length > 90)
                    {
                        m_text.Append(dayText);
                    }
                }
            }

            AddNoteRtf(m_text);

            m_text.AppendLine();
            m_text.AppendLine("}");

            return(1);
        }
Beispiel #4
0
        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);
                    }
                }
            }
        }
Beispiel #5
0
        public static int FormatCalendarVCAL(GPCalendarResults daybuff, StringBuilder m_text)
        {
            int           k;
            int           initialLength = 0;
            int           lastmasa = -1;
            string        str, str2;
            StringBuilder dayText = new StringBuilder();
            GPCalendarDay pvd, prevd, nextd;
            string        SPACE_BEFORE_LINE = " , ";

            DateTime st = new DateTime();

            m_text.Remove(0, m_text.Length);
            m_text.Append("BEGIN:VCALENDAR\nVERSION:1.0\nX-WR-CALNAME:VAISNAVA\nPRODID:-//GBC Calendar Comitee//GCAL//EN\n");
            m_text.Append("X-WR-RELCALID:");
            str2 = string.Format("{0:00000000}-{1:0000}-{2:0000}-{3:0000}-{4:0000}{5:00000000}", st.Year + st.Millisecond, st.Day * Convert.ToInt32(st.DayOfWeek), st.Month,
                                 st.Hour, st.Minute + st.Millisecond);
            m_text.Append(str2);
            m_text.Append("\nX-WR-TIMEZONE:");

            m_text.Append(daybuff.CurrentLocation.getLocation(0).getTimeZoneName());
            m_text.Append("\n");

            m_text.Append("CALSCALE:GREGORIAN\nMETHOD:PUBLISH\n");

            for (k = 0; k < daybuff.m_PureCount; k++)
            {
                prevd = daybuff.get(k - 1);
                pvd   = daybuff.get(k);
                nextd = daybuff.get(k + 1);

                if (pvd != null)
                {
                    dayText.Remove(0, dayText.Length);

                    if (pvd.astrodata.nMasa != lastmasa)
                    {
                        str = string.Format("{0}, {1}", pvd.getMasaLongName(), pvd.getGaurabdaYearLongString());
                        dayText.Append(str);
                        dayText.AppendLine();
                        if ((pvd.astrodata.nMasa == GPMasa.ADHIKA_MASA) && ((lastmasa >= GPMasa.SRIDHARA_MASA) && (lastmasa <= GPMasa.DAMODARA_MASA)))
                        {
                            if (dayText.Length > 0)
                            {
                                dayText.Append(SPACE_BEFORE_LINE);
                            }
                            dayText.Append(getSharedStringHtml(128));
                            dayText.AppendLine();
                        }

                        lastmasa      = pvd.astrodata.nMasa;
                        initialLength = -1;
                    }
                    else
                    {
                        initialLength = 0;
                    }

                    if (dayText.Length > 0)
                    {
                        dayText.Append(SPACE_BEFORE_LINE);
                    }
                    dayText.Append(GPTithi.getName(pvd.astrodata.nTithi));

                    if ((pvd.astrodata.nTithi == 10) || (pvd.astrodata.nTithi == 25) || (pvd.astrodata.nTithi == 11) || (pvd.astrodata.nTithi == 26))
                    {
                        if (pvd.hasEkadasiParana() == false)
                        {
                            dayText.Append(" ");
                            if (pvd.nMahadvadasiType == GPConstants.EV_NULL)
                            {
                                dayText.Append(getSharedStringHtml(58));
                            }
                            else
                            {
                                dayText.Append(getSharedStringHtml(59));
                            }
                        }
                    }
                    dayText.AppendLine();
                    initialLength += dayText.Length;

                    if (pvd.astrodata.sun.eclipticalLongitude >= 0.0)
                    {
                        if (pvd.hasEkadasiParana())
                        {
                            m_text.AppendLine("BEGIN:VEVENT");
                            if (pvd.ekadasiParanaStart != null)
                            {
                                str2 = string.Format("DTSTART:{0:0000}{1:00}{2:00}T{3:00}{4:00}00", pvd.date.getYear(), pvd.date.getMonth(), pvd.date.getDay(), pvd.ekadasiParanaStart.getHour(), pvd.ekadasiParanaStart.getMinute());
                            }
                            else
                            {
                                str2 = string.Format("DTSTART:{0:0000}{1:00}{2:00}T000000", pvd.date.getYear(), pvd.date.getMonth(), pvd.date.getDay());
                            }
                            m_text.AppendLine(str2);
                            if (pvd.ekadasiParanaEnd != null)
                            {
                                str2 = string.Format("DTEND:{0:0000}{1:00}{2:00}T{3:00}{4:00}00", pvd.date.getYear(), pvd.date.getMonth(), pvd.date.getDay(), pvd.ekadasiParanaEnd.getHour(), pvd.ekadasiParanaEnd.getMinute());
                            }
                            else
                            {
                                str2 = string.Format("DTEND:{0:0000}{1:00}{2:00}T{3:00}{4:00}00", pvd.date.getYear(), pvd.date.getMonth(), pvd.date.getDay(), pvd.astrodata.sun.set.getHour(), pvd.astrodata.sun.set.getMinute());
                            }
                            m_text.AppendLine(str2);
                            m_text.Append("SUMMARY:");
                            m_text.Append(getSharedStringHtml(60));
                            m_text.Append("\nSEQUENCE:1\nEND:VEVENT\n");
                        }

                        foreach (GPCalendarDay.Festival fest in pvd.CompleteFestivalList(prevd, nextd))
                        {
                            if (GPUserDefaults.BoolForKey(fest.ShowSettingItem, true))
                            {
                                dayText.Append(SPACE_BEFORE_LINE);
                                dayText.AppendLine(fest.Text);
                            }
                        }
                    }


                    if (dayText.Length > initialLength)
                    {
                        m_text.Append("BEGIN:VEVENT\n");
                        str2 = string.Format("DTSTART:{0:0000}{1:00}{2:00}T{3:00}{4:00}{5:00}\n", pvd.date.getYear(), pvd.date.getMonth(), pvd.date.getDay(),
                                             pvd.astrodata.sun.rise.getHour(), pvd.astrodata.sun.rise.getMinute(), pvd.astrodata.sun.rise.getSecond());
                        m_text.Append(str2);
                        str2 = string.Format("DTEND:{0:0000}{1:00}{2:00}T{3:00}{4:00}{5:00}\n", pvd.date.getYear(), pvd.date.getMonth(), pvd.date.getDay(),
                                             pvd.astrodata.sun.set.getHour(), pvd.astrodata.sun.set.getMinute(), pvd.astrodata.sun.set.getSecond());
                        m_text.Append(str2);
                        str2 = string.Format("LOCATION:{0}\n", pvd.date.getLocation().getFullName());
                        str2.Replace(",", "\\,");
                        m_text.Append(str2);
                        m_text.Append("SUMMARY:");
                        dayText.Replace(",", "\\,");
                        m_text.Append(dayText.ToString().TrimStart());
                        str2 = string.Format("UID:{0:00000000}-{1:0000}-{2:0000}-{3:0000}-{4:00000000}{5:0000}\n", st.Year, st.Month * 30 + st.Day, st.Hour * 60 + st.Minute, st.Second, st.Millisecond, k);
                        m_text.Append(str2);
                        m_text.Append("SEQUENCE:1\nEND:VEVENT\n");
                    }
                }
            }

            m_text.Append("END:VCALENDAR\n");
            return(1);
        }
Beispiel #6
0
        public static int FormatCalendarCSV(GPCalendarResults daybuff, StringBuilder m_text)
        {
            int           k;
            int           initialLength = 0;
            int           lastmasa = -1;
            string        str, str2;
            StringBuilder dayText = new StringBuilder();
            GPCalendarDay pvd, prevd, nextd;
            string        SPACE_BEFORE_LINE = " , ";

            m_text.Remove(0, m_text.Length);
            m_text.Append("\"Subject\",\"Begin Date\",\"Start\",\"End Date\",\"End\",\"WholeDay\",\"Alarm\"\n");

            for (k = 0; k < daybuff.m_PureCount; k++)
            {
                //		date.shour = 0.0;
                //		date.TimeZone = earth.tzone;

                prevd = daybuff.get(k - 1);
                pvd   = daybuff.get(k);
                nextd = daybuff.get(k + 1);

                if (pvd != null)
                {
                    dayText.Remove(0, dayText.Length);

                    if (pvd.astrodata.nMasa != lastmasa)
                    {
                        lastmasa      = pvd.astrodata.nMasa;
                        initialLength = -1;
                    }
                    else
                    {
                        initialLength = 0;
                    }

                    if (dayText.Length > 0)
                    {
                        dayText.Append(SPACE_BEFORE_LINE);
                    }
                    dayText.Append(GPTithi.getName(pvd.astrodata.nTithi));

                    if ((pvd.astrodata.nTithi == 10) || (pvd.astrodata.nTithi == 25) || (pvd.astrodata.nTithi == 11) || (pvd.astrodata.nTithi == 26))
                    {
                        if (pvd.hasEkadasiParana() == false)
                        {
                            dayText.Append(" ");
                            if (pvd.nMahadvadasiType == GPConstants.EV_NULL)
                            {
                                dayText.Append(getSharedStringHtml(58));
                            }
                            else
                            {
                                dayText.Append(getSharedStringHtml(59));
                            }
                        }
                    }
                    dayText.Append("; ");
                    initialLength = dayText.Length;

                    if (pvd.astrodata.sun.eclipticalLongitude < 0.0)
                    {
                        goto _resolve_text;
                    }

                    //			if (0 != GetShowSetVal(17) == 1)
                    {
                        //				double h1, m1;
                        if (pvd.hasEkadasiParana())
                        {
                            str = pvd.getEkadasiParanaString();

                            dayText.Append(str);
                            dayText.Append("; ");
                        }
                    }

                    //			if (0 != GetShowSetVal(6) == 1)
                    {
                        foreach (GPCalendarDay.Festival fest in pvd.Festivals)
                        {
                            if (GPUserDefaults.BoolForKey(fest.ShowSettingItem, true))
                            {
                                dayText.Append(fest.Text);
                                dayText.Append("; ");
                            }
                        }
                    }

                    if (/*GetShowSetVal(16) == 1 &&*/ pvd.sankranti_zodiac >= 0)
                    {
                        str = string.Format("{0} {1}; ", GPSankranti.getName(pvd.sankranti_zodiac), getSharedStringHtml(56));
                        dayText.Append(str);
                    }


                    //"Sunrise Time",//2
                    //"Sunset Time",//3
                    if (GPDisplays.Calendar.TimeSunriseVisible())
                    {
                        str = string.Format("Sunrise {0}; ", pvd.astrodata.sun.rise.getShortTimeString());
                        dayText.Append(str);
                    }
                    if (GPDisplays.Calendar.TimeSunsetVisible())
                    {
                        str = string.Format("Sunset {0}; ", pvd.astrodata.sun.set.getShortTimeString());
                        dayText.Append(str);
                    }


                    {
                        if (prevd != null)
                        {
                            if (prevd.astrodata.nMasa != pvd.astrodata.nMasa)
                            {
                                str = string.Format("{0} {1} {2}", getSharedStringHtml(780), GPMasa.GetName(pvd.astrodata.nMasa), getSharedStringHtml(22));
                                dayText.Append(str);
                                dayText.Append("; ");
                            }
                        }
                        if (nextd != null)
                        {
                            if (nextd.astrodata.nMasa != pvd.astrodata.nMasa)
                            {
                                str = string.Format("{0} {1} {2}", getSharedStringHtml(781), GPMasa.GetName(pvd.astrodata.nMasa), getSharedStringHtml(22));
                                dayText.Append(str);
                                dayText.Append("; ");
                            }
                        }
                    }

_resolve_text:
                    if (dayText.Length > initialLength || !GPDisplays.Calendar.HideEmptyDays())
                    {
                        m_text.Append("\"");
                        m_text.Append(dayText);
                        m_text.Append("\",");

                        str2 = string.Format("\"{0}.{1}.{2}\",\"0:00:00\",\"{3}.{4}.{5}\",\"0:00:00\",\"True\",\"False\"\n",
                                             pvd.date.getDay(), pvd.date.getMonth(), pvd.date.getYear(), nextd.date.getDay(),
                                             nextd.date.getMonth(), nextd.date.getYear());
                        m_text.Append(str2);
                    }
                }
            }

            return(1);
        }
Beispiel #7
0
        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();
        }
Beispiel #8
0
        public static void AvcGetTodayInfo(GPGregorianTime vc, GPLocationProvider loc, StringBuilder str)
        {
            string str2;

            GPCalendarResults db = new GPCalendarResults();

            GPGregorianTime vc2 = new GPGregorianTime(vc);

            vc2.AddDays(-4);
            db.CalculateCalendar(vc2, 9);

            int           i = db.FindDate(vc);
            GPCalendarDay p = db.get(i);

            if (p == null)
            {
                return;
            }

            str.AppendFormat("{0}, {1} {2}", loc.getFullName(), loc.getLocation(0).getLatitudeString(), loc.getLocation(0).getLongitudeString());
            str.AppendLine();
            str.AppendFormat("{0}: {1}", getSharedStringPlain(12), loc.getLocation(0).getTimeZoneString());
            str.AppendLine();
            str.AppendLine();
            str.AppendFormat("[{0} - {1}]", vc, getSharedStringPlain(vc.getDayOfWeek()));
            str.AppendLine();
            str.AppendFormat("  {0}, {1} {2}", GPTithi.getName(p.astrodata.nTithi), GPPaksa.getName(p.astrodata.nPaksa), getSharedStringPlain(20));
            str.AppendLine();
            str.Append("  ");
            str.AppendFormat("{0}, {1}", p.getMasaLongName(), p.getGaurabdaYearLongString());
            str.AppendLine();
            str.AppendLine();

            if (p.hasEkadasiParana())
            {
                str.AppendLine(p.getEkadasiParanaString());
            }

            // adding mahadvadasi
            // adding spec festivals

            foreach (GPCalendarDay.Festival fest in p.CompleteFestivalList(db.get(i - 1), db.get(i + 1)))
            {
                if (GPUserDefaults.BoolForKey(fest.ShowSettingItem, true))
                {
                    if (fest.ShowSettingItem == GPDisplays.Keys.CalendarSankranti)
                    {
                        str.AppendLine(GPAppHelper.CenterString(fest.Text, 80, '-'));
                    }
                    else
                    {
                        str.AppendFormat("   {0}", fest.Text);
                        str.AppendLine();
                    }
                }
            }


            str.AppendLine();


            if (GPDisplays.Today.BrahmaMuhurtaVisible())
            {
                str.AppendLine();
                str.AppendFormat("{0} {1}", getSharedStringPlain(988), p.astrodata.sun.arunodaya.getShortMuhurtaRange(0));
            }

            if (GPDisplays.Today.SunriseVisible())
            {
                str.AppendLine();
                str2 = string.Format("{0} {1} ",
                                     getSharedStringPlain(51), p.astrodata.sun.rise.getShortTimeString());
                str.Append(str2);
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1}", getSharedStringPlain(989), p.astrodata.sun.rise.getShortSandhyaRange());
                }
                str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.AppendLine();
            }
            if (GPDisplays.Today.NoonVisible())
            {
                str2 = string.Format("{0}    {1} ", getSharedStringPlain(857), p.astrodata.sun.noon.getShortTimeString());
                str.Append(str2);
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1} ", getSharedStringPlain(989), p.astrodata.sun.noon.getShortSandhyaRange());
                }
                str2 = string.Format(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.Append(str2);
                str.AppendLine();
            }
            if (GPDisplays.Today.SunsetVisible())
            {
                str2 = string.Format("{0}  {1} ", getSharedStringPlain(52), p.astrodata.sun.set.getShortTimeString());
                str.Append(str2);
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1} ", getSharedStringPlain(989), p.astrodata.sun.set.getShortSandhyaRange());
                }
                str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.AppendLine();
            }

            if (GPDisplays.Today.SunriseInfo())
            {
                str.AppendLine();
                str.AppendLine(getSharedStringPlain(990));
                str.AppendLine();
                str.AppendFormat("   {0} {1}", GPNaksatra.getName(p.astrodata.nNaksatra), getSharedStringPlain(15));
                if (GPDisplays.Today.NaksatraPadaVisible())
                {
                    str.AppendFormat(", {0} {1} ({2})", p.getNaksatraElapsedString(), getSharedStringPlain(993), getSharedStringPlain(811 + p.getNaksatraPada()));
                }
                if (GPDisplays.Today.RasiOfMoonVisible())
                {
                    str.AppendFormat(", {0}: {1}", getSharedStringPlain(991), GPSankranti.getName(p.astrodata.nMoonRasi), getSharedStringPlain(105));
                }
                str.AppendFormat(", {0} {1}", GPYoga.getName(p.astrodata.nYoga), getSharedStringPlain(104));
                str.AppendLine();
                str.AppendFormat("   {0}: {1}.", getSharedStringPlain(992), GPSankranti.getName(p.astrodata.nSunRasi));
                str.AppendLine();
            }

            AddNoteText(str);
        }
Beispiel #9
0
        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);
        }
Beispiel #10
0
        public static int FormatCalendarPlain(GPCalendarResults daybuff, StringBuilder m_text)
        {
            int           k, nMasaHeader;
            String        str;
            StringBuilder dayText = new StringBuilder();

            GPCalendarDay pvd, prevd, nextd;
            int           lastmasa  = -1;
            int           lastmonth = -1;
            int           tp1;
            bool          bCalcMoon = (getShowSettingsValue(4) > 0 || getShowSettingsValue(5) > 0);

            GPStrings.pushRich(false);

            m_text.Remove(0, m_text.Length);

            for (k = 0; k < daybuff.m_vcCount; k++)
            {
                prevd = daybuff.get(k - 1);
                pvd   = daybuff.get(k);
                nextd = daybuff.get(k + 1);

                if (pvd != null)
                {
                    nMasaHeader = 0;
                    if (GPDisplays.Calendar.MasaHeader() && (pvd.astrodata.nMasa != lastmasa))
                    {
                        nMasaHeader = 1;
                        m_text.AppendLine();
                        str = string.Format("{0}, {1}", pvd.getMasaLongName(), pvd.getGaurabdaYearLongString());
                        tp1 = (80 - str.Length) / 2;
                        m_text.Append(string.Empty.PadLeft(tp1));
                        m_text.Append(str);
                        m_text.Append(string.Empty.PadLeft(tp1 - GPAppHelper.getShortVersionText().Length));
                        m_text.AppendLine(GPAppHelper.getShortVersionText());
                        if ((pvd.astrodata.nMasa == GPMasa.ADHIKA_MASA) && ((lastmasa >= GPMasa.SRIDHARA_MASA) && (lastmasa <= GPMasa.DAMODARA_MASA)))
                        {
                            AddListText(m_text, getSharedStringPlain(128));
                        }
                        m_text.AppendLine();
                        m_text.AppendLine(GPAppHelper.CenterString(daybuff.CurrentLocation.getLocation(pvd.date.getJulianGreenwichTime()).getFullName(), 80));
                        m_text.AppendLine();
                        lastmasa = pvd.astrodata.nMasa;
                    }

                    if (GPDisplays.Calendar.MonthHeader() && (pvd.date.getMonth() != lastmonth))
                    {
                        nMasaHeader = 1;
                        m_text.AppendLine();
                        str = string.Format("{0} {1}", getSharedStringPlain(759 + pvd.date.getMonth()), pvd.date.getYear());
                        tp1 = (80 - str.Length) / 2;
                        m_text.Append(string.Empty.PadLeft(tp1));
                        m_text.Append(str);
                        string tmpString = GPAppHelper.getShortVersionText();
                        if (tmpString.Length < tp1)
                        {
                            m_text.Append(string.Empty.PadLeft(tp1 - tmpString.Length));
                        }
                        m_text.AppendLine(GPAppHelper.getShortVersionText());
                        m_text.AppendLine(GPAppHelper.CenterString(daybuff.CurrentLocation.getLocation(pvd.date.getJulianGreenwichTime()).getFullName(), 80));
                        m_text.AppendLine();
                        lastmonth = pvd.date.getMonth();
                    }

                    else if (pvd.Travelling != null)
                    {
                        m_text.AppendLine(GPAppHelper.CenterString(GPStrings.getString(1030), 80));
                        GPLocationChange lastLocChange = null;
                        foreach (GPLocationChange lc in pvd.Travelling)
                        {
                            if (lastLocChange != lc)
                            {
                                m_text.AppendLine(GPAppHelper.CenterString(String.Format("{0} -> {1}", lc.LocationA.getFullName(), lc.LocationB.getFullName()), 80));
                                lastLocChange = lc;
                            }
                        }
                        m_text.AppendLine();

                        nMasaHeader = 1;
                    }
                    else if (pvd.FlagNewLocation)
                    {
                        m_text.AppendLine(GPAppHelper.CenterString(GPStrings.getString(9), 80));
                        m_text.AppendLine(GPAppHelper.CenterString(daybuff.CurrentLocation.getLocation(pvd.date.getJulianGreenwichTime()).getFullName(), 80));
                        m_text.AppendLine();

                        nMasaHeader = 1;
                    }

                    if (nMasaHeader == 1)
                    {
                        nMasaHeader = m_text.Length;
                        m_text.Append(" ");
                        m_text.Append(getSharedStringPlain(985).ToUpper().PadRight(16));
                        m_text.Append(getSharedStringPlain(986).ToUpper().PadRight(30));
                        if (GPDisplays.Calendar.PaksaInfoVisible())
                        {
                            m_text.Append(getSharedStringPlain(20).ToUpper().PadRight(6));
                        }
                        else
                        {
                            m_text.Append(string.Empty.PadRight(6));
                        }
                        if (GPDisplays.Calendar.YogaVisible())
                        {
                            m_text.Append(getSharedStringPlain(104).ToUpper().PadRight(10));
                        }
                        if (GPDisplays.Calendar.NaksatraVisible())
                        {
                            m_text.Append(getSharedStringPlain(15).ToUpper().PadRight(15));
                        }
                        if (GPDisplays.Calendar.FastingFlagVisible())
                        {
                            m_text.Append(getSharedStringPlain(987).ToUpper().PadRight(5));
                        }
                        if (GPDisplays.Calendar.RasiVisible())
                        {
                            m_text.Append(getSharedStringPlain(105).ToUpper().PadRight(15));
                        }
                        nMasaHeader = m_text.Length - nMasaHeader;
                        m_text.AppendLine();
                        m_text.AppendLine(string.Empty.PadRight(nMasaHeader, '-'));
                    }

                    AvcGetOldCalendarDayText(pvd, dayText, prevd, nextd);

                    if (!GPDisplays.Calendar.HideEmptyDays() || dayText.Length > 90)
                    {
                        m_text.Append(dayText);
                    }
                }
            }

            AddNoteText(m_text);

            GPStrings.popRich();
            return(1);
        }
Beispiel #11
0
        public static int FormatCalendarICAL(GPCalendarResults daybuff, StringBuilder m_text)
        {
            int             k;
            int             initialLength = 0;
            int             lastmasa = -1;
            int             tzoffset = 0, tzoff;
            string          str, str2;
            StringBuilder   dayText = new StringBuilder();
            GPCalendarDay   pvd, prevd, nextd;
            string          SPACE_BEFORE_LINE = " , ";
            GPGregorianTime vc  = new GPGregorianTime(daybuff.m_vcStart);
            GPLocation      loc = daybuff.CurrentLocation.getLocation(0);

            DateTime st = new DateTime();

            m_text.Remove(0, m_text.Length);
            m_text.Append("BEGIN:VCALENDAR\nVERSION:2.0\nX-WR-CALNAME:VAISNAVA\nPRODID:-//GBC Calendar Comitee//GCAL//EN\n");
            m_text.Append("X-WR-RELCALID:");
            str2 = string.Format("{0:00000000}-{1:0000}-{2:0000}-{3:0000}-{4:0000}{5:00000000}", st.Year + st.Millisecond, st.Day, st.Month,
                                 st.Hour, st.Minute + st.Millisecond);
            m_text.Append(str2);
            m_text.Append("\nX-WR-TIMEZONE:");

            m_text.Append(loc.getTimeZoneName());
            m_text.Append("\n");

            m_text.Append("CALSCALE:GREGORIAN\nMETHOD:PUBLISH\n");
            m_text.Append("BEGIN:VTIMEZONE\nTZID:");
            m_text.Append(loc.getTimeZoneName());
            str2 = string.Format("\nLAST-MODIFIED:{0:0000}{1:00}{2:00}T{3:00}{4:00}{5:00}Z", st.Year, st.Month, st.Day, st.Hour, st.Minute, st.Second);
            m_text.Append(str2);

            tzoffset = Convert.ToInt32(loc.getTimeZone().OffsetSeconds / 60);
            tzoff    = Convert.ToInt32(loc.getTimeZone().getMaximumOffsetSeconds() / 60);

            if (loc.getTimeZone().hasDstInYear(st.Year))
            {
                DateTime dta = loc.getTimeZone().StartDateInYear(st.Year);
                str2 = string.Format("\nBEGIN:DAYLIGHT\nDTSTART:{0:0000}{1:00}{2:00}T{3:00}0000", dta.Year, dta.Month, dta.Day, dta.Hour);
                m_text.Append(str2);

                str2 = string.Format("\nTZOFFSETTO:{0}{1:00}{2:00}", (tzoff > 0 ? '+' : '-'), Math.Abs(tzoff) / 60, Math.Abs(tzoff) % 60);
                m_text.Append(str2);

                str2 = string.Format("\nTZOFFSETFROM:{0}{1:00}{2:00}", '+', 0, 0);
                m_text.Append(str2);

                dta = loc.getTimeZone().EndDateInYear(st.Year);
                m_text.Append("\nEND:DAYLIGHT\nBEGIN:STANDARD\nDTSTART:");
                str2 = string.Format("{0:0000}{1:00}{2:00}T{3:00}0000", dta.Year, dta.Month, dta.Day, dta.Hour);
                m_text.Append(str2);

                str2 = string.Format("\nTZOFFSETTO:{0}{1:00}{2:00}", (tzoffset > 0 ? '+' : '-'), Math.Abs(tzoffset) / 60, Math.Abs(tzoffset) % 60);
                m_text.Append(str2);
                str2 = string.Format("\nTZOFFSETFROM:{0}{1:00}{2:00}", (tzoff > 0 ? '+' : '-'), Math.Abs(tzoff) / 60, Math.Abs(tzoff) % 60);
                m_text.Append(str2);
                m_text.Append("\nEND:STANDARD\n");
            }
            else
            {
                m_text.Append("\nBEGIN:STANDARD\nDTSTART:");
                str2 = string.Format("{0:0000}0101T000000", vc.getYear(), vc.getMonth(), vc.getDay(), vc.getHour());
                m_text.Append(str2);

                str2 = string.Format("\nTZOFFSETTO:%+02d{0:00}", Math.Abs(tzoffset) / 60, Math.Abs(tzoffset) % 60);
                m_text.Append(str2);
                str2 = string.Format("\nTZOFFSETFROM:+0000");
                m_text.Append(str2);
                m_text.Append("\nEND:STANDARD\n");
            }

            m_text.Append("END:VTIMEZONE\n");

            for (k = 0; k < daybuff.m_PureCount; k++)
            {
                //		date.shour = 0.0;
                //		date.TimeZone = earth.tzone;

                prevd = daybuff.get(k - 1);
                pvd   = daybuff.get(k);
                nextd = daybuff.get(k + 1);

                if (pvd != null)
                {
                    dayText.Remove(0, dayText.Length);

                    if (pvd.astrodata.nMasa != lastmasa)
                    {
                        str = string.Format("{0} {1}, Gaurabda {2}", GPMasa.GetName(pvd.astrodata.nMasa), getSharedStringHtml(22), pvd.astrodata.nGaurabdaYear);
                        dayText.Append(str);
                        dayText.Append("\n");
                        if ((pvd.astrodata.nMasa == GPMasa.ADHIKA_MASA) && ((lastmasa >= GPMasa.SRIDHARA_MASA) && (lastmasa <= GPMasa.DAMODARA_MASA)))
                        {
                            if (dayText.Length > 0)
                            {
                                dayText.Append(SPACE_BEFORE_LINE);
                            }
                            dayText.Append(getSharedStringHtml(128));
                            dayText.Append("\n");
                        }

                        lastmasa      = pvd.astrodata.nMasa;
                        initialLength = -1;
                    }
                    else
                    {
                        initialLength = 0;
                    }

                    if (dayText.Length > 0)
                    {
                        dayText.Append(SPACE_BEFORE_LINE);
                    }
                    dayText.Append(GPTithi.getName(pvd.astrodata.nTithi));

                    if ((pvd.astrodata.nTithi == 10) || (pvd.astrodata.nTithi == 25) || (pvd.astrodata.nTithi == 11) || (pvd.astrodata.nTithi == 26))
                    {
                        if (pvd.hasEkadasiParana() == false)
                        {
                            dayText.Append(" ");
                            if (pvd.nMahadvadasiType == GPConstants.EV_NULL)
                            {
                                dayText.Append(getSharedStringHtml(58));
                            }
                            else
                            {
                                dayText.Append(getSharedStringHtml(59));
                            }
                        }
                    }
                    dayText.Append("\n");
                    initialLength += dayText.Length;

                    if (pvd.astrodata.sun.eclipticalLongitude < 0.0)
                    {
                        goto _resolve_text;
                    }

                    //			if (0 != GetShowSetVal(17) == 1)
                    {
                        //				double h1, m1;
                        if (pvd.hasEkadasiParana())
                        {
                            str = pvd.getEkadasiParanaString();

                            dayText.Append(SPACE_BEFORE_LINE);
                            dayText.Append(str);
                            dayText.Append("\n");
                        }
                    }

                    //			if (0 != GetShowSetVal(6) == 1)
                    {
                        foreach (GPCalendarDay.Festival fest in pvd.Festivals)
                        {
                            if (GPUserDefaults.BoolForKey(fest.ShowSettingItem, true))
                            {
                                dayText.Append(SPACE_BEFORE_LINE);
                                dayText.Append(fest.Text);
                                dayText.Append("\n");
                            }
                        }
                    }

                    if (/*GetShowSetVal(16) == 1 &&*/ pvd.sankranti_zodiac >= 0)
                    {
                        str = string.Format(" {0} {1}", GPSankranti.getName(pvd.sankranti_zodiac), getSharedStringHtml(56));
                        dayText.Append(SPACE_BEFORE_LINE);
                        dayText.Append(str);
                        dayText.Append("\n");
                    }



                    //"Sunrise Time",//2
                    //"Sunset Time",//3
                    if (GPDisplays.Calendar.TimeSunriseVisible())
                    {
                        str = string.Format("{0} {1}", getSharedStringHtml(51), pvd.astrodata.sun.rise.getShortTimeString());
                        dayText.Append(SPACE_BEFORE_LINE);
                        dayText.Append(str);
                        dayText.Append("\n");
                    }
                    if (GPDisplays.Calendar.TimeSunsetVisible())
                    {
                        str = string.Format("{0} {1}", getSharedStringHtml(52), pvd.astrodata.sun.set.getShortTimeString());
                        dayText.Append(SPACE_BEFORE_LINE);
                        dayText.Append(str);
                        dayText.Append("\n");
                    }

                    {
                        if (prevd != null)
                        {
                            if (prevd.astrodata.nMasa != pvd.astrodata.nMasa)
                            {
                                str = string.Format("{0} {1} {2}", getSharedStringHtml(780), GPMasa.GetName(pvd.astrodata.nMasa), getSharedStringHtml(22));
                                dayText.Append(SPACE_BEFORE_LINE);
                                dayText.Append(str);
                                dayText.Append("\n");
                            }
                        }
                        if (nextd != null)
                        {
                            if (nextd.astrodata.nMasa != pvd.astrodata.nMasa)
                            {
                                str = string.Format("{0} {1} {2}", getSharedStringHtml(781), GPMasa.GetName(pvd.astrodata.nMasa), getSharedStringHtml(22));
                                dayText.Append(SPACE_BEFORE_LINE);
                                dayText.Append(str);
                                dayText.Append("\n");
                            }
                        }
                    }

_resolve_text:
                    if (dayText.Length > initialLength)
                    {
                        m_text.Append("BEGIN:VEVENT\n");
                        str2 = string.Format("DTSTART;VALUE=DATE:{0:0000}{1:00}{2:00}\n", pvd.date.getYear(), pvd.date.getMonth(), pvd.date.getDay());
                        m_text.Append(str2);

                        /*str2 = string.Format("DTEND;VALUE=DATE:{0:0000}{0:00}{0:00}T{0:00}{0:00}{0:00}\n", pvd.date.year, pvd.date.month, pvd.date.day,
                         *  pvd.astrodata.sun.set.hour, pvd.astrodata.sun.set.min, pvd.astrodata.sun.set.sec);
                         * m_text.Append(str2);*/
                        str2 = string.Format("LOCATION:{0}\n", loc.getFullName());
                        str2.Replace(",", "\\,");
                        m_text.Append(str2);
                        m_text.Append("SUMMARY:");
                        dayText.Replace(",", "\\,");
                        m_text.Append(dayText.ToString().TrimStart());
                        str2 = string.Format("UID:{0:00000000}-{1:0000}-{2:0000}-{3:0000}-{4:00000000}{5:0000}\n", st.Year, st.Month * 30 + st.Day, st.Hour * 60 + st.Minute, st.Second, st.Millisecond, k);
                        m_text.Append(str2);
                        m_text.Append("DURATION:P1D\nSEQUENCE:1\nEND:VEVENT\n");
                    }
                }
            }

            m_text.Append("END:VCALENDAR\n");
            return(1);
        }
Beispiel #12
0
        public static XmlDocument GetCalendarXmlDocument(GPCalendarResults daybuff)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement  e1, e2, e3, eday, e5, e6;
            int         k;
            string      str, st;

            GPCalendarDay pvd;
            int           nPrevMasa = -1;

            e1 = doc.CreateElement("xml");
            doc.AppendChild(e1);

            e2 = doc.CreateElement("request");
            e1.AppendChild(e2);
            e2.SetAttribute("name", "Calendar");
            e2.SetAttribute("version", GPFileHelper.FileVersion);

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "longitude");
            e3.SetAttribute("val", daybuff.CurrentLocation.getLocation(0).GetLongitudeEastPositive().ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "latitude");
            e3.SetAttribute("val", daybuff.CurrentLocation.getLocation(0).GetLatitudeNorthPositive().ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "timezone");
            e3.SetAttribute("val", (daybuff.CurrentLocation.getLocation(0).getTimeZone().OffsetSeconds / 60).ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "startdate");
            e3.SetAttribute("val", daybuff.m_vcStart.ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "daycount");
            e3.SetAttribute("val", daybuff.m_vcCount.ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "dst");
            e3.SetAttribute("val", daybuff.CurrentLocation.getLocation(0).getTimeZoneName());

            e2 = doc.CreateElement("result");
            e1.AppendChild(e2);
            e2.SetAttribute("name", "Calendar");

            e3 = doc.CreateElement("dstsystem");
            e2.AppendChild(e3);
            e3.SetAttribute("name", daybuff.CurrentLocation.getLocation(0).getTimeZoneName());

            for (k = 0; k < daybuff.m_vcCount; k++)
            {
                pvd = daybuff.get(k);
                if (pvd != null)
                {
                    if (nPrevMasa != pvd.astrodata.nMasa)
                    {
                        e3 = doc.CreateElement("masa");
                        e2.AppendChild(e3);
                        e3.SetAttribute("name", GPMasa.GetName(pvd.astrodata.nMasa) + " Masa" + (nPrevMasa == GPMasa.ADHIKA_MASA ? " " + getSharedStringHtml(109) : ""));
                        e3.SetAttribute("gyear", pvd.getGaurabdaYearLongString());
                    }

                    nPrevMasa = pvd.astrodata.nMasa;

                    eday = doc.CreateElement("day");
                    e3.AppendChild(eday);
                    eday.SetAttribute("date", pvd.date.ToString());
                    eday.SetAttribute("dayweekid", pvd.date.getDayOfWeek().ToString());
                    eday.SetAttribute("dayweek", getSharedStringHtml(150 + pvd.date.getDayOfWeek()));

                    // sunrise data
                    e5 = doc.CreateElement("sunrise");
                    eday.AppendChild(e5);
                    e5.SetAttribute("time", pvd.astrodata.sun.rise.getLongTimeString());

                    e6 = doc.CreateElement("tithi");
                    e5.AppendChild(e6);
                    e6.SetAttribute("name", pvd.getTithiNameExtended());
                    e6.SetAttribute("elapse", pvd.astrodata.nTithiElapse.ToString());
                    e6.SetAttribute("index", (pvd.astrodata.nTithi % 30 + 1).ToString());

                    e6 = doc.CreateElement("naksatra");
                    e5.AppendChild(e6);
                    e6.SetAttribute("name", pvd.getNaksatraName());
                    e6.SetAttribute("elapse", pvd.astrodata.nNaksatraElapse.ToString());

                    e6 = doc.CreateElement("yoga");
                    e5.AppendChild(e6);
                    e6.SetAttribute("name", pvd.getYogaName());

                    e6 = doc.CreateElement("paksa");
                    e5.AppendChild(e6);
                    e6.SetAttribute("id", GPPaksa.getAbbreviation(pvd.astrodata.nPaksa));
                    e6.SetAttribute("name", GPPaksa.getName(pvd.astrodata.nPaksa));

                    e5 = doc.CreateElement("dst");
                    eday.AppendChild(e5);
                    e5.SetAttribute("offset", pvd.date.getDaylightTimeBias().ToString());


                    // arunodaya data
                    e5 = doc.CreateElement("arunodaya");
                    eday.AppendChild(e5);
                    e5.SetAttribute("time", pvd.astrodata.sun.arunodaya.getLongTimeString());

                    e6 = doc.CreateElement("tithi");
                    e5.AppendChild(e6);
                    e6.SetAttribute("name", GPTithi.getName(pvd.astrodata.getTithiAtArunodaya()));

                    e5 = doc.CreateElement("noon");
                    eday.AppendChild(e5);
                    e5.SetAttribute("time", pvd.astrodata.sun.noon.getLongTimeString());

                    e5 = doc.CreateElement("sunset");
                    eday.AppendChild(e5);
                    e5.SetAttribute("time", pvd.astrodata.sun.set.getLongTimeString());

                    if (pvd.hasEkadasiParana() && pvd.ekadasiParanaStart != null)
                    {
                        e5 = doc.CreateElement("parana");
                        eday.AppendChild(e5);
                        if (pvd.ekadasiParanaEnd != null)
                        {
                            e5.SetAttribute("from", pvd.ekadasiParanaStart.getShortTimeString());
                            e5.SetAttribute("to", pvd.ekadasiParanaEnd.getShortTimeString());
                        }
                        else
                        {
                            e5.SetAttribute("after", pvd.ekadasiParanaStart.getShortTimeString());
                        }
                    }
                    str = string.Empty;

                    foreach (GPCalendarDay.Festival fest in pvd.Festivals)
                    {
                        e5 = doc.CreateElement("festival");
                        eday.AppendChild(e5);
                        e5.SetAttribute("name", fest.Text);
                        e5.SetAttribute("class", fest.ShowSettingItem);
                    }

                    if (pvd.nFastType != GPConstants.FAST_NULL)
                    {
                        e5 = doc.CreateElement("fast");
                        eday.AppendChild(e5);

                        e5.SetAttribute("type", pvd.nFastType.ToString());
                        e5.SetAttribute("mark", "*");
                    }

                    if (pvd.sankranti_zodiac >= 0)
                    {
                        e5 = doc.CreateElement("sankranti");
                        eday.AppendChild(e5);
                        e5.SetAttribute("rasi", GPSankranti.getName(pvd.sankranti_zodiac));
                        e5.SetAttribute("time", pvd.sankranti_day.getLongTimeString());
                    }

                    if (pvd.hasKsayaTithi())
                    {
                        GPGregorianTime vcStart = pvd.ksayaTithi.getStartTime();
                        GPGregorianTime vcEnd   = pvd.ksayaTithi.getEndTime();

                        e5 = doc.CreateElement("ksaya");
                        eday.AppendChild(e5);
                        e5.SetAttribute("from", vcStart.ToString() + " " + vcStart.getShortTimeString());
                        e5.SetAttribute("to", vcEnd.ToString() + " " + vcEnd.getShortTimeString());
                    }


                    if (pvd.IsSecondDayTithi)
                    {
                        e5 = doc.CreateElement("vriddhi");
                        eday.AppendChild(e5);
                        e5.SetAttribute("sd", "yes");
                    }
                }
            }

            return(doc);
        }