private string GetDayOfWeekString(JewishDate jd, Location location) { string dow = ""; if (this.rbDOWJewishNum.Checked) { dow = (jd.DayInWeek + 1).ToNumberHeb(); } else if (this.rbDowNum.Checked) { dow = (jd.DayInWeek + 1).ToString(); } else if (this.rbDayOfWeekFull.Checked) { if (jd.DayOfWeek == DayOfWeek.Saturday) { dow = "ש\"ק"; if (!SpecialDay.IsMajorYomTov(jd, location)) { dow += " " + string.Join(" - ", Sedra.GetSedra(jd, location.IsInIsrael) .Select(i => i.nameHebrew)); } } else { dow = Utils.JewishDOWNamesShort[jd.DayInWeek]; } } else if (this.rbDOWEnglish.Checked) { if (jd.DayOfWeek == DayOfWeek.Saturday) { dow = "Shabbos"; if (!SpecialDay.IsMajorYomTov(jd, location)) { dow += " " + string.Join(" - ", Sedra.GetSedra(jd, location.IsInIsrael) .Select(i => i.nameEng)); } } else { dow = jd.DayOfWeek.ToString().Substring(0, 3); } } if (this.choiceDayDetails.ChoiceOneSelected) { string holidayText = Zmanim.GetHolidaysText( Zmanim.GetHolidays(jd, location.IsInIsrael), " - ", !this.rbDOWEnglish.Checked); if (!string.IsNullOrWhiteSpace(holidayText)) { dow += " - " + holidayText; } } return(dow); }
private void ShowDateData() { this.Cursor = Cursors.WaitCursor; var location = (JewishCalendar.Location) this.cmbLocation.SelectedItem; var zmanim = new Zmanim(this._currentJewishDate, location); var dy = DafYomi.GetDafYomi(this._currentJewishDate); var holidays = Zmanim.GetHolidays(this._currentJewishDate, location.IsInIsrael); var holidayList = holidays.Cast <SpecialDay>(); var netzshkia = zmanim.GetNetzShkia(); var netz = netzshkia != null ? netzshkia[0] : new HourMinute(); var shkia = netzshkia != null ? netzshkia[1] : netz; var chatzos = zmanim.GetChatzos(); var shaaZmanis = zmanim.GetShaaZmanis(); var shaaZmanis90 = zmanim.GetShaaZmanis(90); var bold = new Font(this.richTextBox1.Font, FontStyle.Bold | FontStyle.Underline); this.richTextBox1.Clear(); this.richTextBox1.SelectionColor = Color.DarkBlue; this.richTextBox1.SelectionFont = bold; this.richTextBox1.SelectedText = Utils.JewishDOWNames[(int)this._currentJewishDate.DayOfWeek].ToString() + " - " + this._currentJewishDate.ToShortDateStringHeb() + Environment.NewLine; if (holidayList.Count() > 0) { this.richTextBox1.SelectedText = Environment.NewLine + Zmanim.GetHolidaysText(holidays, " - ", true) + Environment.NewLine; if (holidayList.Any(h => h.DayType.HasFlag(SpecialDayTypes.HasCandleLighting))) { this.AddLine("הדלקת נרות", (shkia - location.CandleLighting).ToString24H()); } } this.richTextBox1.SelectionColor = Color.Black; this.richTextBox1.SelectedText = Environment.NewLine; this.AddLine("פרשת השבוע", string.Join(" ", Sedra.GetSedra(this._currentJewishDate, location.IsInIsrael).Select(i => i.nameHebrew))); this.AddLine("תאריך לועזי", this._currentDate.ToString("D", Program.HebrewCultureInfo)); if (dy != null) { this.AddLine("דף היומי", dy.ToStringHeb()); } this.richTextBox1.SelectionFont = this.richTextBox1.Font; this.richTextBox1.SelectedText = string.Format("{0}----------------------------------------------{0}" + "זמני היום עבור {1}{0}-----------------------------------------------{0}", Environment.NewLine, location.Name); this.AddLine("עלות השחר - 90", (netz - 90).ToString24H()); this.AddLine("עלות השחר - 72", (netz - 72).ToString24H()); this.AddLine("נץ החמה", netz.ToString24H()); this.AddLine("סזק\"ש מג\"א", ((netz - 90) + (int)Math.Floor(shaaZmanis90 * 3D)).ToString24H()); this.AddLine("סזק\"ש גר\"א", (netz + (int)Math.Floor(shaaZmanis * 3D)).ToString24H()); this.AddLine("סז\"ת מג\"א", ((netz - 90) + (int)Math.Floor(shaaZmanis90 * 4D)).ToString24H()); this.AddLine("סז\"ת גר\"א", (netz + (int)Math.Floor(shaaZmanis * 4D)).ToString24H()); this.AddLine("חצות היום והלילה", chatzos.ToString24H()); this.AddLine("מנחה גדולה", (chatzos + (int)(shaaZmanis * 0.5)).ToString24H()); this.AddLine("שקיעת החמה", shkia.ToString24H()); this.AddLine("צה\"כ 45", (shkia + 45).ToString24H()); this.AddLine("צה\"כ ר\"ת", (shkia + 72).ToString24H()); this.Cursor = Cursors.Default; }
private void ShowDateData() { this.Cursor = Cursors.WaitCursor; var location = (JewishCalendar.Location) this.cmbLocation.SelectedItem; var zmanim = new Zmanim(this._currentJewishDate, location); var dy = DafYomi.GetDafYomi(this._currentJewishDate); var holidays = Zmanim.GetHolidays(this._currentJewishDate, location.IsInIsrael); var holidayList = holidays.Cast <SpecialDay>(); var netzshkia = zmanim.GetNetzShkia(); var netz = netzshkia != null ? netzshkia[0] : new HourMinute(); var shkia = netzshkia != null ? netzshkia[1] : netz; var chatzos = zmanim.GetChatzos(); var shaaZmanis = zmanim.GetShaaZmanis(); var shaaZmanis90 = zmanim.GetShaaZmanis(90); var bold = new Font(this.richTextBox1.Font, FontStyle.Bold | FontStyle.Underline); this.SetlblDiff(); this.richTextBox1.Clear(); this.richTextBox1.SelectionColor = Color.DarkBlue; this.richTextBox1.SelectionFont = bold; this.richTextBox1.SelectedText = this._currentJewishDate.DayOfWeek.ToString() + " - " + this._currentJewishDate.ToShortDateString() + Environment.NewLine; if (holidayList.Count() > 0) { this.richTextBox1.SelectedText = Environment.NewLine + Zmanim.GetHolidaysText(holidays, " - ", false) + Environment.NewLine; if (holidayList.Any(h => h.DayType.HasFlag(SpecialDayTypes.HasCandleLighting))) { this.AddLine("Candle Lighting", (shkia - location.CandleLighting).ToString()); } } this.richTextBox1.SelectionColor = Color.Black; this.richTextBox1.SelectedText = Environment.NewLine; this.AddLine("Weekly Sedra", string.Join(" ", Sedra.GetSedra(this._currentJewishDate, location.IsInIsrael).Select(i => i.nameEng))); this.AddLine("Secular Date", this._currentDate.ToString("D", System.Threading.Thread.CurrentThread.CurrentCulture)); if (dy != null) { this.AddLine("Daf Yomi", dy.ToString()); } this.richTextBox1.SelectionFont = this.richTextBox1.Font; this.richTextBox1.SelectedText = string.Format("{0}---------------------------------------------{0}" + "Zmanim for {1}{0}---------------------------------------------{0}", Environment.NewLine, location.Name); this.AddLine("Alos Hashachar - 90", (netz - 90).ToString()); this.AddLine("Alos Hashachar - 72", (netz - 72).ToString()); this.AddLine("Netz Hachama", netz.ToString()); this.AddLine("Krias Shma - MG\"A", ((netz - 90) + (int)Math.Floor(shaaZmanis90 * 3D)).ToString()); this.AddLine("Krias Shma - GR\"A", (netz + (int)Math.Floor(shaaZmanis * 3D)).ToString()); this.AddLine("Zeman Tefillah - MG\"A", ((netz - 90) + (int)Math.Floor(shaaZmanis90 * 4D)).ToString()); this.AddLine("Zeman Tefillah - GR\"A", (netz + (int)Math.Floor(shaaZmanis * 4D)).ToString()); this.AddLine("Chatzos - Day & Night", chatzos.ToString()); this.AddLine("Mincha Gedolah", (chatzos + (int)(shaaZmanis * 0.5)).ToString()); this.AddLine("Shkias Hachama", shkia.ToString()); this.AddLine("Nightfall 45", (shkia + 45).ToString()); this.AddLine("Rabbeinu Tam", (shkia + 72).ToString()); this.Cursor = Cursors.Default; }
private void DrawSingleDay(Graphics g, JewishDate currDate, float width, float height, float currX, float currY) { var zmanim = new Zmanim(currDate, this._currentLocation); var rect = new RectangleF(currX, currY, width, height); var text = currDate.Day.ToNumberHeb(); var holidays = Zmanim.GetHolidays(currDate, this._currentLocation.IsInIsrael); string textZmanim = ""; if (currDate.DayOfWeek == DayOfWeek.Saturday) { foreach (SpecialDay sd in holidays) { if (sd.DayType == SpecialDayTypes.Shabbos) { holidays.Remove(sd); break; } } foreach (SpecialDay sd in holidays) { if (sd.NameEnglish == "Shabbos Mevarchim") { var nextMonth = currDate + 12; var molad = Molad.GetMolad(nextMonth.Month, nextMonth.Year); sd.NameHebrew += "\nמולד: " + molad.ToStringHeb(zmanim.GetShkia()); break; } } textZmanim = string.Join(" - ", Sedra.GetSedra(currDate, false).Select(i => i.nameHebrew)) + "\n" + Zmanim.GetHolidaysText(holidays, "\n", true); g.FillRectangle(Program.ShabbosBrush, rect); } else { if (currDate.DayOfWeek == DayOfWeek.Sunday) { width = (this.pnlMain.Width - currX) - 1f; rect.Width = width; } if (holidays.Count > 0) { var hlist = holidays.Cast <SpecialDay>(); if (hlist.Any(h => h.DayType.HasFlag(SpecialDayTypes.HasCandleLighting))) { textZmanim += "הדלק\"נ: " + (zmanim.GetShkia() - this._currentLocation.CandleLighting).ToString24H() + "\n"; } if (hlist.Any(h => (h.DayType & SpecialDayTypes.MajorYomTov) == SpecialDayTypes.MajorYomTov || (h.DayType & SpecialDayTypes.MinorYomtov) == SpecialDayTypes.MinorYomtov)) { g.FillRectangle(Program.YomtovBrush, rect); } textZmanim += Zmanim.GetHolidaysText(holidays, "\n", true); } } this._dateList.Add(Tuple.Create(currDate, textZmanim, rect)); if (this._selectedDay != null && currDate == this._selectedDay) { g.FillRectangle(Program.SelectedDayBackgroundBrush, rect); } g.DrawRectangle(Program.DayCellBorderPen, rect.X, rect.Y, rect.Width, rect.Height); if (currDate == this._todayJewishDate) { var eh = rect.Height / 3.3f; var ew = rect.Width / 3.3f; g.FillClosedCurve(Program.DayHeadersBGBrush, new PointF[] { new PointF(rect.X + ew, rect.Y + eh), new PointF(rect.X + (rect.Width - ew), rect.Y + eh), new PointF(rect.X + (rect.Width - ew), rect.Y + (rect.Height - eh)), new PointF(rect.X + ew, rect.Y + (rect.Height - eh)) }, System.Drawing.Drawing2D.FillMode.Alternate, 3f); } rect.Height /= 2f; rect.X = currX + (width / 2); rect.Width = (width / 2); g.DrawString(text, this._dayFont, Program.DayTextBrush, rect, Program.StringFormat); rect.X = currX; g.DrawString(currDate.GregorianDate.Day.ToString(), this._secularDayFont, Program.SecularDayBrush, rect, Program.StringFormat); rect.Width = width; if (!string.IsNullOrWhiteSpace(textZmanim)) { rect.Y += rect.Height; rect.Height = height - rect.Height; g.DrawString(textZmanim, this._zmanimFont, Program.ZmanimBrush, rect, Program.StringFormat); } }
internal void ShowDateData() { this.Cursor = Cursors.WaitCursor; var showSeconds = Properties.Settings.Default.ShowSeconds; var dy = DafYomi.GetDafYomi(this._displayingJewishDate); var netzshkia = this._dailyZmanim.NetzShkiaAtElevation; var netzshkiaMishor = this._dailyZmanim.NetzShkiaMishor; var netz = this._dailyZmanim.NetzAtElevation; var shkia = this._dailyZmanim.ShkiaAtElevation; var netzMishor = this._dailyZmanim.NetzMishor; var shkiaMishor = this._dailyZmanim.ShkiaMishor; var chatzos = this._dailyZmanim.Chatzos; var shaaZmanis = this._dailyZmanim.ShaaZmanis; var shaaZmanis90 = this._dailyZmanim.ShaaZmanisMga; var html = new StringBuilder(); html.AppendFormat("<div class=\"padWidth royalBlue bold\">{0}</div>", this._displayingJewishDate.ToLongDateStringHeb()); html.AppendFormat("<div class=\"padWidth lightSteelBlue\">{0}</div>", this._displayingSecularDate.ToString("D", Program.HebrewCultureInfo)); //If the secular day is a day behind as day being displayed is todays date and it is after sunset, //the user may get confused as the secular date for today and tomorrow will be the same. //So we esplain'in it to them... if (this._secularDateAtMidnight.Date != this._displayingSecularDate.Date) { html.Append("<div class=\"padWidth rosyBrown seven italic\">שים לב: תאריך הלועזי מתחיל בשעה 0:00</div>"); } this.DisplayDateDiff(html); html.Append("<br />"); if (this._holidays.Count() > 0) { foreach (var h in this._holidays) { html.AppendFormat("<div class=\"padWidth\">{0}", h.NameHebrew); if (h.NameEnglish == "Shabbos Mevarchim") { var nextMonth = this._displayingJewishDate + 12; html.AppendFormat(" - חודש {0}", Utils.GetProperMonthNameHeb(nextMonth.Year, nextMonth.Month)); var molad = Molad.GetMolad(nextMonth.Month, nextMonth.Year); var dim = JewishDateCalculations.DaysInJewishMonth(this._displayingJewishDate.Year, this._displayingJewishDate.Month); var dow = dim - this._displayingJewishDate.Day; if (dim == 30) { dow--; } html.AppendFormat("<div>המולד: {0}</div>", molad.ToStringHeb(this._dailyZmanim.ShkiaAtElevation)); html.AppendFormat("<div>ראש חודש: {0}{1}</div>", Utils.JewishDOWNames[dow], (dim == 30 ? ", " + Utils.JewishDOWNames[(dow + 1) % 7] : "")); } html.Append("</div>"); if (h.NameEnglish.Contains("Sefiras Ha'omer")) { var dayOfOmer = this._displayingJewishDate.GetDayOfOmer(); html.AppendFormat("<div><a onclick=\"javacript:window.external.showSefirah({0}, true);return false;\" class=\"nine bluoid pointer\">{1}</a></div>", dayOfOmer, Utils.GetOmerNusach(dayOfOmer, Properties.Settings.Default.Nusach)); } if (h.DayType.IsSpecialDayType(SpecialDayTypes.EruvTavshilin)) { html.Append("<div class=\"padWidth crimson bold\">עירוב תבשילין</div>"); } } } html.Append("<table>"); if (shkia != TimeOfDay.NoValue && this._holidays.Any(h => h.DayType.IsSpecialDayType(SpecialDayTypes.HasCandleLighting))) { this.AddLine(html, "הדלקת נרות", (shkia - this._dailyZmanim.Location.CandleLighting).ToString24H(showSeconds), wideDescription: false); html.Append("<tr><td class=\"nobg\" colspan=\"3\"> </td></tr>"); } this.AddLine(html, "פרשת השבוע", string.Join(" ", Sedra.GetSedra(this._displayingJewishDate, this._dailyZmanim.Location.IsInIsrael).Select(i => i.nameHebrew)), wideDescription: false); if (dy != null) { this.AddLine(html, "דף יומי", dy.ToStringHeb(), wideDescription: false); } html.Append("</table><br />"); html.AppendFormat("<div class=\"padBoth lightSteelBlueBG ghostWhite nine bold clear\">זמני היום ב{0}</div>", this._dailyZmanim.Location.NameHebrew); html.Append("<table>"); if (netz == TimeOfDay.NoValue) { this.AddLine(html, "הנץ החמה", "השמש אינו עולה", bold: true, emphasizeValue: true); } else { if (this._displayingJewishDate.Month == 1 && this._displayingJewishDate.Day == 14) { this.AddLine(html, "סו\"ז אכילת חמץ", ((netz - 90) + (int)Math.Floor(shaaZmanis90 * 4D)).ToString24H(showSeconds), bold: true); this.AddLine(html, "סו\"ז שריפת חמץ", ((netz - 90) + (int)Math.Floor(shaaZmanis90 * 5D)).ToString24H(showSeconds), bold: true); html.Append("<br />"); } this.AddLine(html, "עלות השחר - 90", (netzMishor - 90).ToString24H(showSeconds)); this.AddLine(html, "עלות השחר - 72", (netzMishor - 72).ToString24H(showSeconds)); if (netz == netzMishor) { this.AddLine(html, "הנץ החמה", netz.ToString24H(showSeconds), bold: true, emphasizeValue: true); } else { this.AddLine(html, "הנה\"ח <span class=\"reg lightSteelBlue\">...מ " + this._dailyZmanim.Location.Elevation.ToString() + " מטר</span>", netz.ToString24H(showSeconds)); this.AddLine(html, "הנה\"ח <span class=\"reg lightSteelBlue\">...גובה פני הים</span>", netzMishor.ToString24H(showSeconds), bold: true, emphasizeValue: true); } this.AddLine(html, "סוזק\"ש - מג\"א", this._dailyZmanim.GetZman(ZmanType.KShmMga).ToString24H(showSeconds)); this.AddLine(html, "סוזק\"ש - הגר\"א", this._dailyZmanim.GetZman(ZmanType.KshmGra).ToString24H(showSeconds)); this.AddLine(html, "סוז\"ת - מג\"א", this._dailyZmanim.GetZman(ZmanType.TflMga).ToString24H(showSeconds)); this.AddLine(html, "סוז\"ת - הגר\"א", this._dailyZmanim.GetZman(ZmanType.TflGra).ToString24H(showSeconds)); } if (netz != TimeOfDay.NoValue && shkia != TimeOfDay.NoValue) { this.AddLine(html, "חצות היום והלילה", chatzos.ToString24H(showSeconds)); this.AddLine(html, "מנחה גדולה", this._dailyZmanim.GetZman(ZmanType.MinchaG).ToString24H(showSeconds)); this.AddLine(html, "מנחה קטנה", this._dailyZmanim.GetZman(ZmanType.MinchaK).ToString24H(showSeconds)); this.AddLine(html, "פלג המנחה", this._dailyZmanim.GetZman(ZmanType.MinchaPlg).ToString24H(showSeconds)); } if (shkia == TimeOfDay.NoValue) { this.AddLine(html, "שקיעת החמה", "השמש אינו שוקע", bold: true, emphasizeValue: true); } else { if (shkia == shkiaMishor) { this.AddLine(html, "שקיעת החמה", shkia.ToString24H(showSeconds), bold: true, emphasizeValue: true); } else { this.AddLine(html, "שקה\"ח <span class=\"reg lightSteelBlue\">...גובה פני הים</span>", shkiaMishor.ToString24H(showSeconds)); this.AddLine(html, "שקה\"ח <span class=\"reg lightSteelBlue\">...מ " + this._dailyZmanim.Location.Elevation.ToString() + " מטר</span>", shkia.ToString24H(showSeconds), bold: true, emphasizeValue: true); } this.AddLine(html, "צאת הכוכבים 45", (shkia + 45).ToString24H(showSeconds)); this.AddLine(html, "רבינו תם", (shkia + 72).ToString24H(showSeconds)); this.AddLine(html, "72 דקות זמניות", (shkia + (int)(shaaZmanis * 1.2)).ToString24H(showSeconds)); this.AddLine(html, "72 דקות זמניות לחומרה", (shkia + (int)(shaaZmanis90 * 1.2)).ToString24H(showSeconds)); } html.Append("</table>"); this.webBrowser1.DocumentText = Properties.Resources.InfoHTMLHeb .Replace("{{BODY}}", html.ToString()); this.tableLayoutPanel1.Controls.Clear(); foreach (UserOccasion occ in this._occasions) { this.AddOccasion(occ); } var bg = (from o in this._occasions where o.BackColor != Color.Empty select o.BackColor).FirstOrDefault(); this.tableLayoutPanel1.BackColor = (bg != Color.Empty ? bg.Color : Color.GhostWhite); this.Cursor = Cursors.Default; }
private SingleDateInfo DrawSingleDay(Graphics g, JewishDate currDate, float width, float height, float currX, float currY) { var zmanim = new Zmanim(currDate, this._currentLocation); var rect = new RectangleF(currX, currY, width, height); var text = currDate.Day.ToNumberHeb().Replace("'", ""); var holidays = Zmanim.GetHolidays(currDate, this._currentLocation.IsInIsrael); SingleDateInfo sdi = new SingleDateInfo(currDate, new RectangleF(rect.Location, rect.Size)); this._singleDateInfoList.Add(sdi); if (this._isFirstOpen) { //We will be repainting anyway... return(sdi); } string textZmanim = ""; if (currDate.DayOfWeek == DayOfWeek.Saturday) { bool noSedra = false; width = (this.pnlMain.Width - currX) - 1f; rect.Width = width; foreach (SpecialDay sd in holidays) { if (sd.DayType == SpecialDayTypes.Shabbos) { holidays.Remove(sd); break; } } foreach (SpecialDay sd in holidays) { if (sd.DayType.IsSpecialDayType(SpecialDayTypes.MajorYomTov) || sd.DayType.IsSpecialDayType(SpecialDayTypes.CholHamoed)) { noSedra = true; } if (sd.NameEnglish == "Shabbos Mevarchim") { var nextMonth = currDate + 12; var molad = Molad.GetMolad(nextMonth.Month, nextMonth.Year); sd.NameEnglish += "\nMolad: " + molad.ToString(zmanim.GetShkia()); break; } } if (noSedra) { textZmanim = Zmanim.GetHolidaysText(holidays, "\n", false); } else { textZmanim = string.Join(" - ", Sedra.GetSedra(currDate, this._currentLocation.IsInIsrael).Select(i => i.nameEng)) + "\n" + Zmanim.GetHolidaysText(holidays, "\n", false); } g.FillRectangle(Program.ShabbosBrush, rect); } else if (holidays.Count > 0) { var hlist = holidays.Cast <SpecialDay>(); if (hlist.Any(h => (h.DayType.IsSpecialDayType(SpecialDayTypes.HasCandleLighting)))) { textZmanim += "Candles: " + (zmanim.GetShkia() - this._currentLocation.CandleLighting).ToString() + "\n"; } if (hlist.Any(h => (h.DayType.IsSpecialDayType(SpecialDayTypes.MajorYomTov)))) { g.FillRectangle(Program.MajorYomtovBrush, rect); } else if (hlist.Any(h => (h.DayType.IsSpecialDayType(SpecialDayTypes.MinorYomtov)))) { g.FillRectangle(Program.MinorYomtovBrush, rect); } textZmanim += Zmanim.GetHolidaysText(holidays, "\n", false); } if (sdi.UserOccasions.Any(bc => bc.BackColor != Color.Empty)) { g.FillRectangle(new SolidBrush(sdi.UserOccasions.First(bc => bc.BackColor.Color != Color.Empty).BackColor), rect); } if (this._selectedDay != null && currDate == this._selectedDay) { g.FillRectangle(Program.SelectedDayBackgroundBrush, rect); } g.DrawRectangle(Program.DayCellBorderPen, rect.X, rect.Y, rect.Width, rect.Height); if (currDate == this._todayJewishDate) { var eh = rect.Height / 3.3f; var ew = rect.Width / 3.3f; g.FillClosedCurve(Program.DayHeadersBGBrush, new PointF[] { new PointF(rect.X + ew, rect.Y + eh), new PointF(rect.X + (rect.Width - ew), rect.Y + eh), new PointF(rect.X + (rect.Width - ew), rect.Y + (rect.Height - eh)), new PointF(rect.X + ew, rect.Y + (rect.Height - eh)) }, System.Drawing.Drawing2D.FillMode.Alternate, 3f); } //accumulative height of all text rectangles - keeps track of current Y position in box. float offsetTop = 0f; //Padding top - varies according to what needs to be displayed beneath it rect.Y = currY + (rect.Height / (sdi.UserOccasions.Count + holidays.Count > 1 ? 20 : 10)); //Hebrew day will be on the left, so we cut the rectangle in half. rect.Width /= 2; rect.Height = TextRenderer.MeasureText(g, text, this._dayFont, rect.Size.ToSize(), Program.TextFormatFlags).Height; offsetTop += rect.Height; TextRenderer.DrawText( g, text, this._dayFont, Rectangle.Truncate(rect), Program.DayTextColor, Program.TextFormatFlags); //Secular day will be on the right, so we move the rectangle over to the right of the box. //No need to resize the width. rect.X += rect.Width; TextRenderer.DrawText( g, currDate.GregorianDate.Day.ToString(), this._secularDayFont, Rectangle.Truncate(rect), Program.SecularDayColor, Program.TextFormatFlags); //Move rectangle back over to the left of the box rect.X = currX; //resize rectangle to fix whole box rect.Width = width; offsetTop += rect.Height / (holidays.Count > 1 ? 5 : 3); foreach (var o in sdi.UserOccasions) { //Get the text size for this occasions label. var textSize = TextRenderer.MeasureText(g, o.Name, this._userOccasionFont, rect.Size.ToSize(), Program.TextFormatFlags); //Move the Y position down to empty space. rect.Y = currY + offsetTop; rect.Height = textSize.Height; //Save the exact position of the occasion label so when the user clicks on it afterwards, we can open the occasion for editing. //Note: the occasion labels are centered in the days box, so we can't use the X position of rect (which is always 0). o.Rectangle = new RectangleF(rect.X + ((rect.Width / 2) - (textSize.Width / 2)), rect.Y, textSize.Width, textSize.Height); TextRenderer.DrawText( g, o.Name, this._userOccasionFont, Rectangle.Truncate(rect), o.Color, Program.TextFormatFlags); offsetTop += rect.Height; } if (!string.IsNullOrWhiteSpace(textZmanim)) { rect.Y = currY + offsetTop; rect.Height = height - offsetTop; TextRenderer.DrawText( g, textZmanim, this._zmanimFont, Rectangle.Truncate(rect), Program.ZmanimColor, Program.TextFormatFlags); } return(sdi); }
private void DisplayZmanim(StringBuilder html) { var showSeconds = Properties.Settings.Default.ShowSeconds; var dy = DafYomi.GetDafYomi(this._displayingJewishDate); var netz = this._dailyZmanim.NetzAtElevation; var shkia = this._dailyZmanim.ShkiaAtElevation; var netzMishor = this._dailyZmanim.NetzMishor; var shkiaMishor = this._dailyZmanim.ShkiaMishor; var chatzos = this._dailyZmanim.Chatzos; var shaaZmanis = this._dailyZmanim.ShaaZmanis; var shaaZmanis90 = this._dailyZmanim.ShaaZmanisMga; var feet = "...at " + (this._dailyZmanim.Location.Elevation * 3.28084).ToString("N0") + " ft."; this.AddLine(html, "Weekly Sedra", string.Join(" ", Sedra.GetSedra(this._displayingJewishDate, this._dailyZmanim.Location.IsInIsrael).Select(i => i.nameEng)), wideDescription: false); if (dy != null) { this.AddLine(html, "Daf Yomi", dy.ToString(), wideDescription: false); } html.Append("</table><br />"); html.AppendFormat("<div class=\"padBoth lightSteelBlueBG ghostWhite nine bold clear\">Zmanim for {0}</div>", this._dailyZmanim.Location.Name); html.Append("<table>"); if (netz == TimeOfDay.NoValue) { this.AddLine(html, "Netz Hachama", "The does not rise", bold: true, emphasizeValue: true); } else { if (this._displayingJewishDate.Month == 1 && this._displayingJewishDate.Day == 14) { this.AddLine(html, "Stop eating Chometz", ((netz - 90d) + (shaaZmanis90 * 4d)).ToString24H(showSeconds), bold: true); this.AddLine(html, "Burn Chometz before", ((netz - 90d) + (shaaZmanis90 * 5d)).ToString24H(showSeconds), bold: true); html.Append("<br />"); } this.AddLine(html, "Alos Hashachar - 90", (netzMishor - 90d).ToString(showSeconds)); this.AddLine(html, "Alos Hashachar - 72", (netzMishor - 72d).ToString(showSeconds)); if (netz != netzMishor) { this.AddLine(html, "Sunrise <em class=\"reg lightSteelBlue\">" + feet + "</em>", netz.ToString(showSeconds)); } this.AddLine(html, "Netz Hachama", netzMishor.ToString(showSeconds), bold: true, emphasizeValue: true); this.AddLine(html, "Krias Shma - MG\"A", this._dailyZmanim.GetZman(ZmanType.KShmMga).ToString(showSeconds)); this.AddLine(html, "Krias Shma - GR\"A", this._dailyZmanim.GetZman(ZmanType.KshmGra).ToString(showSeconds)); this.AddLine(html, "Zeman Tefillah - MG\"A", this._dailyZmanim.GetZman(ZmanType.TflMga).ToString(showSeconds)); this.AddLine(html, "Zeman Tefillah - GR\"A", this._dailyZmanim.GetZman(ZmanType.TflGra).ToString(showSeconds)); } if (netz != TimeOfDay.NoValue && shkia != TimeOfDay.NoValue) { this.AddLine(html, "Chatzos - Day & Night", chatzos.ToString(showSeconds)); this.AddLine(html, "Mincha Gedolah", this._dailyZmanim.GetZman(ZmanType.MinchaG).ToString(showSeconds)); this.AddLine(html, "Mincha Ktanah", this._dailyZmanim.GetZman(ZmanType.MinchaK).ToString(showSeconds)); this.AddLine(html, "Plag Hamincha", this._dailyZmanim.GetZman(ZmanType.MinchaPlg).ToString(showSeconds)); } if (shkia == TimeOfDay.NoValue) { this.AddLine(html, "Shkias Hachama", "The sun does not set", bold: true, emphasizeValue: true); } else { if (shkia == shkiaMishor) { this.AddLine(html, "Shkias Hachama", shkia.ToString(showSeconds), bold: true, emphasizeValue: true); } else { this.AddLine(html, "Sunset <em class=\"reg lightSteelBlue\">...at Sea Level</em>", shkiaMishor.ToString(showSeconds)); this.AddLine(html, "Shkiah <em class=\"reg lightSteelBlue\"> " + feet + "</em>", shkia.ToString(showSeconds), bold: true, emphasizeValue: true); } this.AddLine(html, "Nightfall 45", (shkia + 45d).ToString(showSeconds)); this.AddLine(html, "Rabbeinu Tam", (shkia + 72d).ToString(showSeconds)); this.AddLine(html, "72 \"Zmaniot\"", (shkia + (shaaZmanis * 1.2)).ToString(showSeconds)); this.AddLine(html, "72 \"Zmaniot MA\"", (shkia + (shaaZmanis90 * 1.2)).ToString(showSeconds)); } html.Append("</table>"); }