private void eventMapOverlayView1_OnClick(object o, EventmapOverlayEventArgs e) { GregorianDateTime dt = new GregorianDateTime(SelectedDate); dt.PreviousDay(); dt.PreviousDay(); GCLocation loc = new GCLocation(); TTimeZone tz = new TTimeZone(); loc.Latitude = 0; loc.Longitude = 0; loc.TimeZone = tz; TResultCalendar cal = new TResultCalendar(); cal.EkadasiOnly = true; VAISNAVADAY vd = GetCalcDay(dt, loc, cal, e.Longitude, e.Latitude); string str = string.Format("{0}, sunrise: {1}, longitude: {2}, latitude: {3}" , vd.date.ToString(), vd.astrodata.sunRise.ToLongTimeString() , e.Longitude, e.Latitude); labelStatus.Text = str; }
private void buttonCalcEkadasi_Click(object sender, EventArgs e) { TResultCalendar cal = new TResultCalendar(); cal.CalculateCalendar(GCGlobal.myLocation, new GregorianDateTime(int.Parse(textBox1.Text), comboBox1.SelectedIndex + 1, 1), 31); List <VAISNAVADAY> le = new List <VAISNAVADAY>(); for (int i = 0; i < 31; i++) { VAISNAVADAY vd = cal.GetDay(i); if (vd.nFastID == FastType.FAST_EKADASI) { LBVD lb = new LBVD(); lb.vd = vd; listBox1.Items.Add(lb); } } if (listBox1.Items.Count > 0) { listBox1.SelectedIndex = 0; } panel1.Visible = true; }
private void ekadasiMapToolStripMenuItem_Click(object sender, EventArgs e) { int step = 0; VAISNAVADAY dayEkadasi = null; GregorianDateTime dateEkadasi = null; GCMap selectedMap = null; while (step >= 0) { switch (step) { case 0: // select ekadasi DlgGetEkadasiName dlg = new DlgGetEkadasiName(); if (dlg.ShowDialog() == DialogResult.OK) { dayEkadasi = dlg.SelectedDate; dateEkadasi = dlg.SelectedDate.date; step = 1; } else { step = -1; } break; case 1: // select location map DlgSelectMap maps = new DlgSelectMap(); if (maps.ShowDialog() == DialogResult.OK) { step = 2; selectedMap = maps.SelectedMap; if (selectedMap == null) { step = -1; } } else { step = -1; } break; case 2: // calculate Ekadasi map DlgCalcEkadasiBoundaries d2 = new DlgCalcEkadasiBoundaries(dayEkadasi.date); d2.SelectedDate = dateEkadasi; d2.SelectedVaisnavaDay = dayEkadasi; d2.FindType = 1; d2.SelectedMap = selectedMap; d2.Show(); step = -1; break; } } }
public VAISNAVADAY GetCalcDay(GregorianDateTime dt, GCLocation loc, TResultCalendar cal, double longitude, double latitude) { loc.SetCoordinates(longitude, latitude); cal.CalculateCalendar(loc, dt, 5); for (int i = 0; i < 5; i++) { VAISNAVADAY vd = cal.GetDay(i); if (vd.nFastID == FastType.FAST_EKADASI) { return(vd); } } return(null); }
/// <summary> /// If newText is changed during the processing of this method /// then running of this method is aborted and new search starts in backSearch_DoWork /// by assigning newText value into currentText /// </summary> private void doSearch(string text, CancellationTokenSource tokenSource) { TResultCalendar cal = new TResultCalendar(); string dayText; cal.CalculateCalendar(EarthLocation, new GregorianDateTime(), 700); StringBuilder results3 = new StringBuilder(); GSScript script = new GSScript(); script.readTextTemplate(TResultCalendar.getPlainDayTemplate()); GSExecutor exec = new GSExecutor(); for (int i = 0; i < cal.m_PureCount; i++) { VAISNAVADAY vd = cal.GetDay(i); exec.SetVariable("app", GCUserInterface.Shared); exec.SetVariable("location", EarthLocation); exec.SetVariable("pvd", vd); //dayText = TResultCalendar.formatPlainTextDay(vd); exec.resetOutput(); exec.ExecuteElement(script); dayText = exec.getOutput(); //Debugger.Log(0, "", "SEARCH IN TEXT: " + dayText + "\n\n"); if (dayText.IndexOf(text, 0, StringComparison.CurrentCultureIgnoreCase) >= 0) { results3.AppendLine(); results3.AppendLine(dayText); } if (tokenSource.IsCancellationRequested) { return; } } if (!tokenSource.IsCancellationRequested) { FinalizeDelegate dlg = new FinalizeDelegate(setRichText); richTextBox1.BeginInvoke(dlg, results3.ToString()); ctTask = null; ctPrev = null; } }
private QuadrantArray CalculateQuadrantArray(Quadrant map, GregorianDateTime dt, GCLocation loc, TResultCalendar cal, List <Quadrant> qlist) { QuadrantArray qa = new QuadrantArray(map, calculateSplits(map.LongitudeRange, map.pixelsX), calculateSplits(map.LatitudeRange, map.pixelsY)); for (int lo = 0; lo < qa.Longitudes.Length; lo++) { for (int la = 0; la < qa.Latitudes.Length; la++) { if (qa.Points[lo, la].Result != null) { continue; } VAISNAVADAY vd = GetCalcDay(dt, loc, cal, qa.Longitudes[lo], qa.Latitudes[la]); /* loc.SetCoordinates(qa.Longitudes[lo], qa.Latitudes[la]); * cal.CalculateCalendar(loc, dt, 5); * for (int i = 0; i < 5; i++) * { * VAISNAVADAY vd = cal.GetDay(i); * if (vd.nFastID == FastType.FAST_EKADASI) * { * qa.Points[lo, la].Result = GetSafeResult(vd); * } * }*/ if (vd != null) { qa.Points[lo, la].Result = GetSafeResult(vd); } } } for (int lo = 0; lo < qa.Quadrants.GetLength(0); lo++) { for (int la = 0; la < qa.Quadrants.GetLength(1); la++) { if (qa.Quadrants[lo, la].ResultState == QuadrantResultState.Decomposable) { qlist.Add(qa.Quadrants[lo, la]); } } } return(qa); }
private static void ConstructMasaText(StringBuilder masaText, int i, VAISNAVADAY vd, VAISNAVADAY vd_prev, VAISNAVADAY vd_next) { if (vd.astrodata.Masa != vd_prev.astrodata.Masa || i == 1) { if (masaText.Length > 0) { masaText.Append(", "); } masaText.AppendFormat("{0} Masa ", GCMasa.GetName(vd.astrodata.Masa)); if (vd.astrodata.Masa != vd_prev.astrodata.Masa) { masaText.AppendFormat("from {0} ", vd.date.ToString()); } } else if (vd.astrodata.Masa != vd_next.astrodata.Masa) { masaText.AppendFormat("to {0}", vd.date.ToString()); } }
private float DrawTithiText(Graphics g, VAISNAVADAY vd) { SizeF textSize; float tempTextHeight = 0; string str2 = GCTithi.GetName(vd.astrodata.sunRise.Tithi); textSize = g.MeasureString(str2, fontH3); g.DrawString(str2, fontH3, Brushes.Black, xCellAnchor1, yCellMarginTop); tempTextHeight = yCellMarginTop + textSize.Height; if (vd.HasExtraFastingNote()) { str2 = vd.GetExtraFastingNote(); textSize = g.MeasureString(str2, fontS2); g.DrawString(str2, fontS2, Brushes.Black, xCellAnchor1, tempTextHeight); tempTextHeight += textSize.Height; } return(tempTextHeight); }
private QuandrantResult GetSafeResult(VAISNAVADAY day) { string key = day.date.ToString(); if (results.ContainsKey(key)) { return(results[key]); } QuandrantResult qr = new QuandrantResult(); qr.day = day; qr.ResultId = results.Count; qr.color = result_colors[qr.ResultId]; results[key] = qr; resultsList.Add(qr); return(qr); }
private static string GetEventsLineText(VAISNAVADAY vd) { string str; StringBuilder sb = new StringBuilder(); foreach (VAISNAVAEVENT ed in vd.dayEvents) { if (sb.Length > 0) { sb.Append("; "); } int disp = ed.dispItem; if (ed.dispItem != 0 && (disp == -1 || GCDisplaySettings.Current.getValue(disp) != 0)) { sb.Append(ed.text); } } sb.Replace("-- Appearance", "[app]"); sb.Replace("-- Disappearance", "[dis]"); str = sb.ToString(); return(str); }
private void buttonSelectEkadasi_Click(object sender, EventArgs e) { SelectedDate = (listBox1.Items[listBox1.SelectedIndex] as LBVD).vd; }
internal void Draw(Graphics graphics, Size size, Base.TResultCalendar tResultCalendar, int nYear, int nMonth) { Graphics g = graphics; SizeF textSize = Size.Empty; float fontH1Size = Math.Min(size.Height - PaddingLeft - PaddingRight, size.Width * 0.707f - PaddingTop - PaddingBottom) / 30; xMarginLeft = PaddingLeft; yMarginTop = PaddingTop; xMarginRight = size.Width - PaddingRight; yUnderTitleBar = 0; yUnderMainTitle = 0; float tx; float cellInset = fontH1Size / 5; StringFormat rectFormat = new StringFormat(); rectFormat.Trimming = StringTrimming.EllipsisWord; DateTime dtToday = DateTime.Now; InitializeFonts(fontH1Size); string str; DrawTitle(nYear, nMonth, g); if (tResultCalendar == null) { return; } DrawRightTitleInfo(tResultCalendar, g); g.DrawLine(monthDivider, xMarginLeft, yUnderTitleBar, xMarginRight, yUnderTitleBar); firstDayOfWeekGeneral = GCDisplaySettings.Current.getValue(GCDS.GENERAL_FIRST_DOW); xCellWidth = (xMarginRight - xMarginLeft) / 7.0f; float tempTextHeight = fontH1Size / 5; // draw names of weekdays textSize = DrawWeekdayHeader(g, tempTextHeight); yTableTop = yUnderTitleBar + 2 * tempTextHeight + textSize.Height; yMarginBottom = size.Height - PaddingBottom; int firstIndex = 0; int firstDayDow = 0; for (int i = 0; i < tResultCalendar.m_nCount; i++) { GregorianDateTime gdt = tResultCalendar.m_pData[i].date; if (gdt.day == 1 && gdt.month == nMonth && gdt.year == nYear) { firstIndex = i; firstDayDow = gdt.dayOfWeek; } } int daysBeforeFirstDay = (firstDayDow - firstDayOfWeekGeneral + 14) % 7; int monthDays = GregorianDateTime.GetMonthMaxDays(nYear, nMonth); int totalDays = daysBeforeFirstDay + monthDays; int weeksCount = ((totalDays % 7) == 0) ? (totalDays / 7) : (totalDays / 7 + 1); yCellHeight = (yMarginBottom - yTableTop) / weeksCount; RectangleF rcf = new RectangleF(); int row, column, di; StringBuilder masaText = new StringBuilder(); for (int i = 1; i <= monthDays; i++) { di = daysBeforeFirstDay + i - 1; row = di / 7; column = di % 7; VAISNAVADAY vd = tResultCalendar.m_pData[firstIndex + i - 1]; VAISNAVADAY vd_prev = tResultCalendar.m_pData[firstIndex + i - 2]; VAISNAVADAY vd_next = tResultCalendar.m_pData[firstIndex + i]; ConstructMasaText(masaText, i, vd, vd_prev, vd_next); yCellMarginTop = yTableTop + row * yCellHeight + cellInset; xCellMarginLeft = xMarginLeft + column * xCellWidth + cellInset; rcf.X = xCellMarginLeft - cellInset; rcf.Y = yCellMarginTop - cellInset; rcf.Width = xCellWidth; rcf.Height = yCellHeight; if (vd.nFastID == FastType.FAST_EKADASI) { g.FillRectangle(Brushes.LightGreen, rcf); } else if (vd.nFastID != 0) { g.FillRectangle(Brushes.LightSkyBlue, rcf); } if (dtToday.Day == i && dtToday.Month == nMonth && dtToday.Year == nYear) { g.DrawRectangle(todayBorder, rcf.Left, rcf.Top, rcf.Width, rcf.Height); } textSize = DrawCellDayNumber(g, i); yCellAnchor1 = yCellMarginTop + textSize.Height + cellInset; xCellAnchor1 = xCellMarginLeft + textSize.Width + cellInset; xCellMarginRight = xCellMarginLeft + xCellWidth - 2 * cellInset; yCellMarginBottom = yCellMarginTop + yCellHeight - 2 * cellInset; tempTextHeight = DrawTithiText(g, vd); yCellAnchor1 = Math.Max(tempTextHeight + cellInset, yCellAnchor1); rcf.X = xCellAnchor1; rcf.Y = yCellMarginTop; rcf.Width = xCellMarginRight - xCellAnchor1; rcf.Height = textSize.Height + 2; str = GetEventsLineText(vd); Font f = fontS2; textSize = g.MeasureString(str, fontS2, Convert.ToInt32(xCellMarginRight - xCellMarginLeft)); if (textSize.Height + yCellAnchor1 + cellInset > yCellMarginTop + yCellHeight) { f = fontS3; textSize = g.MeasureString(str, f, Convert.ToInt32(xCellMarginRight - xCellMarginLeft)); } rcf.Y = yCellAnchor1; rcf.X = xCellMarginLeft; rcf.Width = textSize.Width; rcf.Height = Math.Min(yCellMarginBottom - yCellAnchor1, textSize.Height); g.DrawString(str, f, Brushes.Black, rcf, rectFormat); } // masa info text g.DrawString(masaText.ToString(), fontS2, Brushes.Black, xMarginLeft, yUnderMainTitle); // final step: draw matrix for (int i = 0; i < 8; i++) { g.DrawLine(dayDivider, xMarginLeft + i * xCellWidth, yTableTop, xMarginLeft + i * xCellWidth, yMarginBottom); } for (int j = 0; j <= weeksCount; j++) { g.DrawLine(dayDivider, xMarginLeft, yTableTop + j * yCellHeight, xMarginRight, yTableTop + j * yCellHeight); } }
private CDVPara FormatCalendarLayout(CDVDataTarget requestor, DocCalenarData docData) { CDVParaStyle pstitle = new CDVParaStyle(); pstitle.StyleName = "TitleC"; pstitle.Align = CDVAlign.Center; pstitle.Padding.All = 12; pstitle.Margin.All = 12; pstitle.BorderWidth.All = 1; pstitle.BorderColor = CDVColor.Black; pstitle.BackgroundColor = CDVColor.LightYellow; CDVParaStyle pshdr = new CDVParaStyle(); pshdr.StyleName = "Hdr"; pshdr.Margin.Top = 2; pshdr.Margin.Bottom = 12; pshdr.BackgroundColor = new CDVColor(255, 64, 32, 0); CDVParaStyle ps = new CDVParaStyle(); ps.StyleName = "Centered"; ps.Align = CDVAlign.Center; CDVTextStyle ts = new CDVTextStyle(); ts.FontSize = 18; CDVTextStyle tsWeekday = new CDVTextStyle(); tsWeekday.FontSize = 9; CDVTextStyle tsHdr = new CDVTextStyle(); tsHdr.Color = CDVColor.White; tsHdr.FontSize = 10; CDVRuler atithi = new CDVRuler(null, 10); CDVRuler aday = new CDVRuler(null, 0); CDVRuler apak = new CDVRuler(null); CDVRuler anak = new CDVRuler(null); CDVRuler ayog = new CDVRuler(null); CDVRuler afast = new CDVRuler(null, 0); CDVRuler amr = new CDVRuler(null); CDVRuler amsun1 = new CDVRuler(null); CDVRuler amsun2 = new CDVRuler(null); CDVRuler amsun3 = new CDVRuler(null); CDVRuler amcore = new CDVRuler(null, 20); CDVRuler amcoretime = new CDVRuler(null); CDVAtom doc = requestor.GetDocument(); CDVPara para = new CDVPara(doc, CDVOrientation.Vertical, new CDVPara(null, CDVOrientation.Vertical, pstitle, CDVSpan.Maximum, new CDVWord(null, string.Format("{0} {1}", GregorianDateTime.GetMonthName(docData.Month), docData.Year), ts, ps, CDVSpan.Maximum), new CDVWord(null, calLocation.Format("{locationName}, {longitudeText} {latitudeText}, {timeZoneName}"), ps, CDVSpan.Maximum) ) ); CDVPara subRow; CDVPara row = new CDVPara(para, CDVOrientation.Horizontal, pshdr, tsHdr); para.Add(row); row.Add(new CDVWord(row, "Date")); row.Add(aday); row.Add(new CDVWord(row, "")); row.Add(atithi); row.Add(new CDVWord(row, "Tithi/Festival/Paksa")); if (GCDisplaySettings.Current.CalColPaksa) { row.Add(apak); row.Add(new CDVWord(row, "")); } if (GCDisplaySettings.Current.CalColNaksatra) { row.Add(anak); row.Add(new CDVWord(row, "Naksatra")); } if (GCDisplaySettings.Current.CalColYoga) { row.Add(ayog); row.Add(new CDVWord(row, "Yoga")); } if (GCDisplaySettings.Current.CalColFast) { row.Add(afast); row.Add(new CDVWord(row, "Fast")); } if (GCDisplaySettings.Current.CalColMoonRasi) { row.Add(amr); row.Add(new CDVWord(row, "Moon Rasi")); } if (GCDisplaySettings.Current.CalColCoreEvents) { row.Add(amcore); row.Add(new CDVWord(row, "Core Events")); } else { if (GCDisplaySettings.Current.CalColSunrise) { row.Add(amsun1); row.Add(new CDVWord(row, "Sunrise")); } if (GCDisplaySettings.Current.CalColNoon) { row.Add(amsun2); row.Add(new CDVWord(row, "Noon")); } if (GCDisplaySettings.Current.CalColSunset) { row.Add(amsun3); row.Add(new CDVWord(row, "Sunset")); } } for (int i = 0; i < docData.Calendar.m_PureCount; i++) { VAISNAVADAY vd = docData.Calendar.GetDay(i); row = new CDVPara(para, CDVOrientation.Horizontal); para.Add(row); row.Add(new CDVWord(row, vd.date.ToString())); row.Add(aday); row.Add(new CDVWord(row, GCCalendar.GetWeekdayAbbr(vd.date.dayOfWeek), tsWeekday)); row.Add(atithi); row.Add(new CDVWord(row, vd.GetFullTithiName())); if (GCDisplaySettings.Current.CalColPaksa) { row.Add(apak); row.Add(new CDVWord(row, GCPaksa.GetAbbr(vd.astrodata.sunRise.Paksa).ToString())); } if (GCDisplaySettings.Current.CalColNaksatra) { row.Add(anak); row.Add(new CDVWord(row, GCNaksatra.GetName(vd.astrodata.sunRise.Naksatra))); } if (GCDisplaySettings.Current.CalColYoga) { row.Add(ayog); row.Add(new CDVWord(row, GCYoga.GetName(vd.astrodata.sunRise.Yoga))); } if (GCDisplaySettings.Current.CalColFast) { row.Add(afast); row.Add(new CDVWord(row, vd.nFastID > 0 ? "*" : "")); } if (GCDisplaySettings.Current.CalColMoonRasi) { row.Add(amr); row.Add(new CDVWord(row, GCRasi.GetName(vd.astrodata.sunRise.RasiOfMoon))); } if (!GCDisplaySettings.Current.CalColCoreEvents) { if (GCDisplaySettings.Current.CalColSunrise) { row.Add(amsun1); row.Add(new CDVWord(row, vd.astrodata.sunRise.ToShortTimeString())); } if (GCDisplaySettings.Current.CalColNoon) { row.Add(amsun2); row.Add(new CDVWord(row, vd.astrodata.sunNoon.ToShortTimeString())); } if (GCDisplaySettings.Current.CalColSunset) { row.Add(amsun3); row.Add(new CDVWord(row, vd.astrodata.sunSet.ToShortTimeString())); } } row = new CDVPara(para, CDVOrientation.Horizontal); para.Add(row); subRow = new CDVPara(row, CDVOrientation.Vertical); row.Add(atithi); row.Add(subRow); List <VAISNAVAEVENT> evs = vd.VisibleEvents; if (evs.Count > 0 && vd.astrodata.sunRise.longitude >= 0.0) { foreach (VAISNAVAEVENT ve in evs) { subRow.Add(new CDVPara(null, CDVOrientation.Horizontal, new CDVWord(null, ve.text) )); } } if (GCDisplaySettings.Current.CalColCoreEvents) { row.Add(amcore); subRow = new CDVPara(row, CDVOrientation.Vertical); row.Add(subRow); bool show = false; foreach (TCoreEvent tce in vd.coreEvents) { if (tce.nType == CoreEventType.CCTYPE_S_ARUN) { show = GCDisplaySettings.Current.CalColSunrise; } else if (tce.nType == CoreEventType.CCTYPE_S_RISE) { show = GCDisplaySettings.Current.CalColSunrise; } else if (tce.nType == CoreEventType.CCTYPE_S_NOON) { show = GCDisplaySettings.Current.CalColNoon; } else if (tce.nType == CoreEventType.CCTYPE_S_SET) { show = GCDisplaySettings.Current.CalColSunset; } else { show = true; } if (show) { subRow.Add(new CDVPara(null, CDVOrientation.Horizontal, tsWeekday, new CDVWord(null, tce.TypeString), amcoretime, new CDVWord(null, vd.GetCoreEventTime(tce)))); } } } } return(para); }