Exemplo n.º 1
0
        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;
        }
Exemplo n.º 3
0
        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;
        }
        public frmDailyInfoEng(JewishDate jd, Location location)
        {
            this._displayingJewishDate = jd;
            this._dailyZmanim          = new DailyZmanim(jd.GregorianDate, location);
            this._holidays             = Zmanim.GetHolidays(jd, location.IsInIsrael).Cast <SpecialDay>();
            this._occasions            = UserOccasionColection.FromSettings(jd);

            InitializeComponent();

            this._lblOccasionFont = new Font(this.Font, FontStyle.Bold);
            this.webBrowser1.ObjectForScripting = new ScriptingObject();
        }
        public frmDailyInfoHeb(JewishDate jd, Location location)
        {
            this._displayingJewishDate = jd;
            this.SetSecularDate();
            this._dailyZmanim = new DailyZmanim(this._secularDateAtMidnight, location);
            this._holidays    = Zmanim.GetHolidays(jd, location.IsInIsrael).Cast <SpecialDay>();
            this._occasions   = UserOccasionColection.FromSettings(jd);

            InitializeComponent();

            this._lblOccasionFont = new Font(this.tableLayoutPanel1.Font, FontStyle.Bold);
            this.webBrowser1.ObjectForScripting = new ScriptingObject();
        }
Exemplo n.º 6
0
        private void ShowSingleDayToolTip(Tuple <JewishDate, string, RectangleF> tuple)
        {
            var zmanim    = new Zmanim(tuple.Item1, this._currentLocation);
            var shkiaNetz = zmanim.GetNetzShkia();
            var text      = tuple.Item1.GregorianDate.ToString("MMMM d, yyyy") + "\n" +
                            (string.IsNullOrWhiteSpace(tuple.Item2) ? "" : tuple.Item2 + "\n") +
                            "Sunrise: " + shkiaNetz[0].ToString() + "\n" +
                            "Sunset: " + shkiaNetz[1].ToString();

            this.toolTip1.ToolTipTitle = tuple.Item1.DayOfWeek.ToString() + " " + tuple.Item1.ToLongDateString();
            this.toolTip1.Show(text, this.pnlMain, this._pnlMouseLocation.X + 5, this._pnlMouseLocation.Y + 5, 10000);
            this.pnlMain.Focus();
        }
Exemplo n.º 7
0
        private void SetZmanim()

        {
            this.timer1.Stop();

            this._jdate = new JewishDate(this._today);
            var ns = Zmanim.GetNetzShkia(DateTime.Now, this._location);

            this._netzSeconds  = ns[0].TotalSeconds;
            this._shkiaSeconds = ns[1].TotalSeconds;

            var totalDaySeconds = this._shkiaSeconds - this._netzSeconds;

            this._zmaniosDaytimeSecondsPerHour   = totalDaySeconds / 12d;
            this._zmaniosDaytimeSecondsPerMinute = totalDaySeconds / 720d;
            this._zmaniosDaytimeSecondsPerSecond = totalDaySeconds / 43200d;

            var totalNightSeconds = 86400 - totalDaySeconds;

            this._zmaniosNighttimeSecondsPerHour   = totalNightSeconds / 12d;
            this._zmaniosNighttimeSecondsPerMinute = totalNightSeconds / 720d;
            this._zmaniosNighttimeSecondsPerSecond = totalNightSeconds / 43200d;


            var nowSeconds = DateTime.Now.TimeOfDay.TotalSeconds;

            this.richTextBox1.Clear();

            this.richTextBox1.Text += $@"{this._jdate.ToLongDateString()}
{this._today.ToLongDateString()}
Hanetz Hachama: {ns[0].ToString24H(true)}
Shkias Hachama: {ns[1].ToString24H(true)}
Hour Zmanios Day: {this._zmaniosDaytimeSecondsPerHour / 60:N2} minutes
Hour Zmanios Night: {this._zmaniosNighttimeSecondsPerHour / 60:N2}  minutes";


            if (this._netzSeconds <= nowSeconds && this._shkiaSeconds > nowSeconds)
            {
                //DayTime
                this.timer1.Interval = Convert.ToInt32(this._zmaniosDaytimeSecondsPerSecond * 1000);
            }
            else
            {
                this.timer1.Interval = Convert.ToInt32(this._zmaniosNighttimeSecondsPerSecond * 1000);
            }

            this.timer1.Start();
        }
Exemplo n.º 8
0
        private void ShowSingleDayToolTip(Tuple <JewishDate, string, RectangleF> tuple)
        {
            var zmanim    = new Zmanim(tuple.Item1, this._currentLocation);
            var shkiaNetz = zmanim.GetNetzShkia();
            var text      = tuple.Item1.ToShortDateStringHeb() + "\n" +
                            tuple.Item1.GregorianDate.ToString("D", Program.HebrewCultureInfo) + "\n" +
                            (string.IsNullOrWhiteSpace(tuple.Item2) ?
                             "" : ("___________________________\n\n" + tuple.Item2 + "\n")) +
                            "___________________________\n\n" +
                            "נץ החמה: " + shkiaNetz[0].ToString24H() + "\n" +
                            "שקיעת החמה: " + shkiaNetz[1].ToString24H();

            this.toolTip1.ToolTipTitle = tuple.Item1.ToLongDateStringHeb();
            this.toolTip1.Show(text, this.pnlMain, this._pnlMouseLocation.X + 5, this._pnlMouseLocation.Y + 5, 10000);
            this.pnlMain.Focus();
        }
Exemplo n.º 9
0
        private void ShowCurrentDateZmanimData()
        {
            this._holidays              = Zmanim.GetHolidays(this._displayingJewishDate, Program.CurrentLocation.IsInIsrael).Cast <SpecialDay>();
            this.cmbYear.SelectedItem   = Program.HebrewCalendar.GetYear(this._displayingSecularDate);
            this.cmbMonth.SelectedIndex = Program.HebrewCalendar.GetMonth(this._displayingSecularDate) - 1;
            this.cmbDay.SelectedIndex   = Program.HebrewCalendar.GetDayOfMonth(this._displayingSecularDate) - 1;

            this._loading = false;
            this.FillProblemOnahs();
            this.ShowDateData();

            string jdateText = this._displayingJewishDate.ToLongDateStringHeb();

            this.Text            = jdateText;
            this.lblCaption.Text = this.Text;
        }
Exemplo n.º 10
0
        private void ShowSingleDayInfo(SingleDateInfo sdi)
        {
            if (sdi == null)
            {
                return;
            }

            var             zmanim = new Zmanim(sdi.JewishDate, this._currentLocation);
            frmDailyInfoEng f;

            if (!this.DailyPanelIsShowing)
            {
                f = new frmDailyInfoEng((sdi.JewishDate == this._todayJewishDate ? this._todayJewishDate : sdi.JewishDate),
                                        this._currentLocation);
                f.TopLevel            = false;
                f.Parent              = this;
                f.OccasionWasChanged += delegate(object sender, JewishDate jd)
                {
                    var sd = this._singleDateInfoList.FirstOrDefault(d => d.JewishDate == jd);
                    if (sd != null)
                    {
                        sd.UpdateOccasions();
                        this.RedrawSingleDay(sd);
                    }
                    this.OccasionWasChanged?.Invoke(f, new EventArgs());
                };
                f.FormClosed += delegate
                {
                    this.splitContainer1.Panel2Collapsed = true;
                    this.llShowDaily.Visible             = true;
                };
                f.Dock = DockStyle.Fill;
                this.splitContainer1.Panel2.Controls.Add(f);
                f.Show();
                this.llShowDaily.Visible = false;
            }
            else
            {
                f            = this.splitContainer1.Panel2.Controls[0] as frmDailyInfoEng;
                f.JewishDate = (sdi.JewishDate == this._todayJewishDate ? this._todayJewishDate : sdi.JewishDate);
            }
            if (this.splitContainer1.Panel2Collapsed)
            {
                this.splitContainer1.Panel2Collapsed = false;
            }
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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);
        }