Пример #1
0
        private CustomTaskPane GetTaskPane(TaskPaneSettings settings)
        {
            var result = default(CustomTaskPane);

            result = ctpFactory.CreateCTP(
                cTPAxID: progId,
                cTPTitle: settings.Title,
                cTPParentWindow: taskPaneWindow) as CustomTaskPane;

            try
            {
                result.Visible              = false;
                result.DockPosition         = settings.GetDockPosition();
                result.DockPositionRestrict = settings.GetDockRestriction();

                if (result.DockPosition != MsoCTPDockPosition.msoCTPDockPositionLeft &&
                    result.DockPosition != MsoCTPDockPosition.msoCTPDockPositionRight)
                {
                    result.Height = settings.Height;
                }

                if (result.DockPosition != MsoCTPDockPosition.msoCTPDockPositionBottom &&
                    result.DockPosition != MsoCTPDockPosition.msoCTPDockPositionTop)
                {
                    result.Width = settings.Width;
                }

                result.DockPositionStateChangeEvent += (t) => BaseProvider.OnTaskPaneChanged(t);
                result.VisibleStateChangeEvent      += (t) => BaseProvider.OnTaskPaneChanged(t);
            }
            catch
            { }

            return(result);
        }