示例#1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtName.Text))
            {
                MessageBox.Show("Please enter the Occasion or Event description.",
                                "Add Occasion or Event", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                this.txtName.Focus();
                return;
            }

            if (this.UserOccasion == null)
            {
                this.UserOccasion = new UserOccasion();
            }

            this.UserOccasion.Name  = this.txtName.Text;
            this.UserOccasion.Notes = this.txtNotes.Text;
            this.UserOccasion.Color = this._selectedForeColor;

            if (rbOneTime.Checked)
            {
                this.UserOccasion.JewishDate       = this.JewishDate;
                this.UserOccasion.UserOccasionType = UserOccasionTypes.OneTime;
            }
            else if (this.rbJewishYearly.Checked)
            {
                this.UserOccasion.JewishDate       = this.JewishDate;
                this.UserOccasion.UserOccasionType = UserOccasionTypes.HebrewDateRecurringYearly;
            }
            else if (this.rbJewishMonthly.Checked)
            {
                this.UserOccasion.JewishDate       = this.JewishDate;
                this.UserOccasion.UserOccasionType = UserOccasionTypes.HebrewDateRecurringMonthly;
            }
            else if (this.rbSecularYearly.Checked)
            {
                this.UserOccasion.SecularDate      = this.SecularDate;
                this.UserOccasion.UserOccasionType = UserOccasionTypes.SecularDateRecurringYearly;
            }
            else if (this.rbSecularMonthly.Checked)
            {
                this.UserOccasion.SecularDate      = this.SecularDate;
                this.UserOccasion.UserOccasionType = UserOccasionTypes.SecularDateRecurringMonthly;
            }

            if (!Properties.Settings.Default.UserOccasions.Contains(this.UserOccasion))
            {
                Properties.Settings.Default.UserOccasions.Add(this.UserOccasion);
            }

            //Set the back-color for all occasions on that same day (Jewish/Secular according to occasion type)
            UserOccasionColection.FromSettings(this.JewishDate).ForEach(uo =>
                                                                        uo.BackColor = this._selectedBackColor);

            Properties.Settings.Default.Save();

            OccasionWasChanged?.Invoke(this, this.UserOccasion);

            this.Close();
        }
        private void AddOccasion(UserOccasion occ)
        {
            var lnkLbl = new LinkLabel
            {
                Text         = occ.Name,
                Font         = this._lblOccasionFont,
                LinkColor    = occ.Color,
                Tag          = occ,
                AutoEllipsis = true,
                Dock         = DockStyle.Fill,
                LinkBehavior = LinkBehavior.HoverUnderline
            };
            string dateDiff = occ.GetAnniversaryString(this.JewishDate, true);
            var    lbl      = new Label
            {
                Dock      = DockStyle.Fill,
                ForeColor = occ.Color,
                Text      = ((!string.IsNullOrWhiteSpace(dateDiff)) ? "(" + dateDiff + ") " : "") +
                            (occ.Notes ?? "")
            };

            lnkLbl.MouseClick += delegate
            {
                this.EditOccasion(occ, null);
            };

            lbl.MouseClick += delegate
            {
                this.EditOccasion(occ, null);
            };

            this.tableLayoutPanel1.Controls.Add(lnkLbl);
            this.tableLayoutPanel1.Controls.Add(lbl);
        }
 private void GoToSelectedOccasionUpcoming()
 {
     if (this.listView1.SelectedItems.Count > 0)
     {
         //The selected occasion
         UserOccasion uo = (UserOccasion)this.listView1.SelectedItems.OfType <ListViewItem>().First().Tag;
         ((dynamic)this.Owner).SelectedDate = uo.GetUpcomingOccurence();
     }
 }
示例#4
0
        public void EditOccasion(UserOccasion uo)
        {
            this.SelectedJewishDate = uo.JewishDate;
            var sdi = this._singleDateInfoList.FirstOrDefault(t => t.JewishDate == this._selectedDay);

            if (uo != null && this.DailyPanelIsShowing)
            {
                var f = this.splitContainer1.Panel2.Controls[0] as frmDailyInfoEng;
                f.EditOccasion(uo, new Point((int)(sdi.RectangleF.X - f.Width), (int)(sdi.RectangleF.Y + sdi.RectangleF.Height)));
            }
        }
示例#5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Delete the occasion/event \"" +
                                this.UserOccasion.Name + "\"?", "Are you sure?",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                Properties.Settings.Default.UserOccasions.Remove(this.UserOccasion);
                Properties.Settings.Default.Save();
                this.UserOccasion = null;

                OccasionWasChanged?.Invoke(this, this.UserOccasion);

                this.Close();
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("מחק אירוע \"" +
                                this.UserOccasion.Name + "\"?", "האם אתה בטוח?",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                Properties.Settings.Default.UserOccasions.Remove(this.UserOccasion);
                Properties.Settings.Default.Save();
                this.UserOccasion = null;

                if (OccasionWasChanged != null)
                {
                    OccasionWasChanged(this, this.UserOccasion);
                }

                this.Close();
            }
        }
        public void EditOccasion(UserOccasion occ, Point?parentPoint)
        {
            if (this._frmAddOccasionEng != null)
            {
                this._frmAddOccasionEng.CloseStyle = frmAddOccasionEng.CloseStyles.None;
                this._frmAddOccasionEng.Close();
            }
            this._frmAddOccasionEng = new frmAddOccasionEng(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._frmAddOccasionEng.OccasionWasChanged += delegate(object sndr, UserOccasion uo)
            {
                OccasionWasChanged?.Invoke(this, (uo != null ? uo.JewishDate : this._displayingJewishDate));

                if (this._frmAddOccasionEng.UserOccasion == null ||
                    (!UserOccasionColection.FromSettings(this._displayingJewishDate).Contains(this._frmAddOccasionEng.UserOccasion)))
                {
                    this.tableLayoutPanel1.Controls.Remove(lbl);
                    this.tableLayoutPanel1.Controls.Remove(lnkLbl);
                    if (this.tableLayoutPanel1.RowCount > 0)
                    {
                        this.tableLayoutPanel1.RowCount -= 1;
                    }
                }
                else
                {
                    lnkLbl.Text      = this._frmAddOccasionEng.UserOccasion.Name;
                    lnkLbl.LinkColor = this._frmAddOccasionEng.UserOccasion.Color;
                    var dateDiff = this._frmAddOccasionEng.UserOccasion.GetAnniversaryString(this.JewishDate, false);
                    lbl.Text = ((!string.IsNullOrWhiteSpace(dateDiff)) ? "(" + dateDiff + ") " : "") +
                               (this._frmAddOccasionEng.UserOccasion.Notes ?? "");
                    this.tableLayoutPanel1.BackColor = (uo.BackColor != Color.Empty ? uo.BackColor.Color : Color.GhostWhite);
                }
            };
            this.PositionAddOccasion(parentPoint);
        }
示例#8
0
 public frmAddOccasionEng(UserOccasion uoToEdit)
     : this()
 {
     this.UserOccasion = uoToEdit;
     this.Text         = "Edit Occasion - " + this.UserOccasion.Name;
 }
 public frmAddOccasionHeb(UserOccasion uoToEdit)
     : this()
 {
     this.UserOccasion = uoToEdit;
     this.Text         = "עדכן - " + this.UserOccasion.Name;
 }