예제 #1
0
        public void FormatOutput(StringBuilder sb, GPCalendarResults cal)
        {
            bool done = false;

            if (Template != null)
            {
                if (Template == "default:plain")
                {
                    sb.AppendLine("<html><head><title>Calendar</title>");
                    sb.AppendLine("<style>");
                    sb.AppendLine("<!--");
                    sb.AppendLine(FormaterHtml.CurrentFormattingStyles);
                    sb.AppendLine("-->");
                    sb.AppendLine("</style>");
                    sb.AppendLine("</head>");
                    sb.AppendLine("<body>");
                    sb.AppendLine("<pre>");
                    StringBuilder fout = new StringBuilder();
                    FormaterPlain.FormatCalendarPlain(cal, fout);
                    sb.Append(fout);

                    sb.AppendLine("</pre></body></html>");
                    done = true;
                }
                else if (Template == "default:table")
                {
                    FormaterHtml.WriteCalendarHtmlTable(cal, sb);
                    done = true;
                }
            }
            if (!done)
            {
                FormaterHtml.WriteCalendarHTML(cal, sb);
            }
        }
예제 #2
0
파일: Testing.cs 프로젝트: vijeetgv/GCAL
        public static void Report(GPLocationProvider loc, string prefix)
        {
            GPGregorianTime start = new GPGregorianTime(loc);
            GPGregorianTime end   = new GPGregorianTime(loc);

            start.setDate(2010, 1, 1);
            end.setDate(2015, 1, 1);

            GPCalendarResults calendar = new GPCalendarResults();

            calendar.CalculateCalendar(start, Convert.ToInt32(end.getJulianLocalNoon() - start.getJulianLocalNoon()));

            GPCoreEventResults coreEvents = new GPCoreEventResults();

            coreEvents.Sort(false);
            coreEvents.CalculateEvents(loc, start, end);

            string path = "d:\\gcal\\reports\\";

            if (Directory.Exists(path))
            {
                File.WriteAllText(Path.Combine(path, prefix + "-cal-" + loc.getCity() + ".txt"),
                                  FormaterInternal.getInternalDalendarData(calendar));
                File.WriteAllText(Path.Combine(path, prefix + "-eve-" + loc.getCity() + ".txt"),
                                  FormaterInternal.getInternalEventsText(coreEvents));
            }
        }
예제 #3
0
        protected override void Execute()
        {
            GPCalendarResults calA = new GPCalendarResults();
            GPCalendarResults calB = new GPCalendarResults();

            calA.progressReport = this;
            calB.progressReport = this;

            if (startDateA != null && startDateB != null)
            {
                calA.CalculateCalendar(startDateA, nCount);
                calB.CalculateCalendar(startDateB, nCount);
            }

            StringBuilder sb = new StringBuilder();

            GPCalendarTwoLocResults cals = new GPCalendarTwoLocResults();

            cals.CalendarA = calA;
            cals.CalendarB = calB;

            FormaterHtml.WriteCompareCalendarHTML(cals, sb);

            HtmlText         = sb.ToString();
            CalculatedObject = cals;
        }
예제 #4
0
        protected override void Execute()
        {
            GPCalendarResults  cal = new GPCalendarResults();
            GPCoreEventResults evn = new GPCoreEventResults();

            cal.progressReport = this;
            evn.progressReport = this;

            if (location != null && startDate != null)
            {
                cal.CalculateCalendar(startDate, Convert.ToInt32(endDate.getJulianLocalNoon() - startDate.getJulianLocalNoon()));
                evn.CalculateEvents(location, startDate, endDate);
            }

            GPCalendarPlusEventsResults calev = new GPCalendarPlusEventsResults();

            calev.theCalendar = cal;
            calev.theEvents   = evn;

            StringBuilder sb = new StringBuilder();

            FormatOutput(sb, calev);

            HtmlText         = sb.ToString();
            CalculatedObject = calev;
        }
예제 #5
0
        /// <summary>
        /// Calculation of calendar
        /// </summary>
        /// <param name="city"></param>
        /// <param name="longitude"></param>
        /// <param name="latitude"></param>
        /// <param name="timezoneName"></param>
        /// <param name="startDate"></param>
        /// <param name="days"></param>
        /// <returns></returns>
        public static XmlDocument CalculateCalendar(GPLocationProvider locationProvider, DateTime startDate, int days)
        {
            GPCalendarResults cr = new GPCalendarResults();


            GPGregorianTime sd = new GPGregorianTime(locationProvider);

            sd.setDate(startDate.Year, startDate.Month, startDate.Day);


            cr.CurrentLocation = locationProvider;
            cr.CalculateCalendar(sd, days);

            return(FormaterXml.GetCalendarXmlDocument(cr));
        }
예제 #6
0
        protected override void Execute()
        {
            GPCalendarResults cal = new GPCalendarResults();

            cal.progressReport = this;

            if (location != null && startDate != null)
            {
                cal.CalculateCalendar(startDate, nCount);
            }

            StringBuilder sb = new StringBuilder();

            FormatOutput(sb, cal);

            HtmlText         = sb.ToString();
            CalculatedObject = cal;
        }
예제 #7
0
        protected override void Execute()
        {
            GPCalendarResults calA = new GPCalendarResults();

            calA.progressReport = this;

            if (startDateA != null)
            {
                calA.CalculateCalendar(startDateA, nCount);
            }

            StringBuilder sb = new StringBuilder();

            FormaterHtml.WriteCalendarHTML(calA, sb);

            HtmlText         = sb.ToString();
            CalculatedObject = calA;
        }
예제 #8
0
        public static string getInternalDalendarData(GPCalendarResults calendar)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("Location: {0}\n", calendar.CurrentLocation.getLocation(0).ToString());
            sb.AppendFormat("Longitude: {0}\nLatitude: {1}\n\n", calendar.CurrentLocation.getLocation(0).getLongitudeString(),
                            calendar.CurrentLocation.getLocation(0).getLatitudeString());

            // julian day
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("jdate {0}\t{1}\n", day.date.ToString(), day.astrodata.jdate);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("msAyanamsa {0}\t{1}\n", day.date.ToString(), day.astrodata.msAyanamsa);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("msDistance {0}\t{1}\n", day.date.ToString(), day.astrodata.msDistance);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nGaurabdaYear {0}\t{1}\n", day.date.ToString(), day.astrodata.nGaurabdaYear);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nMasa {0}\t{1}\n", day.date.ToString(), day.astrodata.nMasa);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nMoonRasi {0}\t{1}\n", day.date.ToString(), day.astrodata.nMoonRasi);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nNaksatra {0}\t{1}\n", day.date.ToString(), day.astrodata.nNaksatra);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nNaksatraElapse {0}\t{1}\n", day.date.ToString(), day.astrodata.nNaksatraElapse);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nPaksa {0}\t{1}\n", day.date.ToString(), day.astrodata.nPaksa);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nSunRasi {0}\t{1}\n", day.date.ToString(), day.astrodata.nSunRasi);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nTithi {0}\t{1}\n", day.date.ToString(), day.astrodata.nTithi);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nTithiElapse {0}\t{1}\n", day.date.ToString(), day.astrodata.nTithiElapse);
            }

            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nYoga {0}\t{1}\n", day.date.ToString(), day.astrodata.nYoga);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("nYogaElapse {0}\t{1}\n", day.date.ToString(), day.astrodata.nYogaElapse);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("sun.latitude_deg {0}\t{1}\n", day.date.ToString(), day.astrodata.sun.eclipticalLatitude);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("sun.longitude_deg {0}\t{1}\n", day.date.ToString(), day.astrodata.sun.eclipticalLongitude);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("sun.rise {0}\t{1}\n", day.date.ToString(), day.astrodata.sun.rise.getDayHours());
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("sun.set {0}\t{1}\n", day.date.ToString(), day.astrodata.sun.set.getDayHours());
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("sun.right_ascession {0}\t{1}\n", day.date.ToString(), day.astrodata.sun.rightAscession);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("sun.declination {0}\t{1}\n", day.date.ToString(), day.astrodata.sun.declination);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("moon.longitude_deg {0}\t{1}\n", day.date.ToString(), day.astrodata.moon.longitude_deg);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("moon.latitude_deg {0}\t{1}\n", day.date.ToString(), day.astrodata.moon.latitude_deg);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("moon.right_ascession {0}\t{1}\n", day.date.ToString(), day.astrodata.moon.right_ascession);
            }
            foreach (GPCalendarDay day in calendar.m_pData)
            {
                sb.AppendFormat("moon.declination {0}\t{1}\n", day.date.ToString(), day.astrodata.moon.declination);
            }
            return(sb.ToString());
        }
예제 #9
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);
        }
예제 #10
0
        /// <summary>
        /// Main function of this class
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public bool ParseCommandArguments(string[] args)
        {
            GPLocationProvider loc = new GPLocationProvider();
            GPLocation         loc1 = new GPLocation();
            GPGregorianTime    vcStart = new GPGregorianTime(loc), vcEnd = new GPGregorianTime(loc);
            GPVedicTime        vaStart = new GPVedicTime(), vaEnd = new GPVedicTime();
            int    nCount;
            int    nReq = 0;
            string strFileOut = "";

            try
            {
                loc1.setLatitudeNorthPositive(0.0);
                loc1.setLongitudeEastPositive(0.0);
                loc1.setTimeZoneName("");
                loc.setDefaultLocation(loc1);
                vcStart.Clear();
                vcEnd         = vcStart;
                vaStart.tithi = vaStart.masa = vaStart.gyear = 0;
                vaEnd         = vaStart;
                nCount        = -1;

                int argc = args.Length;
                for (int i = 0; i < argc; i++)
                {
                    //TRACE2("arg %d = %s\n", i, args[i]);
                    if (args[i] == "-L")
                    {
                        if (argc >= i + 2)
                        {
                            loc1.setLongitudeString(args[i + 1]);
                            double lat   = 0.0;
                            double longi = 0.0;
                            GetArg_EarthPos(args[i + 1], ref lat, ref longi);
                            loc1.setLongitudeEastPositive(longi);
                            loc1.setLatitudeNorthPositive(lat);
                            //TRACE2("-L latitude=%f longitude=%f\n", loc.m_fLatitude, loc.m_fLongitude);
                        }
                        i++;
                    }
                    else if (args[i] == "-N")
                    {
                        if (argc >= i + 2)
                        {
                            loc1.setCity(args[i + 1]);
                            //TRACE1("-N name=%s\n", loc.m_strName);
                        }
                        i++;
                    }
                    else if (args[i] == "-SV")
                    {
                        if (argc >= i + 2)
                        {
                            GetArg_VaisnDate(args[i + 1], out vaStart);
                        }
                        i++;
                    }
                    else if (args[i] == "-SG")
                    {
                        if (argc >= i + 2)
                        {
                            GetArg_Date(args[i + 1], out vcStart);
                        }
                        i++;
                    }
                    else if (args[i] == "-ST")
                    {
                        if (argc >= i + 2)
                        {
                            GetArg_Time(args[i + 1], out vcStart);
                        }
                        i++;
                    }
                    else if (args[i] == "-EG")
                    {
                        if (argc >= i + 2)
                        {
                            GetArg_Date(args[i + 1], out vcEnd);
                            //AfxTrace("-EG day=%d month=%d year=%d\n", vcEnd.day, vcEnd.month, vcEnd.year);
                        }
                        i++;
                    }
                    else if (args[i] == "-EV")
                    {
                        if (argc >= i + 2)
                        {
                            GetArg_VaisnDate(args[i + 1], out vaEnd);
                            //AfxTrace("-EV tithi=%d masa=%d gyear=%d\n", vaEnd.tithi, vaEnd.masa, vaEnd.gyear);
                        }
                        i++;
                    }
                    else if (args[i] == "-EC")
                    {
                        if (argc >= i + 2)
                        {
                            int.TryParse(args[i + 1], out nCount);
                        }
                        i++;
                    }
                    else if (args[i] == "-TZ")
                    {
                        if (argc >= i + 2)
                        {
                            loc1.setTimeZoneName(args[i + 1]);
                        }
                        i++;
                    }
                    else if (args[i] == "-O")
                    {
                        if (argc >= i + 2)
                        {
                            strFileOut = args[i + 1];
                        }
                        i++;
                    }
                    else if (args[i] == "-R")
                    {
                        if (argc >= i + 2)
                        {
                            if (args[i + 1] == "calendar")
                            {
                                nReq = 10;
                            }
                            else if (args[i + 1] == "appday")
                            {
                                nReq = 11;
                            }
                            else if (args[i + 1] == "tithi")
                            {
                                nReq = 12;
                            }
                            else if (args[i + 1] == "sankranti")
                            {
                                nReq = 13;
                            }
                            else if (args[i + 1] == "naksatra")
                            {
                                nReq = 14;
                            }
                            else if (args[i + 1] == "firstday")
                            {
                                nReq = 15;
                            }
                            else if (args[i + 1] == "gcalendar")
                            {
                                nReq = 16;
                            }
                            else if (args[i + 1] == "gtithi")
                            {
                                nReq = 17;
                            }
                            else if (args[i + 1] == "next")
                            {
                                nReq = 18;
                            }
                            else if (args[i + 1] == "help")
                            {
                                nReq = 60;
                            }

                            /*else if (args[i+1] == "")
                             * {
                             * } else if (args[i+1] == "")
                             * {
                             * } else if (args[i+1] == "")
                             * {
                             * } else if (args[i+1] == "")
                             * {
                             * }*/
                        }
                        i++;
                    }
                }

                vcStart.setLocationProvider(loc);
                vcEnd.setLocationProvider(loc);

                switch (nReq)
                {
                case 10:
                case 13:
                case 14:
                    if (vcStart.getYear() == 0 && vaStart.gyear != 0)
                    {
                        GPEngine.VATIMEtoVCTIME(vaStart, out vcStart, loc);
                    }
                    if (vcEnd.getYear() == 0 && vaEnd.gyear != 0)
                    {
                        GPEngine.VATIMEtoVCTIME(vaEnd, out vcEnd, loc);
                    }
                    break;

                default:
                    break;
                }

                if (vcStart.getYear() != 0 && vcEnd.getYear() != 0 && nCount < 0)
                {
                    nCount = Convert.ToInt32(vcEnd.getJulianLocalNoon() - vcStart.getJulianLocalNoon());
                }

                if (nCount < 0)
                {
                    nCount = 30;
                }

                GPAppDayResults   appday   = new GPAppDayResults();
                GPCalendarResults calendar = new GPCalendarResults();
                //AfxTrace("Count === %d\n", nCount);

                StringBuilder fout = new StringBuilder();
                switch (nReq)
                {
                case 10:
                    // -R -O -LAT -LON -SG -C [-DST -NAME]
                    vcStart.NextDay();
                    vcStart.PreviousDay();
                    calendar.CalculateCalendar(vcStart, nCount);
                    FormaterXml.WriteXml(FormaterXml.GetCalendarXmlDocument(calendar), fout);
                    break;

                case 11:
                    // -R -O -LAT -LON -SG -ST [-NAME]
                    appday.calculateAppearanceDayData(loc, vcStart);
                    FormaterXml.FormatAppDayXML(appday, fout);
                    break;

                case 12:
                    FormaterXml.WriteXML_Tithi(fout, loc, vcStart);
                    break;

                case 13:
                    if (vcEnd.getYear() == 0)
                    {
                        vcEnd = vcStart;
                        vcEnd.AddDays(nCount);
                    }
                    FormaterXml.WriteXml(FormaterXml.GetSankrantiXml(loc, vcStart, vcEnd), fout);
                    break;

                case 14:
                    FormaterXml.WriteXML_Naksatra(fout, loc, vcStart, nCount);
                    break;

                case 15:
                    FormaterXml.WriteXML_FirstDay_Year(fout, vcStart);
                    break;

                case 16:
                    vcStart = GPGaurabdaYear.getFirstDayOfYear(loc, vcStart.getYear());
                    vcEnd   = GPGaurabdaYear.getFirstDayOfYear(loc, vcStart.getYear() + 1);
                    nCount  = Convert.ToInt32(vcEnd.getJulianLocalNoon() - vcStart.getJulianLocalNoon());
                    calendar.CalculateCalendar(vcStart, nCount);
                    FormaterXml.WriteXml(FormaterXml.GetCalendarXmlDocument(calendar), fout);
                    break;

                case 17:
                    FormaterXml.WriteXML_GaurabdaTithi(fout, loc, vaStart, vaEnd);
                    break;

                case 18:
                    FormaterXml.WriteXML_GaurabdaNextTithi(fout, loc, vcStart, vaStart);
                    break;
                }
                // application should be windowless
                // since some parameters are present

                File.WriteAllText(strFileOut, fout.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception during execution: " + ex.Message);
            }

            return(true);
        }
예제 #11
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);
        }
예제 #12
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);
        }
예제 #13
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);
        }
예제 #14
0
파일: CELSearch.cs 프로젝트: vijeetgv/GCAL
        protected override void Execute()
        {
            ResultsList.Clear();
            //ClearControlList();
            int limit;

            if (Location == null || p_text == null || p_text.Length == 0)
            {
                return;
            }
            // find in texts

            StringBuilder   sb  = new StringBuilder();
            Results         res = new Results(this, p_text);
            GPGregorianTime vc  = new GPGregorianTime(Location);

            vc.Today();

            //
            // today results (this day, tomorrow and day after
            //
            #region today screen results
            limit = GPUserDefaults.IntForKey("search.today.days", 3);
            for (int i = 0; i < limit; i++)
            {
                sb.Remove(0, sb.Length);
                FormaterPlain.AvcGetTodayInfo(vc, Location, sb);
                res.Title = GPAppHelper.getDateText(vc);
                res.Type  = GPStrings.getString(174);
                res.ScanText(p_text, sb);
                if (res.Lines.Count > 0)
                {
                    res.Operation = GPCalculationOperation.Today;
                    res.Parameters.Add(GPCalculationParameters.LocationProvider, Location);
                    res.Parameters.Add(GPCalculationParameters.StartWesternDate, vc.Copy());
                    res.ActionScript += string.Format("scriptObject.setMyDate({0},{1},{2});", vc.getYear(), vc.getMonth(), vc.getDay());
                    res.ActionScript += "window.location.href='today.html'";
                    ResultsList.Add(res);
                    res = new Results(this, p_text);
                }
                vc.NextDay();
            }

            // move results to control
            if (!ShouldCancel)
            {
                FlushResultsToControl();
            }

            #endregion

            #region calendar results
            limit = GPUserDefaults.IntForKey("search.calendar.months", 12);
            GPCalendarResults rcal = new GPCalendarResults();

            vc.Today();
            vc.AddDays(1 - vc.getDay());
            for (int i = 0; i < limit; i++)
            {
                rcal.CalculateCalendar(vc, GPGregorianTime.GetMonthMaxDays(vc.getYear(), vc.getMonth()));
                FormaterPlain.FormatCalendarPlain(rcal, sb);
                res.Title = string.Format("{0} {1}", GPStrings.getString(759 + vc.getMonth()), vc.getYear());
                res.Type  = GPStrings.getString(44);
                res.ScanText(p_text, sb);
                if (res.Lines.Count > 0)
                {
                    res.Operation = GPCalculationOperation.Calendar;
                    res.Parameters.Add(GPCalculationParameters.LocationProvider, Location);
                    res.Parameters.Add(GPCalculationParameters.StartWesternDate, vc.Copy());
                    GPGregorianTime vc2 = vc.Copy();
                    vc2.AddMonths(1);
                    res.Parameters.Add(GPCalculationParameters.EndWesternDate, vc2);
                    res.ActionScript += "saveString('locationtype', 'mylocation');";
                    res.ActionScript += "saveString('startyear', '" + vc.getYear() + "');";
                    res.ActionScript += "saveString('startmonth', '" + vc.getMonth() + "');";
                    res.ActionScript += "saveString('startday', '" + vc.getDay() + "');";
                    res.ActionScript += "saveString('endperiodtype', '3');";
                    res.ActionScript += "saveString('endperiodlength', '1');";
                    res.ActionScript += "window.location.href='calendar.html'";
                    ResultsList.Add(res);
                    res = new Results(this, p_text);
                }
                vc.AddMonths(1);
            }

            // move results to control
            if (!ShouldCancel)
            {
                FlushResultsToControl();
            }

            #endregion

            #region core events results
            limit = GPUserDefaults.IntForKey("search.coreevents.months", 1);
            GPCoreEventResults reve = new GPCoreEventResults();
            vc.Today();
            vc.AddDays(1 - vc.getDay());
            for (int i = 0; i < limit; i++)
            {
                sb.Remove(0, sb.Length);
                GPGregorianTime vcEnd = vc.Copy();
                vcEnd.AddDays(31);
                reve.CalculateEvents(Location, vc, vcEnd);
                FormaterPlain.FormatEventsText(reve, sb);
                res.Title = string.Format("{0} {1}", GPStrings.getString(759 + vc.getMonth()), vc.getYear());
                res.Type  = GPStrings.getString(46);
                res.ScanText(p_text, sb);
                if (res.Lines.Count > 0)
                {
                    res.Operation = GPCalculationOperation.CoreEvents;
                    res.Parameters.Add(GPCalculationParameters.LocationProvider, Location);
                    res.Parameters.Add(GPCalculationParameters.StartWesternDate, vc.Copy());
                    res.Parameters.Add(GPCalculationParameters.EndWesternDate, vcEnd);
                    res.ActionScript += "saveString('locationtype', 'mylocation');";
                    res.ActionScript += "saveString('startyear', '" + vc.getYear() + "');";
                    res.ActionScript += "saveString('startmonth', '" + vc.getMonth() + "');";
                    res.ActionScript += "saveString('startday', '" + vc.getDay() + "');";
                    res.ActionScript += "saveString('endperiodtype', '3');";
                    res.ActionScript += "saveString('endperiodlength', '1');";
                    res.ActionScript += "window.location.href='coreevents.html'";
                    ResultsList.Add(res);
                    res = new Results(this, p_text);
                }
                vc.AddMonths(1);
            }

            // move results to control
            if (!ShouldCancel)
            {
                FlushResultsToControl();
            }

            #endregion

            #region masa list
            limit = GPUserDefaults.IntForKey("search.masalist.years", 3);
            GPMasaListResults rmas = new GPMasaListResults();
            vc.Today();
            for (int i = 0; i < limit; i++)
            {
                sb.Remove(0, sb.Length);
                rmas.CalcMasaList(Location, vc.getYear(), 1);
                FormaterPlain.FormatMasaListText(rmas, sb);
                res.Title = string.Format("{0}", vc.getYear());
                res.Type  = GPStrings.getString(48);
                res.ScanText(p_text, sb);
                if (res.Lines.Count > 0)
                {
                    res.Operation = GPCalculationOperation.MasaList;
                    res.Parameters.Add(GPCalculationParameters.LocationProvider, Location);
                    res.Parameters.Add(GPCalculationParameters.StartYear, vc.getYear());
                    res.Parameters.Add(GPCalculationParameters.CountYear, 1);
                    res.ActionScript += "saveString('locationtype', 'mylocation');";
                    res.ActionScript += "saveString('startyear', '" + vc.getYear() + "');";
                    res.ActionScript += "saveString('yearcount', '1');";
                    res.ActionScript += "window.location.href='masalist.html'";
                    ResultsList.Add(res);
                    res = new Results(this, p_text);
                }
                vc.AddYears(1);
            }

            // move results to control
            if (!ShouldCancel)
            {
                FlushResultsToControl();
            }

            #endregion

            finished = true;
        }
예제 #15
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);
        }
예제 #16
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);
        }
예제 #17
0
 // flag for validity
 public GPCalendarDay(GPLocationProvider aLoc, GPCalendarResults res, int nIndex)
 {
     p_location     = aLoc;
     resultCalendar = res;
     indexInArray   = nIndex;
 }
예제 #18
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);
        }
예제 #19
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);
        }
예제 #20
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();
        }
예제 #21
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);
        }