コード例 #1
0
        public static XmlDocument GetSankrantiListXml(GCLocation loc, GregorianDateTime vcStart, GregorianDateTime vcEnd)
        {
            GregorianDateTime d = new GregorianDateTime();
            int zodiac;

            XmlDocument doc = new XmlDocument();
            XmlElement  e1  = doc.CreateElement("xml");

            doc.AppendChild(e1);
            XmlElement  e2, e3;
            GCEarthData earth = loc.GetEarthData();

            // open file
            d.Set(vcStart);

            e2 = doc.CreateElement("request");
            e1.AppendChild(e2);
            e2.SetAttribute("name", "Sankranti");
            e2.SetAttribute("version", GCStrings.getString(130));

            e2.SetAttribute("longitude", loc.Longitude.ToString());
            e2.SetAttribute("latitude", loc.Latitude.ToString());
            e2.SetAttribute("timezone", loc.OffsetUtcHours.ToString());
            e2.SetAttribute("startdate", vcStart.ToString());
            e2.SetAttribute("enddate", vcEnd.ToString());

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

            while (d.IsBeforeThis(vcEnd))
            {
                d.Set(GCSankranti.GetNextSankranti(d, earth, out zodiac));
                d.InitWeekDay();

                e3 = doc.CreateElement("sank");
                e2.AppendChild(e3);

                e3.SetAttribute("date", d.ToString());
                e3.SetAttribute("dayweekid", d.dayOfWeek.ToString());
                e3.SetAttribute("dayweek", GCCalendar.GetWeekdayName(d.dayOfWeek));
                e3.SetAttribute("time", d.LongTimeString());
                e3.SetAttribute("rasi", zodiac.ToString());
                e3.SetAttribute("rasiName", GCRasi.GetName(zodiac));
                e3.SetAttribute("rasiNameEn", GCRasi.GetNameEn(zodiac));

                d.NextDay();
                d.NextDay();
            }

            return(doc);
        }
コード例 #2
0
        public override GSCore GetPropertyValue(string s)
        {
            switch (s)
            {
            case "nType":
                return(new GSNumber(nType));

            case "nData":
                return(new GSNumber(nType));

            case "Time":
                return(Time);

            case "nDst":
                return(new GSNumber(nDst));

            case "tithiName":
                return(new GSString(GCTithi.GetName(nData)));

            case "naksatraName":
                return(new GSString(GCNaksatra.GetName(nData)));

            case "rasiName":
                return(new GSString(GCRasi.GetName(nData)));

            case "groupNameString":
                return(new GSString(GetTypeString(nType)));

            case "typeString":
                return(new GSString(GetTypeString(nType, nData)));

            case "dstSignature":
                return(new GSString(GCStrings.GetDSTSignature(nDst)));

            default:
                return(base.GetPropertyValue(s));
            }
        }
コード例 #3
0
        public void CalculateEvents(GCLocation loc, int nYear)
        {
            //GCSunData sun = new GCSunData();
            //DstTypeChange ndst = DstTypeChange.DstOff;
            int nData;

            TResultCoreEvents inEvents = this;

            this.Clear();
            this.EarthLocation = loc;
            this.Year          = nYear;
            GregorianDateTime vcStart = new GregorianDateTime(Year - 1, 12, 29);
            GregorianDateTime vcEnd   = new GregorianDateTime(Year + 1, 1, 2);

            GregorianDateTime vc = new GregorianDateTime();
            GregorianDateTime vcAdd = new GregorianDateTime(), vcNext = new GregorianDateTime();
            GCEarthData       earth = loc.GetEarthData();

            vc.Set(vcStart);
            vc.TimezoneHours = loc.OffsetUtcHours;
            vcAdd.Set(vc);
            vcAdd.InitWeekDay();

            /*while (vcAdd.IsBeforeThis(vcEnd))
             * {
             *  ndst = loc.TimeZone.DetermineDaylightChange(vcAdd);
             *  vcAdd.NextDay();
             * }*/


            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_TITHI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_NAKSATRA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YOGA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SANKRANTI) != 0)
            {
                vcNext = new GregorianDateTime();
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData));
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOONRASI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCMoonData.GetNextMoonRasi(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RASI, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.5;
                    vcAdd.NormalizeValues();
                }
            }
            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_CONJUNCTION) != 0)
            {
                double dlong;
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    dlong = GCConjunction.GetNextConjunction(vcAdd, out vcNext, true, earth);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_CONJ, GCRasi.GetRasi(dlong, GCAyanamsha.GetAyanamsa(vcNext.GetJulianComplete())));
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            inEvents.Sort();
        }
コード例 #4
0
        public static void Export(string pszFile, int format)
        {
            String strc;

            using (StreamWriter f = new StreamWriter(pszFile))
            {
                foreach (GCFestivalBook book in GCFestivalBookCollection.Books)
                {
                    switch (format)
                    {
                    case 1:
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("{0}\n\t{1} Tithi,{2} Paksa,{3} Masa\n", pce.Text,
                                                     GCTithi.GetName(pce.nTithi), GCPaksa.GetName(pce.nTithi / 15), GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                                if (pce.FastID != 0)
                                {
                                    strc = string.Format("\t{0}\n", GCStrings.GetFastingName(pce.FastID));
                                    f.Write(strc);
                                }
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write(string.Format("{0}\n\t\t{1} Sankranti, {2}\n", se.Text, GCRasi.GetName(se.RasiOfSun), se.DayOffset));
                            }
                        }

                        break;

                    case 2:
                    {
                        f.Write("<xml>\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t<event>\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("\t\t<name>{0}</name>\n", pce.Text);
                                f.Write(strc);
                                strc = string.Format("\t\t<tithi>{0}</tithi>\n", GCTithi.GetName(pce.nTithi));
                                f.Write(strc);
                                strc = string.Format("\t\t<paksa>{0}</paksa>\n", GCPaksa.GetName(pce.nTithi / 15));
                                f.Write(strc);
                                strc = string.Format("\t\t<masa>{0}</masa>\n", GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t<name>" + se.Text + "</name>\n");
                                f.Write("\t\t<sankranti>" + GCRasi.GetName(se.RasiOfSun) + "</sankranti>\n");
                                f.Write("\t\t<rel>" + se.DayOffset + "</rel>\n");
                            }

                            if (fb.EventsCount > 0)
                            {
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t<relatedEvent>\n");
                                        f.Write("\t\t\t<name>" + rel.Text + "</name>\n");
                                        f.Write("\t\t\t<offset>" + rel.DayOffset + "</offset>\n");
                                        f.Write("\t\t</relatedEvent>\n");
                                    }
                                }
                            }

                            f.Write("\t</event>\n");
                        }

                        f.Write("</xml>\n");
                    }
                    break;

                    case 3:
                        GSScript script = new GSScript();
                        script.Add(new GSToken("book"));
                        script.Add(new GSList(new GSToken("bookId"), new GSNumber(book.CollectionId)));
                        script.Add(new GSList(new GSToken("bookName"), new GSString(book.CollectionName)));
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            script.Add(fb.ExecuteMessage("getScript"));
                        }
                        script.writeScript(f);
                        break;

                    case 15:
                    {
                        f.Write("{\n");
                        f.Write("\tname: \"" + book.CollectionName + "\",\n");
                        f.Write("\tbookid: " + book.CollectionId + ",\n");
                        f.Write("\tevents: [\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t\t{\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                f.Write("\t\t\ttype: \"T\",\n");
                                f.Write("\t\t\tname: \"{0}\",\n", pce.Text);
                                f.Write("\t\t\ttithi: {0},\n", pce.nTithi);
                                f.Write("\t\t\tmasa: {0}\n", pce.nMasa);
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", pce.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", pce.FastID);
                                f.Write("\t\t\tstart: {0},\n", pce.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", pce.DayOffset);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t\ttype:\"S\",\n");
                                f.Write("\t\t\tname: \"" + se.Text + "\",\n");
                                f.Write("\t\t\tsankranti: " + se.RasiOfSun + ",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }
                            else if (fb is GCFestivalSpecial)
                            {
                                GCFestivalSpecial spe = fb as GCFestivalSpecial;
                                f.Write("\t\t\ttype: \"X\",\n");
                                f.Write("\t\t\tname: \"" + spe.Text + "\",\n");
                                f.Write("\t\t\tmasa1: " + spe.nMasaMin + ",\n");
                                f.Write("\t\t\tmasa2: " + spe.nMasaMax + ",\n");
                                f.Write("\t\t\tscript: \"" + spe.Script + "\",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }
                            else if (fb is GCFestivalEkadasi)
                            {
                                GCFestivalEkadasi se = fb as GCFestivalEkadasi;
                                f.Write("\t\t\ttype: \"E\",\n");
                                f.Write("\t\t\tname: \"" + se.Text + "\",\n");
                                f.Write("\t\t\tmasa: " + se.nMasa + ",\n");
                                f.Write("\t\t\tpaksa: " + se.nPaksa + ",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }

                            if (fb.EventsCount > 0)
                            {
                                f.Write("\t\t\tevents: [\n");
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t\t\t{\n\t\t\t\t\ttype:\"R\",\n");
                                        f.Write("\t\t\t\t\tname: \"" + rel.Text + "\",\n");
                                        f.Write("\t\t\t\t\tfastSubj: \"{0}\",\n", fb2.FastingSubject);
                                        f.Write("\t\t\t\t\tfast: {0},\n", fb2.FastID);
                                        f.Write("\t\t\t\t\tstart: {0},\n", fb2.StartYear);
                                        f.Write("\t\t\t\t\tdayoff: {0},\n", fb2.DayOffset);
                                        f.Write("\t\t\t\t},\n");
                                    }
                                }
                                f.Write("\t\t\t]");
                            }

                            f.Write("\t\t},\n");
                        }

                        f.Write("\t]\n");
                        f.Write("},\n");
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }
コード例 #5
0
        public string Format(string format, params string[] args)
        {
            StringBuilder sb = new StringBuilder(format);

            if (format.IndexOf("{day}") >= 0)
            {
                format = format.Replace("{day}", date.day.ToString());
            }
            if (format.IndexOf("{month}") >= 0)
            {
                format = format.Replace("{month}", date.month.ToString());
            }
            if (format.IndexOf("{monthAbr}") >= 0)
            {
                format = format.Replace("{monthAbr}", GregorianDateTime.GetMonthName(date.month));
            }
            if (format.IndexOf("{monthName}") >= 0)
            {
                format = format.Replace("{monthName}", GregorianDateTime.GetMonthName(date.month));
            }
            if (format.IndexOf("{year}") >= 0)
            {
                format = format.Replace("{year}", date.year.ToString());
            }
            if (format.IndexOf("{hour}") >= 0)
            {
                format = format.Replace("{hour}", date.GetHour().ToString("D2"));
            }
            if (format.IndexOf("{min}") >= 0)
            {
                format = format.Replace("{min}", date.GetMinute().ToString("D2"));
            }
            if (format.IndexOf("{minRound}") >= 0)
            {
                format = format.Replace("{minRound}", date.GetMinuteRound().ToString("D2"));
            }
            if (format.IndexOf("{sec}") >= 0)
            {
                format = format.Replace("{sec}", date.GetSecond().ToString("D2"));
            }

            if (format.IndexOf("{masaName}") >= 0)
            {
                format = format.Replace("{masaName}", GCMasa.GetName(astrodata.Masa));
            }
            if (format.IndexOf("{gaurabdaYear}") >= 0)
            {
                format = format.Replace("{gaurabdaYear}", astrodata.GaurabdaYear.ToString());
            }
            if (format.IndexOf("{tithiName}") >= 0)
            {
                format = format.Replace("{tithiName}", GCTithi.GetName(astrodata.sunRise.Tithi));
            }
            if (format.IndexOf("{prevTithiName}") >= 0)
            {
                format = format.Replace("{prevTithiName}", GCTithi.GetName((astrodata.sunRise.Tithi + 29) % 30));
            }
            if (format.IndexOf("{nextTithiName}") >= 0)
            {
                format = format.Replace("{nextTithiName}", GCTithi.GetName((astrodata.sunRise.Tithi + 1) % 30));
            }
            if (format.IndexOf("{paksaName}") >= 0)
            {
                format = format.Replace("{paksaName}", GCPaksa.GetName(astrodata.sunRise.Paksa));
            }
            if (format.IndexOf("{yogaName}") >= 0)
            {
                format = format.Replace("{yogaName}", GCYoga.GetName(astrodata.sunRise.Yoga));
            }
            if (format.IndexOf("{naksatraName}") >= 0)
            {
                format = format.Replace("{naksatraName}", GCNaksatra.GetName(astrodata.sunRise.Naksatra));
            }
            if (format.IndexOf("{naksatraElapse}") >= 0)
            {
                format = format.Replace("{naksatraElapse}", astrodata.sunRise.NaksatraElapse.ToString("P2"));
            }
            if (format.IndexOf("{naksatraPada}") >= 0)
            {
                format = format.Replace("{naksatraPada}", GCNaksatra.GetPadaText(astrodata.sunRise.NaksatraPada));
            }

            if (format.IndexOf("{sankranti.day}") >= 0)
            {
                format = format.Replace("{sankranti.day}", sankranti_day.day.ToString());
            }
            if (format.IndexOf("{sankranti.month}") >= 0)
            {
                format = format.Replace("{sankranti.month}", sankranti_day.month.ToString());
            }
            if (format.IndexOf("{sankranti.monthAbr}") >= 0)
            {
                format = format.Replace("{sankranti.monthAbr}", GregorianDateTime.GetMonthName(sankranti_day.month));
            }
            if (format.IndexOf("{sankranti.monthName}") >= 0)
            {
                format = format.Replace("{sankranti.monthName}", GregorianDateTime.GetMonthName(sankranti_day.month));
            }
            if (format.IndexOf("{sankranti.hour}") >= 0)
            {
                format = format.Replace("{sankranti.hour}", sankranti_day.GetHour().ToString("D2"));
            }
            if (format.IndexOf("{sankranti.min}") >= 0)
            {
                format = format.Replace("{sankranti.min}", sankranti_day.GetMinute().ToString("D2"));
            }
            if (format.IndexOf("{sankranti.minRound}") >= 0)
            {
                format = format.Replace("{sankranti.minRound}", sankranti_day.GetMinuteRound().ToString("D2"));
            }
            if (format.IndexOf("{sankranti.sec}") >= 0)
            {
                format = format.Replace("{sankranti.sec}", sankranti_day.GetSecond().ToString("D2"));
            }
            if (format.IndexOf("{sankranti.rasiNameEn}") >= 0)
            {
                format = format.Replace("{sankranti.rasiNameEn}", GCRasi.GetNameEn(sankranti_zodiac));
            }
            if (format.IndexOf("{sankranti.rasiName}") >= 0)
            {
                format = format.Replace("{sankranti.rasiName}", GCRasi.GetName(sankranti_zodiac));
            }

            if (format.IndexOf("{dstSig}") >= 0)
            {
                format = format.Replace("{dstSig}", GCStrings.GetDSTSignature(BiasMinutes));
            }

            if (format.IndexOf("{moonRiseTime}") >= 0)
            {
                format = format.Replace("{moonRiseTime}", moonrise.ToShortTimeString());
            }
            if (format.IndexOf("{moonSetTime}") >= 0)
            {
                format = format.Replace("{moonSetTime}", moonset.ToShortTimeString());
            }
            if (format.IndexOf("{moonRasiName}") >= 0)
            {
                format = format.Replace("{moonRasiName}", GCRasi.GetName(astrodata.sunRise.RasiOfMoon));
            }
            if (format.IndexOf("{moonRasiNameEn}") >= 0)
            {
                format = format.Replace("{moonRasiNameEn}", GCRasi.GetNameEn(astrodata.sunRise.RasiOfMoon));
            }

            if (args == null || args.Length == 0)
            {
                return(format.ToString());
            }
            else
            {
                return(string.Format(format.ToString(), args));
            }
        }
コード例 #6
0
        public static string GetTypeString(int nType, int nData)
        {
            switch (nType)
            {
            case CoreEventType.CCTYPE_ASCENDENT:
                return("Ascendent " + GCRasi.GetName(nData));

            case CoreEventType.CCTYPE_CONJ:
                return("Conjunction in " + GCRasi.GetName(nData));

            case CoreEventType.CCTYPE_DATE:
                return("Date");

            case CoreEventType.CCTYPE_DAY_MUHURTA:
                return(string.Format("{0} Muhurta", GCStrings.GetMuhurtaName(nData)));

            case CoreEventType.CCTYPE_DAY_OF_WEEK:
                return(GCCalendar.GetWeekdayName(nData));

            case CoreEventType.CCTYPE_KALA_END:
                return(string.Format("{0} ends", GCStrings.GetKalaName(nData)));

            case CoreEventType.CCTYPE_KALA_START:
                return(string.Format("{0} starts", GCStrings.GetKalaName(nData)));

            case CoreEventType.CCTYPE_M_RASI:
                return(string.Format("Moon in {0} rasi", GCRasi.GetName(nData)));

            case CoreEventType.CCTYPE_M_RISE:
                return("Moon rise");

            case CoreEventType.CCTYPE_M_SET:
                return("Moon set");

            case CoreEventType.CCTYPE_NAKS:
                return(string.Format("{0} Naksatra", GCNaksatra.GetName(nData)));

            case CoreEventType.CCTYPE_S_ARUN:
                return("Arunodaya");

            case CoreEventType.CCTYPE_S_MIDNIGHT:
                return("Midnight");

            case CoreEventType.CCTYPE_S_NOON:
                return("Noon");

            case CoreEventType.CCTYPE_S_RISE:
                return("Sunrise");

            case CoreEventType.CCTYPE_S_SET:
                return("Sunset");

            case CoreEventType.CCTYPE_SANK:
                return(string.Format("{0} Sankranti", GCRasi.GetName(nData)));

            case CoreEventType.CCTYPE_TITHI:
                return(string.Format("{0} Tithi", GCTithi.GetName(nData)));

            case CoreEventType.CCTYPE_YOGA:
                return(string.Format("{0} Yoga", GCYoga.GetName(nData)));

            default:
                return(string.Format("Unspecified event {0} / {1}", nType, nData));
            }
        }
コード例 #7
0
        public void CalculateEvents(GCLocation loc, GregorianDateTime vcStart, GregorianDateTime vcEnd)
        {
            //GCSunData sun = new GCSunData();
            DstTypeChange ndst = 0;
            int           nData;

            TResultEvents inEvents = this;

            this.Clear();
            this.EarthLocation = loc;
            this.StartDateTime = new GregorianDateTime(vcStart);
            this.EndDateTime   = new GregorianDateTime(vcEnd);

            GregorianDateTime vc = new GregorianDateTime();
            GregorianDateTime vcAdd = new GregorianDateTime(), vcNext = new GregorianDateTime();
            GCEarthData       earth = loc.GetEarthData();

            vc.Set(vcStart);
            vc.TimezoneHours = loc.OffsetUtcHours;
            vcAdd.Set(vc);
            vcAdd.InitWeekDay();

            GCHourTime sunriseData, sunsetData;
            double     sunRise, sunSet;
            double     r1, r2;

            while (vcAdd.IsBeforeThis(vcEnd))
            {
                sunriseData = GCSunData.CalcSunrise(vcAdd, earth);
                sunsetData  = GCSunData.CalcSunset(vcAdd, earth);
                sunRise     = sunriseData.TotalDays;
                sunSet      = sunsetData.TotalDays;
                ndst        = loc.TimeZone.DetermineDaylightChange(vcAdd);

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SUN) != 0)
                {
                    ndst = loc.TimeZone.DetermineDaylightChange(vcAdd);

                    vcAdd.shour = sunriseData.TotalDays - 96.0 / 1440.0;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_ARUN, 0, ndst);

                    vcAdd.shour = sunRise;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_RISE, 0, ndst);

                    vcAdd.shour = (sunRise + sunSet) / 2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_NOON, 0, ndst);

                    vcAdd.shour = sunSet;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_SET, 0, ndst);
                }

                /*if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
                 * {
                 *  todayLongitude = sun.longitude_deg;
                 *  vcAdd.shour = sunRise;
                 *  todaySunriseHour = sunRise;
                 *  if (previousLongitude < -10)
                 *  {
                 *      GregorianDateTime prevSunrise = new GregorianDateTime();
                 *      prevSunrise.Set(vcAdd);
                 *      prevSunrise.PreviousDay();
                 *      sun.SunCalc(prevSunrise, earth);
                 *      previousSunriseHour = sun.rise.GetDayTime() - 1;
                 *      previousLongitude = sun.longitude_deg;
                 *      fromTimeLimit = 0;
                 *  }
                 *
                 *  double a, b;
                 *  double jd = vcAdd.GetJulianComplete();
                 *  double ayan = GCAyanamsha.GetAyanamsa(jd);
                 *  r1 = GCMath.putIn360(previousLongitude - ayan) / 30;
                 *  r2 = GCMath.putIn360(todayLongitude - ayan) / 30;
                 *
                 *  while (r2 > r1 + 13)
                 *  {
                 *      r2 -= 12.0;
                 *  }
                 *  while (r2 < r1 + 11)
                 *  {
                 *      r2 += 12.0;
                 *  }
                 *
                 *  a = (r2 - r1) / (todaySunriseHour - previousSunriseHour);
                 *  b = r2 - a * todaySunriseHour;
                 *
                 *  for (double tr = Math.Floor(r1) + 1.0; tr < r2; tr += 1.0)
                 *  {
                 *      double tm = (tr - b) / a;
                 *      if (tm > fromTimeLimit)
                 *      {
                 *          vcNext.Set(vcAdd);
                 *          vcNext.shour = tm;
                 *          vcNext.NormalizeValues();
                 *          inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_ASCENDENT, (int)tr, ndst);
                 *      }
                 *  }
                 *
                 *  previousLongitude = todayLongitude;
                 *  previousSunriseHour = todaySunriseHour - 1;
                 *  fromTimeLimit = previousSunriseHour;
                 * }*/

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_RAHUKALAM) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_RAHU_KALAM);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_RAHU_KALAM, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_RAHU_KALAM, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YAMAGHANTI) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_YAMA_GHANTI);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_YAMA_GHANTI, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_YAMA_GHANTI, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_GULIKALAM) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_GULI_KALAM);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_GULI_KALAM, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_GULI_KALAM, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ABHIJIT_MUHURTA) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_ABHIJIT);

                    if (r1 > 0 && r2 > 0)
                    {
                        vcAdd.shour = r1;
                        inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_ABHIJIT, ndst);

                        vcAdd.shour = r2;
                        inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_ABHIJIT, ndst);
                    }
                }

                vcAdd.NextDay();
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
            {
                GCAscendant asc = new GCAscendant();
                asc.Earth           = EarthLocation.GetEarthData();
                asc.CurrentDateTime = new GregorianDateTime(vc);
                while (asc.GetNextAscendantBefore(vcEnd))
                {
                    ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                    inEvents.AddEvent(asc.CurrentDateTime, CoreEventType.CCTYPE_ASCENDENT, asc.CurrentSign, ndst);
                    asc.CurrentDateTime.AddHours(0.5);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_TITHI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_NAKSATRA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YOGA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SANKRANTI) != 0)
            {
                vcNext = new GregorianDateTime();
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData));
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOONRASI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCMoonData.GetNextMoonRasi(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RASI, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.5;
                    vcAdd.NormalizeValues();
                }
            }
            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_CONJUNCTION) != 0)
            {
                double dlong;
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    dlong = GCConjunction.GetNextConjunction(vcAdd, out vcNext, true, earth);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_CONJ, GCRasi.GetRasi(dlong, GCAyanamsha.GetAyanamsa(vcNext.GetJulianComplete())), ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOON) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCMoonData.GetNextRise(earth, vcAdd, true));
                    inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RISE, 0, ndst);

                    vcNext.Set(GCMoonData.GetNextRise(earth, vcNext, false));
                    inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_SET, 0, ndst);

                    vcNext.shour += 0.05;
                    vcNext.NormalizeValues();
                    vcAdd.Set(vcNext);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
            {/*
              *         vcAdd = vc;
              *         vcAdd.shour = 0.0;
              *         while(vcAdd.IsBeforeThis(vcEnd))
              *         {
              *                 nData = earth.GetNextAscendentStart(vcAdd, vcNext);
              *                 if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
              *                 {
              *                         vcNext.InitWeekDay();
              *                         ndst = TTimeZone.determineDaylightChange(vcNext, loc.m_nDST);
              *                         inEvents.AddEvent(vcNext, CCTYPE_ASCENDENT, nData, ndst);
              *                 }
              *                 else
              *                 {
              *                         break;
              *                 }
              *                 vcAdd = vcNext;
              *                 vcAdd.shour += 1/24.0;
              *                 if (vcAdd.shour >= 1.0)
              *                 {
              *                         vcAdd.shour -= 1.0;
              *                         vcAdd.NextDay();
              *                 }
              *         }
              *
              */
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SORT) != 0)
            {
                inEvents.Sort(SORTING_BY_DATE);
            }
            else
            {
                inEvents.Sort(SORTING_BY_TYPE);
            }
        }
コード例 #8
0
        public void calculateAppDay(GCLocation location, GregorianDateTime eventDate)
        {
            //MOONDATA moon;
            //SUNDATA sun;
            GCAstroData       d       = this.details = new GCAstroData();
            GregorianDateTime vc      = new GregorianDateTime();
            GregorianDateTime vcsun   = new GregorianDateTime();
            GCEarthData       m_earth = location.GetEarthData();

            vc.Set(eventDate);
            vcsun.Set(eventDate);

            this.b_adhika  = false;
            this.eventTime = new GregorianDateTime(eventDate);
            Location       = location;

            //d.nTithi = GetPrevTithiStart(m_earth, vc, dprev);
            //GetNextTithiStart(m_earth, vc, dnext);
            vcsun.shour -= vcsun.TimezoneHours / 24.0;
            vcsun.NormalizeValues();
            vcsun.TimezoneHours     = 0.0;
            d.sunRise               = new GCHourTime();
            d.sunRise.TotalDays     = vc.shour;
            d.sunRise.longitude     = GCCoreAstronomy.GetSunLongitude(vcsun, m_earth);
            d.sunRise.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(vcsun, m_earth);
            d.Ayanamsa              = GCAyanamsha.GetAyanamsa(vc.GetJulianComplete());
            d.sunRise.Ayanamsa      = d.Ayanamsa;

            // tithi


            d.Masa = d.MasaCalc(vc, m_earth);
            if (d.Masa == (int)MasaId.ADHIKA_MASA)
            {
                d.Masa        = d.sunRise.RasiOfSun;
                this.b_adhika = true;
            }

            vc.Today();
            vc.TimezoneHours = m_earth.OffsetUtcHours;
            int               m  = 0;
            GaurabdaDate      va = new GaurabdaDate();
            GregorianDateTime vctemp;

            va.tithi = d.sunRise.Tithi;
            va.masa  = d.Masa;
            va.gyear = GCCalendar.GetGaurabdaYear(vc, m_earth);
            if (va.gyear < d.GaurabdaYear)
            {
                va.gyear = d.GaurabdaYear;
            }

            MainInfo.Add(new AppDayInfo(GCStrings.getString(7), eventDate.ToString()));
            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDayInfo(GCStrings.getString(8), eventDate.ShortTimeString()));
            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDayInfo(GCStrings.getString(9), location.Title));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(10), location.GetLatitudeString()));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(11), location.GetLongitudeString()));
            MainInfo.Add(new AppDayInfo(GCStrings.Localized("Timezone"), location.TimeZoneName));
            MainInfo.Add(new AppDayInfo("DST", "N/A"));
            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDayInfo(GCStrings.getString(13), GCTithi.GetName(d.sunRise.Tithi)));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(14), string.Format("{0:00.000}%", d.sunRise.TithiElapse)));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(15), GCNaksatra.GetName(d.sunRise.Naksatra)));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(16), string.Format("{0:00.000}% ({1} pada)", d.sunRise.NaksatraElapse, GCStrings.getString(811 + d.sunRise.NaksatraPada))));
            MainInfo.Add(new AppDayInfo(GCStrings.Localized("Moon Rasi"), GCRasi.GetName(d.sunRise.RasiOfMoon)));
            MainInfo.Add(new AppDayInfo(GCStrings.Localized("Sun Rasi"), GCRasi.GetName(d.sunRise.RasiOfSun)));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(20), GCPaksa.GetName(d.sunRise.Paksa)));

            if (b_adhika == true)
            {
                MainInfo.Add(new AppDayInfo(GCStrings.getString(22), string.Format("{0} {1}", GCMasa.GetName(d.Masa), GCStrings.getString(21))));
            }
            else
            {
                MainInfo.Add(new AppDayInfo(GCStrings.getString(22), GCMasa.GetName(d.Masa)));
            }
            MainInfo.Add(new AppDayInfo(GCStrings.getString(23), d.GaurabdaYear.ToString()));

            if (GCDisplaySettings.Current.getValue(48) == 1)
            {
                MainInfo.Add(new AppDayBase(GCDS.APP_CHILDNAMES));
                MainInfo.Add(new AppDaySeparator(GCStrings.getString(17)));
                MainInfo.Add(new AppDayBase(GCDS.APP_CHILDNAMES));

                MainInfo.Add(new AppDayInfo(GCDS.APP_CHILDNAMES, GCStrings.getString(18), GCStrings.GetNaksatraChildSylable(d.sunRise.Naksatra, d.sunRise.NaksatraPada) + "..."));
                MainInfo.Add(new AppDayInfo(GCDS.APP_CHILDNAMES, GCStrings.getString(19), GCStrings.GetRasiChildSylable(d.sunRise.RasiOfMoon) + "..."));
            }

            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDaySeparator(GCStrings.getString(24)));
            MainInfo.Add(new AppDayBase());


            celeb_date = new GregorianDateTime[TRESULT_APP_CELEBS];
            celeb_gy   = new int[TRESULT_APP_CELEBS];

            for (int i = 0; i < TRESULT_APP_CELEBS + 3; i++)
            {
                GCCalendar.VATIMEtoVCTIME(va, out vctemp, m_earth);
                if (va.gyear > d.GaurabdaYear)
                {
                    if (m < TRESULT_APP_CELEBS)
                    {
                        MainInfo.Add(new AppDayInfo(string.Format("Gaurabda {0}", va.gyear), vctemp.ToString()));
                        this.celeb_date[m] = new GregorianDateTime(vctemp);
                        this.celeb_gy[m]   = va.gyear;
                        m++;
                    }
                }
                va.gyear++;
            }
        }
コード例 #9
0
 public override void updateListBoxEntry(GCListBoxEntry lb)
 {
     base.updateListBoxEntry(lb);
     lb.Subtitle = string.Format("{0} Sankranti, {1} days offset", GCRasi.GetName(RasiOfSun), DayOffset);
 }
コード例 #10
0
        public GCConfigRatedEvents()
        {
            int i;

            for (i = 0; i < 30; i++)
            {
                rateTithi[i]         = new GCConfigRatedEntry();
                rateTithi[i].Title   = string.Format("{0} Tithi", GCTithi.GetName(i));
                rateTithi[i].Key     = "Tithi";
                rateMuhurta[i]       = new GCConfigRatedEntry();
                rateMuhurta[i].Title = GCStrings.GetMuhurtaName(i);
                rateMuhurta[i].Key   = "Muhurta";
            }

            for (i = 0; i < 4; i++)
            {
                rateDayHours[i]       = new GCConfigRatedEntry();
                rateDayHours[i].Title = GCStrings.GetSandhyaName(i);
                rateDayHours[i].Key   = "DayHours";
            }

            for (i = 0; i < 2; i++)
            {
                rateDay[i]            = new GCConfigRatedEntry();
                rateDay[i].Title      = GCStrings.GetSandhyaName(i * 2);
                rateDay[i].Key        = "DayPart";
                rateMoonTime[i]       = new GCConfigRatedEntry();
                rateMoonTime[i].Title = GCStrings.GetMoonTimesName(i);
                rateMoonTime[i].Key   = "MoonTimes";
            }

            rateKalas[0] = new GCConfigRatedEntry();
            for (i = 1; i < 6; i++)
            {
                rateKalas[i]       = new GCConfigRatedEntry();
                rateKalas[i].Title = GCStrings.GetKalaName(i);
                rateKalas[i].Key   = string.Format("kala.{0}", i);
            }

            for (i = 0; i < 27; i++)
            {
                rateNaksatra[i]       = new GCConfigRatedEntry();
                rateNaksatra[i].Title = string.Format("{0} Naksatra", GCNaksatra.GetName(i));
                rateNaksatra[i].Key   = "Naksatra";
                rateYoga[i]           = new GCConfigRatedEntry();
                rateYoga[i].Title     = string.Format("{0} Yoga", GCYoga.GetName(i));
                rateYoga[i].Key       = "Yoga";
                for (int j = 0; j < 4; j++)
                {
                    rateNaksatraPada[i, j]       = new GCConfigRatedEntry();
                    rateNaksatraPada[i, j].Title = string.Format("{0} of {1}", GCNaksatra.GetPadaText(j), rateNaksatra[i].Title);
                    rateNaksatraPada[i, j].Key   = "NaksatraPada";
                }
            }

            for (i = 0; i < 7; i++)
            {
                weekday[i]       = new GCConfigRatedEntry();
                weekday[i].Title = string.Format("Weekday: {0}", GCCalendar.GetWeekdayName(i));
                weekday[i].Key   = "Weekday";
            }

            for (i = 0; i < 10; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    rateGrahaRasi[i, j]        = new GCConfigRatedEntry();
                    rateGrahaRasi[i, j].Title  = string.Format("{0} in {1}", GCStrings.GetPlanetNameEn(i), GCRasi.GetNameEn(j));
                    rateGrahaRasi[i, j].Key    = "RasiGraha." + GCStrings.GetPlanetNameEn(i);
                    rateGrahaHouse[i, j]       = new GCConfigRatedEntry();
                    rateGrahaHouse[i, j].Title = string.Format("{0} in house {1}", GCStrings.GetPlanetNameEn(i), j + 1);
                    rateGrahaHouse[i, j].Key   = "HouseGraha." + GCStrings.GetPlanetNameEn(i);

                    rateRasiGraha[j, i]  = rateGrahaRasi[i, j];
                    rateHouseGraha[j, i] = rateGrahaHouse[i, j];
                }
            }

            FileName = null;
        }
コード例 #11
0
        public static void Export(string pszFile, int format)
        {
            String strc;

            using (StreamWriter f = new StreamWriter(pszFile))
            {
                foreach (GCFestivalBook book in GCFestivalBookCollection.Books)
                {
                    switch (format)
                    {
                    case 1:
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("{0}\n\t{1} Tithi,{2} Paksa,{3} Masa\n", pce.Text,
                                                     GCTithi.GetName(pce.nTithi), GCPaksa.GetName(pce.nTithi / 15), GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                                if (pce.FastID != 0)
                                {
                                    strc = string.Format("\t{0}\n", GCStrings.GetFastingName(pce.FastID));
                                    f.Write(strc);
                                }
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write(string.Format("{0}\n\t\t{1} Sankranti, {2}\n", se.Text, GCRasi.GetName(se.RasiOfSun), se.DayOffset));
                            }
                        }

                        break;

                    case 2:
                    {
                        f.Write("<xml>\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t<event>\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("\t\t<name>{0}</name>\n", pce.Text);
                                f.Write(strc);
                                strc = string.Format("\t\t<tithi>{0}</tithi>\n", GCTithi.GetName(pce.nTithi));
                                f.Write(strc);
                                strc = string.Format("\t\t<paksa>{0}</paksa>\n", GCPaksa.GetName(pce.nTithi / 15));
                                f.Write(strc);
                                strc = string.Format("\t\t<masa>{0}</masa>\n", GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t<name>" + se.Text + "</name>\n");
                                f.Write("\t\t<sankranti>" + GCRasi.GetName(se.RasiOfSun) + "</sankranti>\n");
                                f.Write("\t\t<rel>" + se.DayOffset + "</rel>\n");
                            }

                            if (fb.EventsCount > 0)
                            {
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t<relatedEvent>\n");
                                        f.Write("\t\t\t<name>" + rel.Text + "</name>\n");
                                        f.Write("\t\t\t<offset>" + rel.DayOffset + "</offset>\n");
                                        f.Write("\t\t</relatedEvent>\n");
                                    }
                                }
                            }

                            f.Write("\t</event>\n");
                        }

                        f.Write("</xml>\n");
                    }
                    break;

                    case 3:
                        GSScript script = new GSScript();
                        script.Add(new GSToken("book"));
                        script.Add(new GSList(new GSToken("bookId"), new GSNumber(book.CollectionId)));
                        script.Add(new GSList(new GSToken("bookName"), new GSString(book.CollectionName)));
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            script.Add(fb.ExecuteMessage("getScript"));
                        }
                        script.writeScript(f);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
コード例 #12
0
ファイル: GCAstroData.cs プロジェクト: icfsoft/GCAL-NET-Core
        public override GSCore GetPropertyValue(string Token)
        {
            GSCore result = null;

            switch (Token)
            {
            case "tithi":
                result = new GSNumber()
                {
                    IntegerValue = sunRise.Tithi
                }; break;

            case "tithiElapsed":
                result = new GSNumber()
                {
                    DoubleValue = sunRise.TithiElapse
                }; break;

            case "tithiName":
                result = new GSString()
                {
                    Value = GCTithi.GetName(sunRise.Tithi)
                }; break;

            case "naksatra":
                result = new GSNumber()
                {
                    IntegerValue = sunRise.Naksatra
                }; break;

            case "naksatraElapsed":
                result = new GSNumber()
                {
                    DoubleValue = sunRise.NaksatraElapse
                }; break;

            case "naksatraName":
                result = new GSString()
                {
                    Value = GCNaksatra.GetName(sunRise.Naksatra)
                }; break;

            case "paksa":
                result = new GSNumber()
                {
                    IntegerValue = sunRise.Paksa
                }; break;

            case "paksaName":
                result = new GSString()
                {
                    Value = GCPaksa.GetName(sunRise.Paksa)
                }; break;

            case "paksaAbbr":
                result = new GSString()
                {
                    Value = GCPaksa.GetAbbr(sunRise.Paksa).ToString()
                }; break;

            case "yoga":
                result = new GSNumber()
                {
                    IntegerValue = sunRise.Yoga
                }; break;

            case "yogaName":
                result = new GSString()
                {
                    Value = GCYoga.GetName(sunRise.Yoga)
                }; break;

            case "masa":
                result = new GSNumber()
                {
                    IntegerValue = Masa
                }; break;

            case "masaName":
                result = new GSString()
                {
                    Value = GCMasa.GetName(Masa)
                }; break;

            case "masaNameVedic":
                result = new GSString()
                {
                    Value = GCMasa.GetNameEx(Masa, 2)
                }; break;

            case "masaNameGaudiya":
                result = new GSString()
                {
                    Value = GCMasa.GetNameEx(Masa, 0)
                }; break;

            case "gaurabdaYear":
                result = new GSNumber()
                {
                    IntegerValue = GaurabdaYear
                }; break;

            case "arunodayaTime":
                result = new GCHourTimeObject(sunArunodaya); break;

            case "arunodayaTithi":
                result = new GSString(GCTithi.GetName(sunArunodaya.Tithi)); break;

            case "sunRiseTime":
                result = new GCHourTimeObject(sunRise); break;

            case "noonTime":
                result = new GCHourTimeObject(sunNoon); break;

            case "sunSetTime":
                result = new GCHourTimeObject(sunSet); break;

            case "moonRasi":
                result = new GSNumber(sunRise.RasiOfMoon); break;

            case "moonRasiName":
                result = new GSString(GCRasi.GetName(sunRise.RasiOfMoon)); break;

            case "sunRasi":
                result = new GSNumber(sunRise.RasiOfSun); break;

            case "sunRasiName":
                result = new GSString(GCRasi.GetName(sunRise.RasiOfSun)); break;

            case "sunLongitude":
                result = new GSNumber(sunRise.longitude); break;

            default:
                result = base.GetPropertyValue(Token);
                break;
            }
            return(result);
        }
コード例 #13
0
ファイル: GCAstroData.cs プロジェクト: icfsoft/GCAL-NET-Core
        /*********************************************************************/
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public int MasaCalc(GregorianDateTime date, GCEarthData earth)
        {
            //	SUNDATA sun;
            //	MOONDATA moon;
            //	VCTIME Conj[6], ConjA;
            //	double Long[6], LongA;
            //	int Sank[6], SankA;

            const int PREV_MONTHS = 6;

            double[]            L = new double[8];
            GregorianDateTime[] C = new GregorianDateTime[8];
            int[] R = new int[8];
            int   n, rasi, masa = MasaId.VISNU_MASA;
            int   ksaya_from = -1;
            int   ksaya_to   = -1;

            date.shour = sunRise.TotalDays;

            // STEP 1: calculate position of the sun and moon
            // it is done by previous call of DayCalc
            // and results are in argument DAYDATA day
            // *DayCalc(date, earth, day, moon, sun);*

            L[1] = /*Long[0] =*/ GCConjunction.GetNextConjunction(date, out C[1], false, earth);
            L[0] = /*LongA   =*/ GCConjunction.GetNextConjunction(C[1], out C[0], true, earth);

            // on Pratipat (nTithi == 15) we need to look for previous conjunction
            // but this conjunction can occur on this date before sunrise
            // so we need to include this very date into looking for conjunction
            // on other days we cannot include it
            // and exclude it from looking for next because otherwise that will cause
            // incorrect detection of Purusottama adhika masa
            L[2] = GCConjunction.GetPrevConjunction(date, out C[2], false, earth);

            for (n = 3; n < PREV_MONTHS; n++)
            {
                L[n] = GCConjunction.GetPrevConjunction(C[n - 1], out C[n], true, earth);
            }

            for (n = 0; n < PREV_MONTHS; n++)
            {
                R[n] = GCRasi.GetRasi(L[n], GCAyanamsha.GetAyanamsa(C[n].GetJulian()));
            }

            /*	TRACE("TEST Date: %d %d %d ", date.day, date.month, date.year);
             *  TRACE("FOUND CONJ Date: %d %d %d rasi: %d ", C[1].day, C[1].month, C[1].year, R[1]);
             *  TRACE("FOUND CONJ Date: %d %d %d rasi: %d ", C[2].day, C[2].month, C[2].year, R[2]);
             *  TRACE("FOUND CONJ Date: %d %d %d rasi: %d ", C[3].day, C[3].month, C[3].year, R[3]);
             *  TRACE("FOUND CONJ Date: %d %d %d rasi: %d ", C[4].day, C[4].month, C[4].year, R[4]);
             *  TRACE("---
             */
            // test for Adhika-Ksaya sequence
            // this is like 1-2-2-4-5...
            // second (2) is replaced by rasi(3)

            /*	if ( ((Sank[1] + 2) % 12 == SankA) && ((Sank[1] == Sank[0]) || (Sank[0] == SankA)))
             *  {
             *      Sank[0] = (Sank[1] + 1) % 12;
             *  }
             *
             *  if ( ((Sank[2] + 2) % 12 == Sank[0]) && ((Sank[2] == Sank[1]) || (Sank[1] == Sank[0])))
             *  {
             *      Sank[1] = (Sank[2] + 1) % 12;
             *  }*/

            // look for ksaya month
            ksaya_from = -1;
            for (n = PREV_MONTHS - 2; n >= 0; n--)
            {
                if ((R[n + 1] + 2) % 12 == R[n])
                {
                    ksaya_from = n;
                    break;
                }
            }

            if (ksaya_from >= 0)
            {
                for (n = ksaya_from; n > 0; n--)
                {
                    if (R[n] == R[n - 1])
                    {
                        ksaya_to = n;
                        break;
                    }
                }

                if (ksaya_to >= 0)
                {
                    // adhika masa found
                    // now correct succession of rasis
                }
                else
                {
                    // adhika masa not found
                    // there will be some break in masa queue
                    ksaya_to = 0;
                }

                int current_rasi = R[ksaya_from + 1] + 1;
                for (n = ksaya_from; n >= ksaya_to; n--)
                {
                    R[n]         = current_rasi;
                    current_rasi = (current_rasi + 1) % 12;
                }
            }

            // STEP 3: test for adhika masa
            // test for adhika masa
            if (R[1] == R[2])
            {
                // it is adhika masa
                masa = 12;
                rasi = R[1];
            }
            else
            {
                // STEP 2. select nearest Conjunction
                if (this.sunRise.Paksa == 0)
                {
                    masa = R[1];
                }
                else if (this.sunRise.Paksa == 1)
                {
                    masa = R[2];
                }
                rasi = masa;
            }

            // calculation of Gaurabda year
            GaurabdaYear = date.year - 1486;

            if ((rasi > 7) && (rasi < 11)) // Visnu
            {
                if (date.month < 6)
                {
                    GaurabdaYear--;
                }
            }

            Masa = masa;

            return(masa);
        }