Ejemplo n.º 1
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);
        }