Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        private void frmAddOccasionEng_Load(object sender, EventArgs e)
        {
            if (this.UserOccasion != null)
            {
                this.txtName.Text     = this.UserOccasion.Name;
                this.txtNotes.Text    = this.UserOccasion.Notes;
                this.txtName.TabIndex = 1000;

                switch (this.UserOccasion.UserOccasionType)
                {
                case UserOccasionTypes.OneTime:
                    this.JewishDate        = this.UserOccasion.JewishDate;
                    this.rbOneTime.Checked = true;
                    break;

                case UserOccasionTypes.HebrewDateRecurringYearly:
                    this.JewishDate             = this.UserOccasion.JewishDate;
                    this.rbJewishYearly.Checked = true;
                    break;

                case UserOccasionTypes.HebrewDateRecurringMonthly:
                    this.JewishDate = this.UserOccasion.JewishDate;
                    this.rbJewishMonthly.Checked = true;
                    break;

                case UserOccasionTypes.SecularDateRecurringYearly:
                    this.SecularDate             = this.UserOccasion.SecularDate;
                    this.rbSecularYearly.Checked = true;
                    break;

                case UserOccasionTypes.SecularDateRecurringMonthly:
                    this.SecularDate = this.UserOccasion.SecularDate;
                    this.rbSecularMonthly.Checked = true;
                    break;
                }
                this.btnAdd.Text        = "Update";
                this.btnDelete.Visible  = true;
                this._selectedForeColor = this.UserOccasion.Color;
            }
            else
            {
                this.btnDelete.Visible  = false;
                this.btnCancel.Location = this.btnDelete.Location;
            }

            this.txtName.ForeColor = this.btnColor.BackColor = this._selectedForeColor;

            //As each day can only have a single background color,
            //we get this occasions back color from any occasion in the list for the day.
            //What exactly is this "Day" is determined by the occasion type.
            this._selectedBackColor = (from o in UserOccasionColection.FromSettings(this.JewishDate)
                                       where o.BackColor != Color.Empty
                                       select o.BackColor).FirstOrDefault();
            this.btnBGColor.BackColor     = this.txtName.BackColor = this._selectedBackColor;
            this.llClearBackColor.Visible = (this._selectedBackColor != Color.Empty);
            this.SetLabels();
            //Repaint the background
            this.Invalidate();
        }
        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();
        }
 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._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);
        }
 public void UpdateOccasions()
 {
     this.UserOccasions = UserOccasionColection.FromSettings(this.JewishDate);
 }