Пример #1
0
        /// <summary>
        /// Edit a recurrence rule
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event parameters</param>
        private void btnEditRRule_Click(object sender, EventArgs e)
        {
            if (lbRRules.SelectedIndex == -1)
            {
                MessageBox.Show("Select a recurrence rule to edit");
                return;
            }

            using (RecurrencePropertiesDlg dlg = new RecurrencePropertiesDlg())
            {
                try
                {
                    Recurrence r = rRules[lbRRules.SelectedIndex].Recurrence;
                    dlg.SetRecurrence(r);

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        // Update the recurrence rule in the collection and the list box
                        dlg.GetRecurrence(r);
                        lbRRules.Items[lbRRules.SelectedIndex] = r.ToString();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Edit the recurrence pattern using the recurrence editor dialog box
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnDesign_Click(object sender, EventArgs e)
        {
            using (RecurrencePropertiesDlg dlg = new RecurrencePropertiesDlg())
            {
                try
                {
                    Recurrence r = new Recurrence(txtRRULE.Text)
                    {
                        StartDateTime = dtpStartDate.Value
                    };

                    dlg.SetRecurrence(r);

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        dlg.GetRecurrence(r);
                        txtRRULE.Text = r.ToString();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }