Ejemplo n.º 1
0
        /// <summary>
        /// Recalculation of sunrise time for given travelling
        /// </summary>
        /// <param name="sun"></param>
        /// <param name="locChange"></param>
        private static void recalculateSunriseTravel(GPSun sun, GPLocationChange locChange)
        {
            GPSun  newSun = new GPSun();
            double drStep = 0.5;
            double dr     = 0.0;
            int    steps  = 0;

            while (steps < 25)
            {
                GPLocation      lp = locChange.getTravellingLocation(dr);
                double          jd = locChange.julianStart + (locChange.julianEnd - locChange.julianStart) * dr;
                GPGregorianTime gt = new GPGregorianTime(lp);
                gt.setJulianGreenwichTime(jd);
                GPLocationProvider lpr = new GPLocationProvider(lp);
                newSun.calculateRise(sun.rise, lpr);
                newSun.updateSunriseTimes(sun.rise, lpr);

                if (gt.getJulianGreenwichTime() > newSun.rise.getJulianGreenwichTime())
                {
                    drStep = drStep / 2;
                    dr    -= drStep;
                }
                else
                {
                    dr += drStep;
                }

                steps++;
            }

            sun.rise                = newSun.rise;
            sun.sunrise_deg         = newSun.sunrise_deg;
            sun.eclipticalLongitude = newSun.eclipticalLongitude;
        }
Ejemplo n.º 2
0
        public bool readXmlNode(XmlElement elem)
        {
            changes = new List <GPLocationChange>();
            bool succ = false;

            foreach (XmlElement e1 in elem.ChildNodes)
            {
                if (e1.Name.Equals("Change"))
                {
                    GPLocationChange chng = new GPLocationChange();
                    chng.loadFromXmlNode(e1);
                    changes.Add(chng);
                }
                else if (e1.Name.Equals("DefaultLocation"))
                {
                    defaultLocation = new GPLocation();
                    defaultLocation.loadFromXmlNode(e1);
                    succ = true;

                    if (e1.HasAttribute("type"))
                    {
                        int i = TYPE_SELECTED;
                        if (int.TryParse(e1.GetAttribute("type"), out i))
                        {
                            this.setType(i);
                        }
                    }
                }
            }

            return(succ);
        }
Ejemplo n.º 3
0
        public List <GPLocation> getLocationList()
        {
            List <GPLocation> locList = new List <GPLocation>();

            double start = m_vcStart.getJulianGreenwichTime();
            double end   = m_vcEnd.getJulianGreenwichTime();

            if (m_location.getChangeCount() > 0)
            {
                for (int i = 0; i < m_location.getChangeCount(); i++)
                {
                    GPLocationChange lc = m_location.getChangeAtIndex(i);

                    if ((lc.julianStart >= start && lc.julianStart <= end) &&
                        (lc.julianEnd >= start && lc.julianEnd <= end))
                    {
                        addLocationToList(lc.LocationA, locList);
                        addLocationToList(lc.LocationB, locList);
                    }
                }
            }
            else
            {
                addLocationToList(m_location.getLocationAtIndex(0), locList);
            }

            return(locList);
        }
Ejemplo n.º 4
0
        public int getIndexForNewChange(double jend)
        {
            int i = 0;

            while (i < changes.Count)
            {
                GPLocationChange c = changes[i];
                if (c.julianStart > jend)
                {
                    return(i);
                }
                i++;
            }

            return(-1);
        }
Ejemplo n.º 5
0
        public void removeChangesInRange(double jstart, double jend)
        {
            int i = 0;

            while (i < changes.Count)
            {
                GPLocationChange c = changes[i];
                if (c.julianStart > jend || c.julianEnd < jstart)
                {
                    i++;
                }
                else
                {
                    changes.RemoveAt(i);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets location based on given julian day
        /// </summary>
        /// <param name="julianDay"></param>
        /// <returns></returns>
        public GPLocation getLocation(double julianDay)
        {
            if (changes.Count < 1)
            {
                return(defaultLocation);
            }
            double lastStart = 0;

            foreach (GPLocationChange lch in changes)
            {
                if (lch.julianStart > julianDay)
                {
                    currStart       = lastStart;
                    currEnd         = lch.julianStart;
                    currentLocation = lch.LocationA;
                    currentChange   = null;
                    return(currentLocation);
                }

                if (lch.julianStart <= julianDay && lch.julianEnd >= julianDay)
                {
                    currStart       = lch.julianStart;
                    currEnd         = lch.julianEnd;
                    currentLocation = null;
                    currentChange   = lch;
                    GPLocation lp = currentChange.getLocation(julianDay);
                    return(lp);
                }

                lastStart = lch.julianEnd;
            }

            int last = changes.Count - 1;

            if (changes[last].julianEnd < julianDay)
            {
                currStart       = changes[last].julianEnd;
                currEnd         = currStart + 2000000;
                currentLocation = changes[last].LocationB;
                return(currentLocation);
            }

            return(defaultLocation);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// recalculation of arunodaya time for given travelling
        /// </summary>
        /// <param name="sun"></param>
        /// <param name="locChange"></param>
        private static void recalculateArunodayaTravel(GPSun sun, GPLocationChange locChange)
        {
            GPSun  newSun = new GPSun();
            double drStep = 0.5;
            double dr     = 0.0;
            int    steps  = 0;

            while (steps < 25)
            {
                GPLocation      lp = locChange.getTravellingLocation(dr);
                double          jd = locChange.julianStart + (locChange.julianEnd - locChange.julianStart) * dr;
                GPGregorianTime gt = new GPGregorianTime(lp);
                gt.setJulianGreenwichTime(jd);
                GPLocationProvider lpr = new GPLocationProvider(lp);
                newSun.calculateRise(sun.rise, lpr);
                newSun.updateSunriseTimes(sun.rise, lpr);
                //                    Debugger.Log(0, "", String.Format("ROW: {0} {1}   {2}  {3}\n", lp.getLongitudeString(), lp.getLatitudeString(),
                //                        newSun.rise.getLongTimeString(), gt.getLongTimeString()));

                if (gt.getJulianGreenwichTime() > newSun.arunodaya.getJulianGreenwichTime())
                {
                    drStep = drStep / 2;
                    dr    -= drStep;
                }
                else
                {
                    dr += drStep;
                }

                steps++;
            }

            sun.arunodaya          = newSun.arunodaya;
            sun.arunodaya_deg      = newSun.arunodaya_deg;
            sun.longitude_arun_deg = newSun.longitude_arun_deg;
        }
Ejemplo n.º 8
0
        public void addChange(GPLocationChange newChange)
        {
            // remove changes with intersection
            removeChangesInRange(newChange.julianStart, newChange.julianEnd);

            if (changes.Count == 0)
            {
                changes.Add(newChange);
            }
            else
            {
                // retrieve index for this new change
                int newIndex = getIndexForNewChange(newChange.julianEnd);

                // insert cange at given index
                if (newIndex < 0)
                {
                    changes.Add(newChange);
                    newIndex = changes.Count - 1;
                }
                else
                {
                    changes.Insert(newIndex, newChange);
                }

                // validate next and prev location
                if (newIndex > 0)
                {
                    changes[newIndex - 1].LocationB = newChange.LocationA;
                }
                if (newIndex < (changes.Count - 1))
                {
                    changes[newIndex + 1].LocationA = newChange.LocationB;
                }
            }
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public void CalculateEvents(GPLocationProvider loc, GPGregorianTime vcStart, GPGregorianTime vcEnd)
        {
            GPCoreEventResults inEvents = this;
            GPLocationProvider earth    = loc;
            GPGregorianTime    vc       = new GPGregorianTime(loc);
            GPSun sun = new GPSun();
            //int ndst = 0;
            int nData;

            inEvents.clear();
            inEvents.m_location = loc;
            inEvents.m_vcStart  = vcStart;
            inEvents.m_vcEnd    = vcEnd;

            GPGregorianTime vcAdd  = new GPGregorianTime(loc);
            GPGregorianTime vcTemp = null;
            GPGregorianTime vcNext = new GPGregorianTime(loc);

            vc.Copy(vcStart);

            if (GPDisplays.CoreEvents.Sunrise())
            {
                vcAdd.Copy(vc);
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    sun.SunCalc(vcAdd, earth);

                    vcTemp = new GPGregorianTime(sun.arunodaya);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_ARUN, 0);

                    //GPJulianTime tr, tt, ts;
                    //GPAstroEngine.CalculateTimeSun(vcTemp, vcTemp.getLocation(), out tr, out tt, out ts);
                    vcTemp = new GPGregorianTime(sun.rise);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), tr);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_RISE, 0);

                    vcTemp = new GPGregorianTime(sun.noon);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), tt);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_NOON, 0);

                    vcTemp = new GPGregorianTime(sun.set);
                    //vcTemp = new GPGregorianTime(vcTemp.getLocation(), ts);
                    inEvents.AddEvent(vcTemp, GPConstants.CCTYPE_S_SET, 0);

                    vcAdd.NextDay();
                }
            }

            if (GPDisplays.CoreEvents.Tithi())
            {
                GPTithi te = new GPTithi();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_TITHI, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Naksatra())
            {
                GPNaksatra te = new GPNaksatra();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentNaksatra();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_NAKS, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Sankranti())
            {
                GPSankranti te = new GPSankranti();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_SANK, nData);
                    vcAdd = te.getNext();
                }
            }

            if (GPDisplays.CoreEvents.Conjunction())
            {
                double[]      times = null;
                GPConjunction te    = new GPConjunction();
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = te.getCurrentPosition();
                    //ndst = loc.getTimeZone().GetDaylightChangeType(vcNext);
                    inEvents.AddEvent(vcAdd, GPConstants.CCTYPE_CONJ, nData);

                    if (GPDisplays.CoreEvents.SunEclipse())
                    {
                        GPAstroEngine.CalculateTimesSunEclipse(vcAdd.getJulianGreenwichTime(), vcAdd.getLocation(), out times);
                        if (times != null && times[2] > 0)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                if (times[i] > 0)
                                {
                                    GPGregorianTime gt = new GPGregorianTime(vcAdd.getLocation());
                                    gt.setJulianGreenwichTime(new GPJulianTime(times[i], 0.0));
                                    inEvents.AddEvent(gt, GPConstants.SUNECLIPSE_CONSTS[i], 0);
                                }
                            }
                        }
                    }

                    vcAdd = te.getNext();
                }
            }


            // moon eclipses
            if (GPDisplays.CoreEvents.MoonEclipse())
            {
                double[]      times = null;
                GPConjunction te    = new GPConjunction();
                te.setOpositeConjunction(true);
                te.setStartDate(vc);
                vcAdd = te.getNext();
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    GPAstroEngine.CalculateTimesMoonEclipse(vcAdd.getJulianGreenwichTime(), vcAdd.getLocation(), out times);
                    if (times != null && times[4] > 0)
                    {
                        for (int i = 0; i < 9; i++)
                        {
                            if (times[i] > 0 && GPConstants.MOONECLIPSE_CONSTS[i] > 0)
                            {
                                GPGregorianTime gt = new GPGregorianTime(vcAdd.getLocation());
                                gt.setJulianGreenwichTime(new GPJulianTime(times[i], 0.0));
                                inEvents.AddEvent(gt, GPConstants.MOONECLIPSE_CONSTS[i], 0);
                            }
                        }
                    }

                    vcAdd = te.getNext();
                }
            }

            // rise and set of the moon
            if (GPDisplays.CoreEvents.Moonrise())
            {
                GPJulianTime julian    = vc.getJulian();
                GPJulianTime julianEnd = vcEnd.getJulian();
                GPJulianTime nextJulian;
                TRiseSet     kind;

                while (julian.getGreenwichJulianDay() < julianEnd.getGreenwichJulianDay())
                {
                    nextJulian = GPAstroEngine.GetNextMoonEvent(julian, vc.getLocationProvider(), out kind);
                    if (kind == TRiseSet.RISE)
                    {
                        inEvents.AddEvent(new GPGregorianTime(loc, nextJulian), GPConstants.CoreEventMoonRise, 0);
                    }
                    else if (kind == TRiseSet.SET)
                    {
                        inEvents.AddEvent(new GPGregorianTime(loc, nextJulian), GPConstants.CoreEventMoonSet, 0);
                    }
                    julian.setGreenwichJulianDay(nextJulian.getGreenwichJulianDay() + 10.0 / 1440.0);
                }
            }

            // travellings
            {
                GPJulianTime julian = vc.getJulian();
                GPJulianTime julianEnd = vcEnd.getJulian();
                double       start, end;

                start = julian.getGreenwichJulianDay();
                end   = julianEnd.getGreenwichJulianDay();

                for (int i = 0; i < loc.getChangeCount(); i++)
                {
                    GPLocationChange chn = loc.getChangeAtIndex(i);
                    if ((chn.julianStart >= start && chn.julianStart <= end) ||
                        (chn.julianStart >= start && chn.julianEnd <= end))
                    {
                        GPGregorianTime startTime = new GPGregorianTime(chn.LocationA);
                        startTime.setJulianGreenwichTime(new GPJulianTime(chn.julianStart, 0));
                        GPGregorianTime endTime = new GPGregorianTime(chn.LocationB);
                        endTime.setJulianGreenwichTime(new GPJulianTime(chn.julianEnd, 0));
                        inEvents.AddEvent(startTime, GPConstants.CCTYPE_TRAVELLING_START, 0);
                        inEvents.AddEvent(endTime, GPConstants.CCTYPE_TRAVELLING_END, 0);
                    }
                }
            }

            // eventual sorting
            inEvents.Sort(GPDisplays.CoreEvents.Sort());
        }
Ejemplo n.º 11
0
 public void insertChangeAtIndex(int p, GPLocationChange newChange)
 {
     changes.Insert(p, newChange);
 }
Ejemplo n.º 12
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);
        }