From 2be99c0798dfb0063ddc9cf42c92d4d3693c66cf Mon Sep 17 00:00:00 2001 From: gamosoft_cp Date: Fri, 29 Mar 2013 23:31:49 +0000 Subject: [PATCH] Fixed storing the VISIBLE property when closing Outlook --- Outlook2013TodoAddIn/AppointmentsControl.cs | 17 +-------------- .../Properties/AssemblyInfo.cs | 4 ++-- Outlook2013TodoAddIn/ThisAddIn.cs | 21 +++++++++++++------ 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Outlook2013TodoAddIn/AppointmentsControl.cs b/Outlook2013TodoAddIn/AppointmentsControl.cs index 5605a47..1cbcf84 100644 --- a/Outlook2013TodoAddIn/AppointmentsControl.cs +++ b/Outlook2013TodoAddIn/AppointmentsControl.cs @@ -42,23 +42,8 @@ namespace Outlook2013TodoAddIn public AppointmentsControl() { InitializeComponent(); - - //(this.apptCalendar as Control).SetStyle(); - //(this.apptCalendar as Control).DoubleClick += AppointmentsControl_DoubleClick; - // ShowScrollBar(this.listView1.Handle.ToInt64(), SB_HORZ, 0); } - //[DllImport("user32")] - //private static extern long ShowScrollBar(long hwnd, long wBar, long bShow); - //long SB_HORZ = 0; - //long SB_VERT = 1; - //long SB_BOTH = 3; - - //void AppointmentsControl_DoubleClick(object sender, EventArgs e) - //{ - // MessageBox.Show("Test"); - //} - /// /// Respond to calendar changes /// @@ -309,7 +294,7 @@ namespace Outlook2013TodoAddIn /// EventArgs private void apptCalendar_DoubleClickEx(object sender, EventArgs e) { - // TODO: Clicking in days outside of the current month will cause the calendar to refresh to that day + // Clicking in days outside of the current month will cause the calendar to refresh to that day // reposition all days and select the wrong one Outlook.Folder f = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder; Globals.ThisAddIn.Application.ActiveExplorer().CurrentFolder = f; diff --git a/Outlook2013TodoAddIn/Properties/AssemblyInfo.cs b/Outlook2013TodoAddIn/Properties/AssemblyInfo.cs index 0773445..a04c69f 100644 --- a/Outlook2013TodoAddIn/Properties/AssemblyInfo.cs +++ b/Outlook2013TodoAddIn/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Outlook2013TodoAddIn")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("Outlook 2013 Todo Add-In")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Outlook2013TodoAddIn")] -[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyCopyright("Copyright ©Gamosoft 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Outlook2013TodoAddIn/ThisAddIn.cs b/Outlook2013TodoAddIn/ThisAddIn.cs index 7d0e29d..1f1e098 100644 --- a/Outlook2013TodoAddIn/ThisAddIn.cs +++ b/Outlook2013TodoAddIn/ThisAddIn.cs @@ -40,14 +40,16 @@ namespace Outlook2013TodoAddIn this.AppControl.RetrieveAppointments(); ToDoTaskPane = this.CustomTaskPanes.Add(this.AppControl, "Appointments"); - // TODO: Fix this - // ToDoTaskPane.Visible = Properties.Settings.Default.Visible; - ToDoTaskPane.Visible = true; + ToDoTaskPane.Visible = Properties.Settings.Default.Visible; ToDoTaskPane.Width = Properties.Settings.Default.Width; ToDoTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight; ToDoTaskPane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal; ToDoTaskPane.VisibleChanged += ToDoTaskPane_VisibleChanged; this.AppControl.SizeChanged += appControl_SizeChanged; + + Globals.ThisAddIn.Application.ActiveExplorer().Deactivate += ThisAddIn_Deactivate; + + // TODO: Make sure there are no memory leaks (dispose COM objects) } /// @@ -67,7 +69,7 @@ namespace Outlook2013TodoAddIn /// EventArgs private void ToDoTaskPane_VisibleChanged(object sender, EventArgs e) { - // TODO: Save visibility ONLY when not closing the form + // Can't save visibility here because this fires when closing Outlook, and by that time the pane is ALWAYS not visible // Properties.Settings.Default.Visible = ToDoTaskPane.Visible; TodoRibbonAddIn rbn = Globals.Ribbons.FirstOrDefault(r => r is TodoRibbonAddIn) as TodoRibbonAddIn; if (rbn != null) @@ -76,6 +78,14 @@ namespace Outlook2013TodoAddIn } } + /// + /// This is the alternative to capture the visibility of the pane when shutting down Outlook + /// + private void ThisAddIn_Deactivate() + { + Properties.Settings.Default.Visible = ToDoTaskPane.Visible; + } + /// /// This is not executed by default /// http://msdn.microsoft.com/en-us/library/office/ee720183.aspx#OL2010AdditionalShutdownChanges_AddinShutdownChangesinOL2010Beta @@ -97,8 +107,7 @@ namespace Outlook2013TodoAddIn /// private void AddRegistryNotification() { - // TODO: Make sure there are no memory leaks (dispose COM obejcts) - // TODO: See if this works the first time (if the entry is not there when Outlook loads, it will NOT notify the add-in) + // If the entry is not there when Outlook loads, it will NOT notify the add-in, so the first time won't save the results string subKey = @"Software\Microsoft\Office\Outlook\Addins\Outlook2013TodoAddIn"; RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(subKey, true); if (rk == null)