这是创建“日志窗格”并将控件加载到其中的示例代码。它被定义为ThisAddin.cs
类的新属性,因此您可以通过以下方式调用它Global.ThisAddin.LogPane
private OfficeTools.CustomTaskPane _logPane;
public OfficeTools.CustomTaskPane LogPane
{
get
{
if(_logPane==null)
{
//my winforms component to load into the pane
var logViewerComp = new LogViewerComp();
_logPane = CustomTaskPanes.Add(logViewerComp, "Log Pane");
//makes the log component fill the all pane size
logViewerComp.Dock = DockStyle.Fill;
//sets the opening position of the pane into PPT view
_logPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionBottom;
//does something when the pane shows/hides
//in this case refreshes the Ribbon to enable/disable
//the toggle button status related to the pane
_logPane.VisibleChanged += (snd, ev) =>
{
Ribbon.Reload();
};
}
return _logPane;
}
}
注意:当您创建一个窗格时,它属于所有应用程序,并且在用户打开的所有演示文稿之间共享。