Esempio n. 1
0
        private void openJhdFileNow()
        {
            DateTime tNow = DateTime.Now;
            Moment   mNow = new Moment(tNow.Year, tNow.Month, tNow.Day, tNow.Hour, tNow.Minute, tNow.Second);

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "JHD Files (*.jhd)|*.jhd";

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }


            HoraInfo info = (new Jhd(ofd.FileName)).toHoraInfo();

            info.tob = mNow;

            string[]  _path_split = ofd.FileName.Split(new Char[] { '/', '\\' });
            ArrayList path_split  = new ArrayList(_path_split);

            childCount++;
            Horoscope h = new Horoscope(info, (HoroscopeOptions)MhoraGlobalOptions.Instance.HOptions.Clone());

            //Horoscope h = new Horoscope (info, new HoroscopeOptions());
            MhoraChild child = new MhoraChild(h);

            child.Text      = childCount.ToString() + " - Prasna Chart";
            child.MdiParent = this;
            child.Name      = child.Text;
            child.Show();
        }
Esempio n. 2
0
        private void openNewJhdFile()
        {
            DateTime tNow = DateTime.Now;
            Moment   mNow = new Moment(tNow.Year, tNow.Month, tNow.Day, tNow.Hour, tNow.Minute, tNow.Second);
            HoraInfo info = new HoraInfo(mNow,
                                         MhoraGlobalOptions.Instance.Latitude,
                                         MhoraGlobalOptions.Instance.Longitude,
                                         MhoraGlobalOptions.Instance.TimeZone);

            childCount++;
            Horoscope h = new Horoscope(info, (HoroscopeOptions)MhoraGlobalOptions.Instance.HOptions.Clone());
            //new HoroscopeOptions());
            MhoraChild child = new MhoraChild(h);

            child.Text      = childCount.ToString() + " - Prasna Chart";
            child.MdiParent = this;
            child.Name      = child.Text;
            //info.name = child.Text;
            try
            {
                child.Show();
            }
            catch (System.OutOfMemoryException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 3
0
        public static double swe_lagna(double tjd_ut)
        {
            sweph.checkLock();
            HoraInfo hi = sweph.mCurrentLockHolder.info;

            double[] cusps = new double[13];
            double[] ascmc = new double[10];
            int      ret   = swe_houses_ex(tjd_ut, sweph.SEFLG_SIDEREAL, hi.lat.toDouble(), hi.lon.toDouble(), 'R', cusps, ascmc);

            return(ascmc[0]);
        }
Esempio n. 4
0
        private bool checkJhd(string fileName)
        {
            HoraInfo  info = (new Jhd(fileName)).toHoraInfo();
            Horoscope h    = new Horoscope(info, new HoroscopeOptions());

            if (h.getPosition(Body.Name.Ketu).toDivisionPosition(new Division(Basics.DivisionType.Rasi)).zodiac_house.value ==
                h.getPosition(Body.Name.Lagna).toDivisionPosition(new Division(Basics.DivisionType.Rasi)).zodiac_house.value)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        public static void swe_sol_eclipse_when_loc(HoraInfo hi, double tjd_ut, double[] tret, double[] attr, bool forward)
        {
            sweph.checkLock();
            StringBuilder serr = new StringBuilder(256);

            double[] geopos = new Double[3] {
                hi.lon.toDouble(), hi.lat.toDouble(), hi.alt
            };
            int ret = xyz_swe_sol_eclipse_when_loc(tjd_ut, iflag, geopos, tret, attr, !forward, serr);

            if (ret < 0)
            {
                Console.WriteLine("Sweph Error: {0}", serr);
                throw new SwephException(serr.ToString());
            }
        }
Esempio n. 6
0
        private void openJhdFile()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Hora Files (*.jhd; *.mhd)|*.jhd;*.mhd";

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string[] sparts = ofd.FileName.ToLower().Split(new char[] { '.' });
            HoraInfo info   = null;

            if (sparts[sparts.Length - 1] == "jhd")
            {
                info = (new Jhd(ofd.FileName)).toHoraInfo();
            }
            else
            {
                info = (new Mhd(ofd.FileName)).toHoraInfo();
            }

            string[]  _path_split = ofd.FileName.Split(new Char[] { '/', '\\' });
            ArrayList path_split  = new ArrayList(_path_split);

            childCount++;
            Horoscope  h     = new Horoscope(info, new HoroscopeOptions());
            MhoraChild child = new MhoraChild(h);

            child.Text         = childCount.ToString() + " - " + path_split[path_split.Count - 1];
            child.MdiParent    = this;
            child.Name         = child.Text;
            child.mJhdFileName = ofd.FileName;

            child.Show();
        }
Esempio n. 7
0
        private void PrintFirstPage(PrintPageEventArgs e)
        {
            e.HasMorePages = true;
            Graphics g = e.Graphics;

            g.ResetTransform();
            g.TranslateTransform(margin_offset, header_offset);

            PrintTitle(g, 0, this.wday_offset + this.wday_width, "Date/Day");
            PrintTitle(g, this.sunrise_offset, this.sunset_offset + this.sunset_width, "Sunrise/set");
            PrintTitle(g, this.nak_name_offset, this.nak_time_offset + this.nak_time_width, "Nakshatra");
            PrintTitle(g, this.tithi_name_offset, this.tithi_time_offset + this.tithi_time_width, "Tithi");
            PrintTitle(g, this.karana_name_1_offset, this.karana_time_2_offset + this.karana_time_width, "Karana");
            PrintTitle(g, this.sm_name_offset, this.sm_time_offset + this.sm_time_width, "SM-Yoga");

            g.TranslateTransform(0, (float)(f.Height * 1.5));

            int iStart = local_index;
            int i      = local_index;

            while (i < locals.Count)
            {
                int numLines = 1;
                PanchangaLocalMoments local = (PanchangaLocalMoments)locals[i];
                Moment m_sunrise            = new Moment(local.sunrise_ut, h);
                Moment m_sunset             = new Moment(0, 0, 0, local.sunset);

                g.DrawString(m_sunrise.ToShortDateString(), f, b, day_offset, 0);
                g.DrawString(Basics.weekdayToShortString(local.wday), f, b, wday_offset, 0);

                if (opts.ShowSunriset)
                {
                    g.DrawString(m_sunrise.ToTimeString(), f, b, sunrise_offset, 0);
                    g.DrawString(m_sunset.ToTimeString(), f, b, sunset_offset, 0);
                }

                int numTithis  = local.tithi_index_end - local.tithi_index_start;
                int numNaks    = local.nakshatra_index_end - local.nakshatra_index_start;
                int numSMYogas = local.smyoga_index_end - local.smyoga_index_start;
                int numKaranas = local.karana_index_end - local.karana_index_start;

                if (opts.CalcTithiCusps)
                {
                    numLines = Math.Max(numLines, numTithis);
                    for (int j = 0; j < numTithis; j++)
                    {
                        PanchangaMomentInfo pmi = (PanchangaMomentInfo)globals.tithis_ut[local.tithi_index_start + 1 + j];
                        Tithi  t      = new Tithi((Tithi.Name)pmi.info);
                        Moment mTithi = new Moment(pmi.ut, h);
                        g.DrawString(t.ToUnqualifiedString(), f, b, tithi_name_offset, j * f.Height);
                        g.DrawString(this.utTimeToString(pmi.ut, local.sunrise_ut, local.sunrise),
                                     f, b, tithi_time_offset, j * f.Height);
                    }
                }

                if (opts.CalcKaranaCusps)
                {
                    numLines = Math.Max(numLines, (int)Math.Ceiling(numKaranas / 2.0));
                    for (int j = 0; j < numKaranas; j++)
                    {
                        PanchangaMomentInfo pmi = (PanchangaMomentInfo)globals.karanas_ut[local.karana_index_start + 1 + j];
                        Karana k           = new Karana((Karana.Name)pmi.info);
                        Moment mKarana     = new Moment(pmi.ut, h);
                        int    jRow        = (int)Math.Floor((decimal)j / 2);
                        int    name_offset = karana_name_1_offset;
                        int    time_offset = karana_time_1_offset;
                        if (j % 2 == 1)
                        {
                            name_offset = karana_name_2_offset;
                            time_offset = karana_time_2_offset;
                        }

                        g.DrawString(k.value.ToString(), f, b, name_offset, jRow * f.Height);
                        g.DrawString(this.utTimeToString(pmi.ut, local.sunrise_ut, local.sunrise),
                                     f, b, time_offset, jRow * f.Height);
                    }
                }

                if (opts.CalcNakCusps)
                {
                    numLines = Math.Max(numLines, numNaks);
                    for (int j = 0; j < numNaks; j++)
                    {
                        PanchangaMomentInfo pmi = (PanchangaMomentInfo)globals.nakshatras_ut[local.nakshatra_index_start + 1 + j];
                        Nakshatra           n   = new Nakshatra((Nakshatra.Name)pmi.info);
                        Moment mNak             = new Moment(pmi.ut, h);
                        g.DrawString(n.ToString(), f, b, nak_name_offset, j * f.Height);
                        g.DrawString(this.utTimeToString(pmi.ut, local.sunrise_ut, local.sunrise),
                                     f, b, nak_time_offset, j * f.Height);
                    }
                }

                if (opts.CalcSMYogaCusps)
                {
                    numLines = Math.Max(numLines, numSMYogas);
                    for (int j = 0; j < numSMYogas; j++)
                    {
                        PanchangaMomentInfo pmi = (PanchangaMomentInfo)globals.smyogas_ut[local.smyoga_index_start + 1 + j];
                        SunMoonYoga         sm  = new SunMoonYoga((SunMoonYoga.Name)pmi.info);
                        Moment mSMYoga          = new Moment(pmi.ut, h);
                        g.DrawString(sm.value.ToString(), f, b, sm_name_offset, j * f.Height);
                        g.DrawString(this.utTimeToString(pmi.ut, local.sunrise_ut, local.sunrise),
                                     f, b, sm_time_offset, j * f.Height);
                    }
                }


#if DND
                string s_rahu_kala = string.Format("{0} - {1}",
                                                   this.utTimeToString(local.kalas_ut[local.rahu_kala_index], local.sunrise_ut, local.sunrise),
                                                   this.utTimeToString(local.kalas_ut[local.rahu_kala_index + 1], local.sunrise_ut, local.sunrise));
                g.DrawString(s_rahu_kala, f, b, rahu_kala_offset, 0);
#endif

                g.TranslateTransform(0, f.Height * numLines);

                local_index = ++i;

                if (g.Transform.OffsetY > e.PageBounds.Height - this.header_offset - divisional_chart_size)
                {
                    goto first_done;
                }
            }

            this.bPrintPanchanga = false;
            this.local_index     = 0;

first_done:
            float offsetY = g.Transform.OffsetY;
            float offsetX = margin_offset + sm_time_offset + sm_time_width;

            Moment          mCurr  = new Moment(((PanchangaLocalMoments)locals[iStart]).sunrise_ut, h);
            HoraInfo        hiCurr = new HoraInfo(mCurr, h.info.lat, h.info.lon, h.info.tz);
            Horoscope       hCurr  = new Horoscope(hiCurr, h.options);
            DivisionalChart dc     = new DivisionalChart(hCurr);
            dc.PrintMode         = true;
            dc.options.ViewStyle = DivisionalChart.UserOptions.EViewStyle.Panchanga;
            dc.SetOptions(dc.options);
            dc.DrawChart(g, divisional_chart_size, divisional_chart_size);

            g.ResetTransform();
            // horizontal top & bottom
            g.DrawLine(p, margin_offset - 5, header_offset - 5, margin_offset + sm_time_offset + sm_time_width + 5, header_offset - 5);
            g.DrawLine(p, margin_offset - 5, header_offset - 5 + f.Height * (float)1.5, margin_offset + sm_time_offset + sm_time_width + 5, header_offset - 5 + f.Height * (float)1.5);
            g.DrawLine(p, margin_offset - 5, offsetY + 5, offsetX + 5, offsetY + 5);
            // vertical left and right
            g.DrawLine(p, margin_offset - 5, header_offset - 5, margin_offset - 5, offsetY + 5);
            g.DrawLine(p, offsetX + 5, header_offset - 5, offsetX + 5, offsetY + 5);

            g.DrawLine(p,
                       margin_offset + sunset_offset + sunset_width - 2, header_offset - 5,
                       margin_offset + sunset_offset + sunset_width - 2, offsetY + 5);

            g.DrawLine(p,
                       margin_offset + tithi_time_offset + tithi_time_width - 2, header_offset - 5,
                       margin_offset + tithi_time_offset + tithi_time_width - 2, offsetY + 5);

            g.DrawLine(p,
                       margin_offset + nak_time_offset + nak_time_width - 2, header_offset - 5,
                       margin_offset + nak_time_offset + nak_time_width - 2, offsetY + 5);

            g.DrawLine(p,
                       margin_offset + karana_time_2_offset + karana_time_width - 2, header_offset - 5,
                       margin_offset + karana_time_2_offset + karana_time_width - 2, offsetY + 5);
        }
Esempio n. 8
0
        private void ComputeEntry(double ut, double[] geopos)
        {
            int    year = 0, month = 0, day = 0;
            double sunset = 0, hour = 0;

            sweph.obtainLock(h);
            h.populateSunrisetCacheHelper(ut - 0.5, ref sunrise, ref sunset, ref ut_sr);
            sweph.releaseLock(h);

            sweph.swe_revjul(ut_sr, ref year, ref month, ref day, ref hour);
            Moment    moment_sr = new Moment(year, month, day, hour);
            Moment    moment_ut = new Moment(ut, h);
            HoraInfo  infoCurr  = new HoraInfo(moment_ut, h.info.lat, h.info.lon, h.info.tz);
            Horoscope hCurr     = new Horoscope(infoCurr, h.options);

            ListViewItem li = null;

            PanchangaLocalMoments local = new PanchangaLocalMoments();

            local.sunrise    = hCurr.sunrise;
            local.sunset     = sunset;
            local.sunrise_ut = ut_sr;
            sweph.swe_revjul(ut, ref year, ref month, ref day, ref hour);
            local.wday = (Basics.Weekday)sweph.swe_day_of_week(ut);



            local.kalas_ut = hCurr.getKalaCuspsUt();
            if (this.opts.CalcSpecialKalas)
            {
                Body.Name bStart = Basics.weekdayRuler(hCurr.wday);
                if (hCurr.options.KalaType == HoroscopeOptions.EHoraType.Lmt)
                {
                    bStart = Basics.weekdayRuler(hCurr.lmt_wday);
                }

                local.rahu_kala_index   = this.rahu_kalas[(int)bStart];
                local.gulika_kala_index = this.gulika_kalas[(int)bStart];
                local.yama_kala_index   = this.yama_kalas[(int)bStart];
            }

            if (opts.CalcLagnaCusps)
            {
                li = new ListViewItem();
                sweph.obtainLock(h);
                BodyPosition     bp_lagna_sr = Basics.CalculateSingleBodyPosition(ut_sr, sweph.BodyNameToSweph(Body.Name.Lagna), Body.Name.Lagna, BodyType.Name.Lagna, h);
                DivisionPosition dp_lagna_sr = bp_lagna_sr.toDivisionPosition(new Division(Basics.DivisionType.Rasi));
                local.lagna_zh = dp_lagna_sr.zodiac_house.value;

                Longitude bp_lagna_base = new Longitude(bp_lagna_sr.longitude.toZodiacHouseBase());
                double    ut_transit    = ut_sr;
                for (int i = 1; i <= 12; i++)
                {
                    Retrogression r = new Retrogression(h, Body.Name.Lagna);
                    ut_transit = r.GetLagnaTransitForward(ut_transit, bp_lagna_base.add(i * 30.0));

                    PanchangaMomentInfo pmi = new PanchangaMomentInfo(
                        ut_transit, (int)bp_lagna_sr.longitude.toZodiacHouse().add(i + 1).value);
                    local.lagnas_ut.Add(pmi);
                }

                sweph.releaseLock(h);
            }

            if (opts.CalcTithiCusps)
            {
                Transit t = new Transit(h);
                sweph.obtainLock(h);
                Tithi tithi_start = t.LongitudeOfTithi(ut_sr).toTithi();
                Tithi tithi_end   = t.LongitudeOfTithi(ut_sr + 1.0).toTithi();

                Tithi tithi_curr = tithi_start.add(1);
                local.tithi_index_start = globals.tithis_ut.Count - 1;
                local.tithi_index_end   = globals.tithis_ut.Count - 1;

                while (tithi_start.value != tithi_end.value &&
                       tithi_curr.value != tithi_end.value)
                {
                    tithi_curr = tithi_curr.add(2);
                    double dLonToFind = ((double)(int)tithi_curr.value - 1) * (360.0 / 30.0);
                    double ut_found   = t.LinearSearchBinary(ut_sr, ut_sr + 1.0, new Longitude(dLonToFind),
                                                             new ReturnLon(t.LongitudeOfTithiDir));

                    globals.tithis_ut.Add(new PanchangaMomentInfo(ut_found, (int)tithi_curr.value));
                    local.tithi_index_end++;
                }
                sweph.releaseLock(h);
            }


            if (opts.CalcKaranaCusps)
            {
                Transit t = new Transit(h);
                sweph.obtainLock(h);
                Karana karana_start = t.LongitudeOfTithi(ut_sr).toKarana();
                Karana karana_end   = t.LongitudeOfTithi(ut_sr + 1.0).toKarana();

                Karana karana_curr = karana_start.add(1);
                local.karana_index_start = globals.karanas_ut.Count - 1;
                local.karana_index_end   = globals.karanas_ut.Count - 1;

                while (karana_start.value != karana_end.value &&
                       karana_curr.value != karana_end.value)
                {
                    karana_curr = karana_curr.add(2);
                    double dLonToFind = ((double)(int)karana_curr.value - 1) * (360.0 / 60.0);
                    double ut_found   = t.LinearSearchBinary(ut_sr, ut_sr + 1.0, new Longitude(dLonToFind),
                                                             new ReturnLon(t.LongitudeOfTithiDir));

                    globals.karanas_ut.Add(new PanchangaMomentInfo(ut_found, (int)karana_curr.value));
                    local.karana_index_end++;
                }
                sweph.releaseLock(h);
            }

            if (opts.CalcSMYogaCusps)
            {
                Transit t = new Transit(h);
                sweph.obtainLock(h);
                SunMoonYoga sm_start = t.LongitudeOfSunMoonYoga(ut_sr).toSunMoonYoga();
                SunMoonYoga sm_end   = t.LongitudeOfSunMoonYoga(ut_sr + 1.0).toSunMoonYoga();

                SunMoonYoga sm_curr = sm_start.add(1);
                local.smyoga_index_start = globals.smyogas_ut.Count - 1;
                local.smyoga_index_end   = globals.smyogas_ut.Count - 1;

                while (sm_start.value != sm_end.value &&
                       sm_curr.value != sm_end.value)
                {
                    sm_curr = sm_curr.add(2);
                    double dLonToFind = ((double)(int)sm_curr.value - 1) * (360.0 / 27);
                    double ut_found   = t.LinearSearchBinary(ut_sr, ut_sr + 1.0, new Longitude(dLonToFind),
                                                             new ReturnLon(t.LongitudeOfSunMoonYogaDir));

                    globals.smyogas_ut.Add(new PanchangaMomentInfo(ut_found, (int)sm_curr.value));
                    local.smyoga_index_end++;
                }

                sweph.releaseLock(h);
            }


            if (opts.CalcNakCusps)
            {
                bool    bDiscard = true;
                Transit t        = new Transit(h, Body.Name.Moon);
                sweph.obtainLock(h);
                Nakshatra nak_start = t.GenericLongitude(ut_sr, ref bDiscard).toNakshatra();
                Nakshatra nak_end   = t.GenericLongitude(ut_sr + 1.0, ref bDiscard).toNakshatra();

                local.nakshatra_index_start = globals.nakshatras_ut.Count - 1;
                local.nakshatra_index_end   = globals.nakshatras_ut.Count - 1;

                Nakshatra nak_curr = nak_start.add(1);

                while (nak_start.value != nak_end.value &&
                       nak_curr.value != nak_end.value)
                {
                    nak_curr = nak_curr.add(2);
                    double dLonToFind = ((double)((int)nak_curr.value - 1)) * (360.0 / 27.0);
                    double ut_found   = t.LinearSearchBinary(ut_sr, ut_sr + 1.0, new Longitude(dLonToFind),
                                                             new ReturnLon(t.GenericLongitude));

                    globals.nakshatras_ut.Add(new PanchangaMomentInfo(ut_found, (int)nak_curr.value));
                    Console.WriteLine("Found nakshatra {0}", nak_curr.value);
                    local.nakshatra_index_end++;
                }
                sweph.releaseLock(h);
            }

            if (opts.CalcHoraCusps)
            {
                local.horas_ut = hCurr.getHoraCuspsUt();
                hCurr.calculateHora(ut_sr + 1.0 / 24.0, ref local.hora_base);
            }

            if (opts.CalcKalaCusps)
            {
                hCurr.calculateKala(ref local.kala_base);
            }


            this.locals.Add(local);
            this.DisplayEntry(local);
        }