- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在为我的公司创建一个 VSTO,遇到了一个有趣的问题,我需要一些帮助。我会尽力解释这一点。我现在设置了 AddIn,以便在启动时通过 Application.AfterNewPresentation 事件创建 2 个 customTaskPanes。以及根据功能区上切换按钮的用户输入隐藏/显示这些内容的能力。
现在,当我启动名为“Presentation1”的第一个 PowerPoint 2010 时,一切正常,我可以显示/隐藏 TaskPanes,一切都按应有的方式插入。现在,我打开了第二个名为“Presentation2”的模板(以帮助在此处保持清晰)一切再次正常运行,我可以显示/隐藏 TaskPanes 并且一切正常插入。如果我回到“Presentation1”,插入内容和一切功能都很好,但是当我隐藏/显示 TaskPanes 时,它会在“Presentation2”上隐藏/显示它们。如果我创建一个“Presentation3”同样的事情会发生但“Presentation1”和“Presentation2”控制“Presentation3”TaskPanes。如果我关闭“Presentation2”和“Presentation3”,“Presentation1”按钮根本不会显示/隐藏任何内容。
ThisAddIn 中的代码
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Application.AfterNewPresentation += new PowerPoint.EApplication_AfterNewPresentationEventHandler(Application_AfterNewPresentation);
}
private void Application_AfterNewPresentation(PowerPoint.Presentation Pres)
{
PowerPoint.Application app = Pres.Application;
PowerPoint.DocumentWindow docWin = null;
foreach (PowerPoint.DocumentWindow win in Globals.ThisAddIn.Application.Windows)
{
if (win.Presentation.Name == app.ActivePresentation.Name)
{
docWin = win;
}
}
this.myWebForm = new SearchWebForm();
this.myWebFormTaskPane = this.CustomTaskPanes.Add(myWebForm, "Search ",docWin);
this.myWebFormTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
this.myWebFormTaskPane.Width = 345;
this.myWebFormTaskPane.VisibleChanged += new EventHandler(WebFormTaskPane_VisibleChanged);
}
private void WebFormTaskPane_VisibleChanged(object sender, System.EventArgs e)
{
Globals.Ribbons.Ribbon1.searchButton.Checked = myWebFormTaskPane.Visible;
if (Globals.Ribbons.Ribbon1.searchButton.Checked == true)
{
myWebForm.SearchForm_Navigate();
}
}
然后这是功能区
private void searchButton_Click(object sender, RibbonControlEventArgs e)
{
Globals.ThisAddIn.WebFormTaskPane.Visible = ((RibbonToggleButton)sender).Checked;
}
最佳答案
在 PowerPoint 2007 中,自定义 task panes are shared across all presentation windows .如果您想为每个演示文稿分配单独的任务 Pane ,您需要处理相应的事件(WindowActivate
、PresentationClose
等)。您还需要管理您创建的所有任务 Pane 的列表,以便您可以显示/隐藏适当的任务 Pane 。这实际上是一个 well-known Outlook pattern frequently referred to in VSTO-world as InspectorWrappers - 或者在您的情况下是 DocumentWindowWrapper。
这已针对 Powerpoint 2010 进行了更改,现在每个任务 Pane 都与特定窗口相关联。参见 this article .
您的错误是 Globals.ThisAddIn.WebFormTaskPane
不一定对应于当前的演示文稿任务 Pane - 您需要在托管列表中查找正确的任务 Pane (如上所述)。当您创建一个新任务 Pane (AfterNewPresentation
) 时,将其添加到您的 CustomTaskPane
收集并提供检索它的方法。
public partial class ThisAddIn
{
private Dictionary<PowerPoint.DocumentWindow, DocumentWindowWrapper> pptWrappersValue =
new Dictionary<PowerPoint.DocumentWindow, DocumentWindowWrapper>();
}
关于C# VSTO-Powerpoint-TaskPanes 在单独的窗口中。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9625466/
对于一个科学实验,我写了一个turtle.py ,它会打开一个 800x480 的窗口并绘制一个缓慢增长的黑点。 turtle.py以 C:\Users\kaza>python C:\Users\ka
我开发了一个 swing 应用程序,但每次运行应用程序时都会打开一个新窗口。我希望如果一个窗口已经打开,则其他窗口不允许打开。 最佳答案 Here是一个 Java 单一应用实例的例子: A singl
有没有办法检测主进程中 Electron 的结构? process.platform 似乎也在 x64 机器上返回 win32,我没有在文档中找到任何获取架构的选项。 最佳答案 你试过 process
public short[] HanningWindow(short[] signal_in ,int pos ,int size) { for (int i= pos; i < pos+si
我有一个具有这些属性的 Electron 窗口: mainWindow = new BrowserWindow({ width: 800, height: 600, title: "Aqu
我有一个 Ubuntu 工作站,我正在尝试引导一个 Windows 节点。 Windows 节点在端口 2222 上打开了 ssh。我一直在关注 http://docs.opscode.com/plu
我是一名优秀的程序员,十分优秀!