Ejemplo n.º 1
0
        // 我们让公共方法具有此行为,以便
        // 能够独立于 NewInspector 事件调用该行为。
        // 目的是为了允许争用条件,
        // 在此条件下可以在挂钩 NewInspector 事件之前进行
        // 功能区回调。
        public Office.Core.CustomTaskPane CreateTaskPane(
            Outlook.Inspector inspector)
        {
            Office.Core.CustomTaskPane taskpane = null;

            try
            {
                // 创建一个新的任务窗格,并将其宽度设置为与
                // SimpleControl 宽度匹配。
                taskpane = _taskPaneConnector.CreateTaskPane(
                    _controlProgId, _controlTitle, inspector);
                if (taskpane != null)
                {
                    taskpane.Width = 230;

                    // 将任务窗格映射到检查器,并将其缓存
                    // 在集合中。
                    _uiElements.Add(new UserInterfaceContainer(
                                        inspector, taskpane, _ribbonConnector));
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            return(taskpane);
        }
        // We factor this behavior out to a public method, so that
        // it can be called independently of the NewInspector event.
        // This is to allow for the race condition where ribbon
        // callbacks can come in before the NewInspector event is
        // hooked up.
        public Office.Core.CustomTaskPane CreateTaskPane(
            Outlook.Inspector inspector)
        {
            Office.Core.CustomTaskPane taskpane = null;

            try
            {
                // Create a new task pane, and set its width to match our
                // SimpleControl width.
                taskpane = _taskPaneConnector.CreateTaskPane(
                    _controlProgId, _controlTitle, inspector);
                if (taskpane != null)
                {
                    taskpane.Width = 230;

                    // Map the task pane to the inspector and cache it
                    // in our collection.
                    _uiElements.Add(new UserInterfaceContainer(
                                        inspector, taskpane, _ribbonConnector));
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }

            return(taskpane);
        }