public void AddNewOccasion(Point?parentPoint)
 {
     if (this._frmAddOccasionHeb != null)
     {
         this._frmAddOccasionHeb.CloseStyle = frmAddOccasionHeb.CloseStyles.None;
         this._frmAddOccasionHeb.Close();
     }
     this._frmAddOccasionHeb = new frmAddOccasionHeb {
         JewishDate = this._displayingJewishDate
     };
     this.PositionAddOccasion(parentPoint);
     this._frmAddOccasionHeb.OccasionWasChanged += delegate(object sndr, UserOccasion uo)
     {
         if (UserOccasionColection.FromSettings(this.JewishDate).Contains(uo))
         {
             this.AddOccasion(uo);
             this.tableLayoutPanel1.BackColor = (uo.BackColor != Color.Empty ? uo.BackColor.Color : Color.GhostWhite);
         }
         OccasionWasChanged?.Invoke(this, (uo != null ? uo.JewishDate : this._displayingJewishDate));
     };
 }
        public void EditOccasion(UserOccasion occ, Point?parentPoint)
        {
            if (this._frmAddOccasionHeb != null)
            {
                this._frmAddOccasionHeb.CloseStyle = frmAddOccasionHeb.CloseStyles.None;
                this._frmAddOccasionHeb.Close();
            }
            this._frmAddOccasionHeb = new frmAddOccasionHeb(occ);
            LinkLabel lnkLbl = this.tableLayoutPanel1.Controls.OfType <LinkLabel>().First(ll => ll.Tag == occ);
            Label     lbl    = (Label)this.tableLayoutPanel1.Controls[this.tableLayoutPanel1.Controls.IndexOf(lnkLbl) + 1];

            this._frmAddOccasionHeb.OccasionWasChanged += delegate(object sndr, UserOccasion uo)
            {
                OccasionWasChanged?.Invoke(this, (uo != null ? uo.JewishDate : this._displayingJewishDate));

                if (this._frmAddOccasionHeb.UserOccasion == null ||
                    (!UserOccasionColection.FromSettings(this._displayingJewishDate).Contains(this._frmAddOccasionHeb.UserOccasion)))
                {
                    this.tableLayoutPanel1.Controls.Remove(lbl);
                    this.tableLayoutPanel1.Controls.Remove(lnkLbl);
                    if (this.tableLayoutPanel1.RowCount > 0)
                    {
                        this.tableLayoutPanel1.RowCount -= 1;
                    }
                }
                else
                {
                    lnkLbl.Text      = this._frmAddOccasionHeb.UserOccasion.Name;
                    lnkLbl.LinkColor = this._frmAddOccasionHeb.UserOccasion.Color;
                    var dateDiff = this._frmAddOccasionHeb.UserOccasion.GetAnniversaryString(this.JewishDate, true);
                    lbl.Text = ((!string.IsNullOrWhiteSpace(dateDiff)) ? "(" + dateDiff + ") " : "") +
                               (this._frmAddOccasionHeb.UserOccasion.Notes ?? "");
                    this.tableLayoutPanel1.BackColor = (uo.BackColor != Color.Empty ? uo.BackColor.Color : Color.GhostWhite);
                }
            };
            this.PositionAddOccasion(parentPoint);
        }