简体   繁体   English

Powerpoint 中的 VSTO C#:WindowSelectionChange 事件

[英]VSTO C# in Powerpoint: WindowSelectionChange Event

I am new to VSTO and C# and have a question regarding events.我是 VSTO 和 C# 的新手,并且对事件有疑问。 I'm trying to fire an event when the user selects something within PowerPoint (eg a shape, slide, etc).当用户在 PowerPoint 中选择某些内容(例如形状、幻灯片等)时,我试图触发一个事件。

I found a working solution for VBA in the Office documentation here and some more info for a Word selection handler here , however I'm clueless on how and where to add it in my ThisAddIn.cs context.我在此处的 Office 文档中找到了 VBA 的有效解决方案,并在此处找到了有关 Word 选择处理程序更多信息,但是我不知道如何以及在何处将其添加到我的ThisAddIn.cs上下文中。

I'm currently working from a fresh C# PowerPoint VSTO Addin我目前正在使用新的 C# PowerPoint VSTO Addin 空白 C# PowerPoint VSTO 插件

Any pointers into the right direction are highly welcome.任何指向正确方向的指针都非常受欢迎。 Thanks!谢谢!

Found this and it works:找到这个并且它有效:

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        this.Application.WindowSelectionChange += Application_WindowSelectionChange;

    }

    private void Application_WindowSelectionChange(PowerPoint.Selection Sel)
    {
        //throw new NotImplementedException();
        MessageBox.Show("Hello");
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM