private IDictionary <Word.Window, CustomTaskPane> m_dicTaskPanes = new Dictionary <Word.Window, CustomTaskPane>(); //key = Word Window object; value = ctp (if any) for that window

        #region Startup/Shutdown

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            // start catching application-level events
            m_appEvents = new ApplicationEvents(Globals.Ribbons.RibbonMapping.toggleButtonMapping, m_dicTaskPanes);

            // perform initial registry setup
            try
            {
                if (Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Office\XML Mapping Task Pane") == null)
                {
                    Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Office\XML Mapping Task Pane", RegistryKeyPermissionCheck.ReadWriteSubTree);

                    using (RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Office\XML Mapping Task Pane", true))
                    {
                        rk.SetValue("Options", ControlTreeView.cOptionsShowAttributes + ControlTreeView.cOptionsAutoSelectNode);
                    }

                    //set up the schema library entries
                    int iLocale = int.Parse(Properties.Resources.Locale, CultureInfo.InvariantCulture);
                    SchemaLibrary.SetAlias("http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Properties.Resources.CoreFilePropertiesName, iLocale);
                    SchemaLibrary.SetAlias("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties", Properties.Resources.ExtendedFilePropertiesName, iLocale);
                    SchemaLibrary.SetAlias("http://schemas.microsoft.com/office/2006/coverPageProps", Properties.Resources.CoverPagePropertiesName, iLocale);
                }
            }
            catch (System.Security.SecurityException)
            {
            }
        }
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            log.Info("ThisAddIn_Startup");

            // start catching application-level events
            m_appEvents = new ApplicationEvents(
                //Globals.Ribbons.RibbonMapping, m_dicTaskPanes);
                Ribbon.ribbon, m_dicTaskPanes);

            // perform initial registry setup
            try
            {
                if (Registry.CurrentUser.OpenSubKey(System.Configuration.ConfigurationManager.AppSettings["Registry.CurrentUser.SubKey"]) == null)
                {
                    Registry.CurrentUser.CreateSubKey(System.Configuration.ConfigurationManager.AppSettings["Registry.CurrentUser.SubKey"], RegistryKeyPermissionCheck.ReadWriteSubTree);

                    using (RegistryKey rk = Registry.CurrentUser.OpenSubKey(System.Configuration.ConfigurationManager.AppSettings["Registry.CurrentUser.SubKey"], true))
                    {
                        string val = System.Configuration.ConfigurationManager.AppSettings["Ribbon.Button.XMLOptions.Value"];
                        if (String.IsNullOrWhiteSpace(val))
                        {
                            rk.SetValue("Options", ControlTreeView.cOptionsShowAttributes + ControlTreeView.cOptionsAutoSelectNode);
                        }
                        else
                        {
                            int intVal;
                            if (int.TryParse(val, out intVal))
                            {
                                rk.SetValue("Options", intVal);
                            }
                            else
                            {
                                rk.SetValue("Options", ControlTreeView.cOptionsShowAttributes + ControlTreeView.cOptionsAutoSelectNode);
                            }
                        }
                    }

                    //set up the schema library entries
                    int iLocale = int.Parse(Properties.Resources.Locale, CultureInfo.InvariantCulture);
                    SchemaLibrary.SetAlias("http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Properties.Resources.CoreFilePropertiesName, iLocale);
                    SchemaLibrary.SetAlias("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties", Properties.Resources.ExtendedFilePropertiesName, iLocale);
                    SchemaLibrary.SetAlias("http://schemas.microsoft.com/office/2006/coverPageProps", Properties.Resources.CoverPagePropertiesName, iLocale);
                }
            }
            catch (System.Security.SecurityException se)
            {
                log.Info(se);
            }
        }