Fixed storing the VISIBLE property when closing Outlook
This commit is contained in:
		
							parent
							
								
									4475ef3b10
								
							
						
					
					
						commit
						2be99c0798
					
				@ -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");
 | 
			
		||||
        //}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Respond to calendar changes
 | 
			
		||||
        /// </summary>
 | 
			
		||||
@ -309,7 +294,7 @@ namespace Outlook2013TodoAddIn
 | 
			
		||||
        /// <param name="e">EventArgs</param>
 | 
			
		||||
        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;
 | 
			
		||||
 | 
			
		||||
@ -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("")]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
@ -67,7 +69,7 @@ namespace Outlook2013TodoAddIn
 | 
			
		||||
        /// <param name="e">EventArgs</param>
 | 
			
		||||
        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
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// This is the alternative to capture the visibility of the pane when shutting down Outlook
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        private void ThisAddIn_Deactivate()
 | 
			
		||||
        {
 | 
			
		||||
            Properties.Settings.Default.Visible = ToDoTaskPane.Visible;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// This is not executed by default
 | 
			
		||||
        /// http://msdn.microsoft.com/en-us/library/office/ee720183.aspx#OL2010AdditionalShutdownChanges_AddinShutdownChangesinOL2010Beta
 | 
			
		||||
@ -97,8 +107,7 @@ namespace Outlook2013TodoAddIn
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user