Ejemplo n.º 1
0
        public void AddRating(double julianDate, GCLocation loc, GCConfigRatedEntry now, GCConfigRatedEntry prev)
        {
            double        offsetHours = loc.OffsetUtcHours;
            GCRatedMoment ma          = new GCRatedMoment();

            ma.JulianDay = new GregorianDateTime();
            ma.JulianDay.SetFromJulian(julianDate);
            ma.JulianDay.TimezoneHours = offsetHours;
            double biasHours = loc.TimeZone.GetBiasMinutesForDay(ma.JulianDay) / 60.0;

            ma.JulianDay.shour         += biasHours / 24.0;
            ma.JulianDay.TimezoneHours += biasHours;
            ma.JulianDay.NormalizeValues();
            //m.Entry = now;
            ma.Title  = now.Title;
            ma.Rating = now.Rating;
            ma.Note   = now.Note;
            ma.Key    = now.Key;
            p_ratings.Add(ma);

            if (now.Margins != null)
            {
                int counter = 0;
                foreach (GCConfigRatedMargin e in now.Margins)
                {
                    if (e.Rating != 0.0)
                    {
                        GCRatedMoment m = new GCRatedMoment();
                        //m.Entry = e;
                        m.Title     = e.Title;
                        m.Rating    = e.Rating;
                        m.Note      = e.Note;
                        m.JulianDay = new GregorianDateTime();
                        m.JulianDay.SetFromJulian(julianDate + e.OffsetMinutesStart / 1440.0);
                        m.JulianDay.TimezoneHours = offsetHours;
                        m.Key = now.Key + ".s" + counter.ToString();
                        p_ratings.Add(m);

                        m = new GCRatedMoment();
                        //m.Entry = e;
                        m.Title     = "";
                        m.Rating    = 0.0;
                        m.Note      = null;
                        m.Key       = now.Key + ".s" + counter.ToString();
                        m.JulianDay = new GregorianDateTime();
                        m.JulianDay.SetFromJulian(julianDate + e.OffsetMinutesEnd / 1440.0);
                        m.JulianDay.TimezoneHours = offsetHours;
                        p_ratings.Add(m);
                    }
                    counter++;
                }
            }
        }
Ejemplo n.º 2
0
        public void AddRating(GregorianDateTime julian, GCConfigRatedEntry now, GCConfigRatedEntry prev)
        {
            if (prev.Rating != now.Rating || now.Rating != 0.0)
            {
                GCRatedMoment m = new GCRatedMoment();
                m.JulianDay = new GregorianDateTime(julian);
                //m.Entry = now;
                m.Title  = now.Title;
                m.Rating = now.Rating;
                m.Note   = now.Note;
                m.Key    = now.Key;
                p_ratings.Add(m);
            }

            if (now.Margins != null)
            {
                int counter = 0;
                foreach (GCConfigRatedMargin e in now.Margins)
                {
                    if (e.Rating != 0.0)
                    {
                        GCRatedMoment m = new GCRatedMoment();
                        //m.Entry = e;
                        m.Title     = e.Title;
                        m.Rating    = e.Rating;
                        m.Note      = e.Note;
                        m.JulianDay = julian.TimeWithOffset(e.OffsetMinutesStart / 1440.0);
                        m.Key       = now.Key + ".s" + counter.ToString();
                        p_ratings.Add(m);

                        m = new GCRatedMoment();
                        //m.Entry = e;
                        m.Title     = "";
                        m.Rating    = 0.0;
                        m.Note      = null;
                        m.Key       = now.Key + ".s" + counter.ToString();
                        m.JulianDay = julian.TimeWithOffset(e.OffsetMinutesEnd / 1440.0);
                        p_ratings.Add(m);
                    }
                    counter++;
                }
            }
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loading configuration from file
        /// </summary>
        /// <param name="fileName"></param>
        public void Load(string fileName)
        {
            FileName = fileName;

            using (StreamReader sr = new StreamReader(fileName))
            {
                List <ParameterDescriptor> ar = this.ParameterDescriptions;
                ParameterDescriptor        a;
                GCConfigRatedEntry         lastEntry = null;
                int            idx, idx2;
                GCRichFileLine rf = new GCRichFileLine();
                while (rf.SetLine(sr.ReadLine()))
                {
                    a = GetArrayRef(ar, rf.GetField(0));
                    try
                    {
                        if (rf.TagInt == 1)
                        {
                            idx = rf.GetFieldInt(1);
                            a.Array[idx].Rating = rf.GetFieldDouble(2);
                            a.Array[idx].Note   = rf.GetField(3);
                            lastEntry           = a.Array[idx];
                        }
                        else if (rf.TagInt == 2)
                        {
                            idx  = rf.GetFieldInt(1);
                            idx2 = rf.GetFieldInt(2);
                            a.Array2[idx, idx2].Rating = rf.GetFieldDouble(3);
                            a.Array2[idx, idx2].Note   = rf.GetField(4);
                            lastEntry = a.Array2[idx, idx2];
                        }
                        else if (rf.TagInt == 3)
                        {
                            useAcceptLimit = bool.Parse(rf.GetField(0));
                            acceptLimit    = rf.GetFieldDouble(1);
                        }
                        else if (rf.TagInt == 4)
                        {
                            useMinPeriodLength = bool.Parse(rf.GetField(0));
                            minPeriodLength    = rf.GetFieldDouble(1);
                        }
                        else if (rf.TagInt == 5)
                        {
                            Title = GCFestivalBase.SafeToString(rf.GetField(0));
                        }
                        else if (rf.TagInt == 6)
                        {
                            Description = GCFestivalBase.SafeToString(rf.GetField(0));
                        }
                        else if (rf.TagInt == 99 && lastEntry != null)
                        {
                            GCConfigRatedMargin m = new GCConfigRatedMargin();
                            m.Title              = GCFestivalBase.SafeToString(rf.GetField(0));
                            m.Rating             = rf.GetFieldDouble(1);
                            m.OffsetMinutesStart = rf.GetFieldInt(2);
                            m.OffsetMinutesEnd   = rf.GetFieldInt(3);
                            m.Note = GCFestivalBase.SafeToString(rf.GetField(4));
                            lastEntry.AddMargin(m);
                        }
                    }
                    catch
                    {
                    }
                }
            }
        }