diff --git a/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs b/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs index 981e335..89a283b 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.Designer.cs @@ -41,6 +41,7 @@ this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.panelCalendar = new System.Windows.Forms.Panel(); this.apptCalendar = new Outlook2013TodoAddIn.CustomCalendar(); + this.mnuItemDeleteAppointment = new System.Windows.Forms.ToolStripMenuItem(); this.ctxMenuAppointments.SuspendLayout(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -53,14 +54,15 @@ // ctxMenuAppointments // this.ctxMenuAppointments.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuItemReplyAllEmail}); + this.mnuItemReplyAllEmail, + this.mnuItemDeleteAppointment}); this.ctxMenuAppointments.Name = "ctxMenuAppointments"; - this.ctxMenuAppointments.Size = new System.Drawing.Size(214, 28); + this.ctxMenuAppointments.Size = new System.Drawing.Size(225, 80); // // mnuItemReplyAllEmail // this.mnuItemReplyAllEmail.Name = "mnuItemReplyAllEmail"; - this.mnuItemReplyAllEmail.Size = new System.Drawing.Size(213, 24); + this.mnuItemReplyAllEmail.Size = new System.Drawing.Size(224, 24); this.mnuItemReplyAllEmail.Text = "Reply All With Email"; this.mnuItemReplyAllEmail.Click += new System.EventHandler(this.mnuItemReplyAllEmail_Click); // @@ -181,6 +183,7 @@ this.apptCalendar.SelectedBackColor = System.Drawing.Color.LightBlue; this.apptCalendar.SelectedDate = new System.DateTime(2013, 5, 2, 0, 0, 0, 0); this.apptCalendar.SelectedForeColor = System.Drawing.Color.Blue; + this.apptCalendar.ShowWeekNumbers = false; this.apptCalendar.Size = new System.Drawing.Size(258, 230); this.apptCalendar.TabIndex = 1; this.apptCalendar.TodayBackColor = System.Drawing.Color.Blue; @@ -189,6 +192,13 @@ this.apptCalendar.SelectedDateChanged += new System.EventHandler(this.apptCalendar_SelectedDateChanged); this.apptCalendar.ConfigurationButtonClicked += new System.EventHandler(this.apptCalendar_ConfigurationButtonClicked); // + // mnuItemDeleteAppointment + // + this.mnuItemDeleteAppointment.Name = "mnuItemDeleteAppointment"; + this.mnuItemDeleteAppointment.Size = new System.Drawing.Size(224, 24); + this.mnuItemDeleteAppointment.Text = "Delete appointment/s"; + this.mnuItemDeleteAppointment.Click += new System.EventHandler(this.mnuItemDeleteAppointment_Click); + // // AppointmentsControl // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -221,6 +231,7 @@ private System.Windows.Forms.ColumnHeader columnHeader4; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.Panel panelCalendar; + private System.Windows.Forms.ToolStripMenuItem mnuItemDeleteAppointment; } diff --git a/Outlook2013TodoAddIn/AppointmentsControl.cs b/Outlook2013TodoAddIn/AppointmentsControl.cs index cd8f14d..fb84754 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.cs @@ -400,6 +400,8 @@ namespace Outlook2013TodoAddIn if (appt.IsRecurring) { FormRecurringOpen f = new FormRecurringOpen(); + f.Title = "Open Recurring Item"; + f.Message = "This is one appointment in a series. What do you want to open?"; if (f.ShowDialog() == DialogResult.OK) { if (f.OpenRecurring) @@ -457,6 +459,49 @@ namespace Outlook2013TodoAddIn } } + /// + /// Allows to delete the selected appointment (whether it's a recurring one or not) + /// + /// Sender + /// EventArgs + private void mnuItemDeleteAppointment_Click(object sender, EventArgs e) + { + if (this.lstAppointments.SelectedIndices.Count != 0) + { + Outlook.AppointmentItem appt = this.lstAppointments.SelectedItems[0].Tag as Outlook.AppointmentItem; + if (appt != null) + { + if (appt.IsRecurring) + { + FormRecurringOpen f = new FormRecurringOpen(); + f.Title = "Warning: Delete Recurring Item"; + f.Message = "This is one appointment in a series. What do you want to delete?"; + if (f.ShowDialog() == DialogResult.OK) + { + if (f.OpenRecurring) + { + Outlook.AppointmentItem masterAppt = appt.Parent; // Get the master appointment item + masterAppt.Delete(); // Will delete ALL instances + } + else + { + appt.Delete(); // Delete just this instance + } + } + } + else + { + if (MessageBox.Show("Are you sure you want to delete this appointment?", "Delete appointment", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + appt.Delete(); // Delete just this instance + } + } + // At the end, synchronously "refresh" appointments in case they have changed + this.RetrieveAppointments(); + } + } + } + /// /// Switch to the calendar view when double-clicking a date /// diff --git a/Outlook2013TodoAddIn/Forms/FormRecurringOpen.Designer.cs b/Outlook2013TodoAddIn/Forms/FormRecurringOpen.Designer.cs index db3893d..433c72d 100644 --- a/Outlook2013TodoAddIn/Forms/FormRecurringOpen.Designer.cs +++ b/Outlook2013TodoAddIn/Forms/FormRecurringOpen.Designer.cs @@ -106,6 +106,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Open Recurring Item"; + this.Load += new System.EventHandler(this.FormRecurringOpen_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Outlook2013TodoAddIn/Forms/FormRecurringOpen.cs b/Outlook2013TodoAddIn/Forms/FormRecurringOpen.cs index 707f61a..27cb54e 100644 --- a/Outlook2013TodoAddIn/Forms/FormRecurringOpen.cs +++ b/Outlook2013TodoAddIn/Forms/FormRecurringOpen.cs @@ -17,18 +17,40 @@ namespace Outlook2013TodoAddIn.Forms get { return this.rbtnAll.Checked; } } + /// + /// To reuse the form, gets/sets the title + /// + public string Title { get; set; } + + + /// + /// To reuse the form, gets/sets the message + /// + public string Message { get; set; } + #endregion "Properties" #region "Methods" /// - /// Open the form + /// Load the form /// public FormRecurringOpen() { InitializeComponent(); } - + + /// + /// Load the form + /// + /// Sender + /// EventArgs + private void FormRecurringOpen_Load(object sender, System.EventArgs e) + { + this.Text = this.Title; + this.textBox1.Text = this.Message; + } + #endregion "Methods" } } \ No newline at end of file