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); }
private void Draw(Graphics g) { Font f_time = MhoraGlobalOptions.Instance.GeneralFont; Pen p_black = new Pen(Brushes.Black); Pen p_lgray = new Pen(Brushes.LightGray); Pen p_orange = new Pen(Brushes.DarkOrange); Pen p_red = new Pen(Brushes.DarkRed); //int bar_width = this.Width - vname_width*2; int bar_width = zoomWidth - vname_width * 2; float x_offset = 0; string s; SizeF sz; g.Clear(Color.AliceBlue); x_offset = (float)((this.momentToUT(this.mOriginal) - ut_lower) / (ut_higher - ut_lower) * bar_width) + vname_width; g.DrawLine(p_lgray, x_offset, unit_height / 2, x_offset, opts.Divisions.Length * unit_height + unit_height / 2); x_offset = (float)((h.baseUT - ut_lower) / (ut_higher - ut_lower) * bar_width) + vname_width; float y_max = opts.Divisions.Length * unit_height + unit_height / 2; g.DrawLine(p_red, x_offset, unit_height / 2, x_offset, y_max); Moment mNow = this.utToMoment(h.baseUT); s = mNow.ToTimeString(this.menuDisplaySeconds.Checked); sz = g.MeasureString(s, f_time); g.DrawString(s, f_time, Brushes.DarkRed, x_offset - sz.Width / 2, y_max); for (int iVarga = 0; iVarga < opts.Divisions.Length; iVarga++) { int varga_y = (iVarga + 1) * unit_height; g.DrawLine(p_black, vname_width, varga_y, vname_width + bar_width, varga_y); s = string.Format("D-{0}", Basics.numPartsInDivision(opts.Divisions[iVarga])); sz = g.MeasureString(s, f_time); g.DrawString(s, f_time, Brushes.Gray, 4, varga_y - sz.Height / 2); float old_x_offset = 0; for (int j = 0; j < this.momentCusps[iVarga].Length; j++) { double ut_curr = this.momentCusps[iVarga][j]; double perc = (ut_curr - ut_lower) / (ut_higher - ut_lower) * 100.0; //Console.WriteLine ("Varga {0}, perc {1}", opts.Divisions[iVarga], perc); x_offset = (float)((ut_curr - ut_lower) / (ut_higher - ut_lower) * bar_width) + vname_width; //(float)((ut_curr-ut_lower)/(ut_higher/ut_lower)*bar_width); Moment m = this.utToMoment(ut_curr); s = string.Format("{0} {1}", m.ToTimeString(this.menuDisplaySeconds.Checked), ZodiacHouse.ToShortString(zhCusps[iVarga][j])); sz = g.MeasureString(s, f_time); if (old_x_offset + sz.Width < x_offset) { g.DrawLine(p_black, x_offset, varga_y - half_tick_height, x_offset, varga_y + half_tick_height); g.DrawString(s, f_time, Brushes.Gray, x_offset - (sz.Width / 2), varga_y - sz.Height - half_tick_height); // x_offset-(sz.Width/2), varga_y-sz.Height-half_tick_height); old_x_offset = x_offset; // s = zhCusps[iVarga][j].ToString(); // sz = g.MeasureString(s, f_time); // g.DrawString(s, f_time, Brushes.Black, // x_offset, varga_y - sz.Height); } else { g.DrawLine(p_orange, x_offset, varga_y - half_tick_height, x_offset, varga_y + half_tick_height); } } } //this.Height); }