C# - 连续显示 PowerPoint 演示文稿

发布于 2024-10-13 17:48:16 字数 2179 浏览 2 评论 0原文

我想连续循环播放一些 ppt 文件,但是当我在第一个文件播放到最后一张幻灯片后打开一个新文件时,会打开一个新的 PowerPoint 窗口并开始播放幻灯片。 我该如何解决这个问题?

        public Microsoft.Office.Interop.PowerPoint.SlideShowWindow startppt(string pptDatei)
    {
        WatchingLabel.Text = "Präsentation läuft...";
        started = true;
        ende = false;
        objPres = ppApp.Presentations.Open(pptDatei, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue);

        objPres.SlideShowSettings.ShowWithAnimation = Microsoft.Office.Core.MsoTriState.msoTrue;
        presWin = objPres.SlideShowSettings.Run();

        return presWin;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        WatchingLabel.Text = "Watching...";

        if (System.IO.Directory.Exists(ordner))
        {
            pptDatei.Clear();
            pptDatei.AddRange(System.IO.Directory.GetFiles(ordner, "*.ppt"));

            if (started == true && presWin.View.State == Microsoft.Office.Interop.PowerPoint.PpSlideShowState.ppSlideShowDone)
            {
                objPres.Close();
                ende = true;
                started = false;
            }

            if (pptDatei.Count > 0 && ende && started == false)
            {
                if (index < pptDatei.Count)
                {
                    startppt(pptDatei[index]);
                    index += 1;
                }
                else
                {
                    index = 0;
                }
            }
            else if (pptDatei.Count > 0 && ende == false && started == true)
            {
                presWin.View.Next();
            }

        }
    }

    public void ppApp_PresentationClose(Microsoft.Office.Interop.PowerPoint.Presentation Pres) 
    {
        pptDatei = new List<string>();
        started = false;
        ende = true;
        WatchingLabel.Text = "Präsentation beenden...";
    }

    public void ppApp_SlideShowEnd(Microsoft.Office.Interop.PowerPoint.Presentation Pres) 
    {
        ende = true;
        started = false;
    }

I want to play some ppt files in a continuous loop, but when I open a new File after the first has reached its last slide, a new PowerPoint window opens and starts the Slide.
How can I solve that problem?

        public Microsoft.Office.Interop.PowerPoint.SlideShowWindow startppt(string pptDatei)
    {
        WatchingLabel.Text = "Präsentation läuft...";
        started = true;
        ende = false;
        objPres = ppApp.Presentations.Open(pptDatei, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue);

        objPres.SlideShowSettings.ShowWithAnimation = Microsoft.Office.Core.MsoTriState.msoTrue;
        presWin = objPres.SlideShowSettings.Run();

        return presWin;
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        WatchingLabel.Text = "Watching...";

        if (System.IO.Directory.Exists(ordner))
        {
            pptDatei.Clear();
            pptDatei.AddRange(System.IO.Directory.GetFiles(ordner, "*.ppt"));

            if (started == true && presWin.View.State == Microsoft.Office.Interop.PowerPoint.PpSlideShowState.ppSlideShowDone)
            {
                objPres.Close();
                ende = true;
                started = false;
            }

            if (pptDatei.Count > 0 && ende && started == false)
            {
                if (index < pptDatei.Count)
                {
                    startppt(pptDatei[index]);
                    index += 1;
                }
                else
                {
                    index = 0;
                }
            }
            else if (pptDatei.Count > 0 && ende == false && started == true)
            {
                presWin.View.Next();
            }

        }
    }

    public void ppApp_PresentationClose(Microsoft.Office.Interop.PowerPoint.Presentation Pres) 
    {
        pptDatei = new List<string>();
        started = false;
        ende = true;
        WatchingLabel.Text = "Präsentation beenden...";
    }

    public void ppApp_SlideShowEnd(Microsoft.Office.Interop.PowerPoint.Presentation Pres) 
    {
        ende = true;
        started = false;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

意犹 2024-10-20 17:48:16

遗憾的是,不能,您无法对多个 PowerPoint 文件执行此操作。在 PowerPoint 2010 之前,您不能同时运行多个 PPT(即使使用 PP2010,这样做也很奇怪)。因此,通过关闭一个窗口并打开一个新窗口来运行,您将失去主运行窗口。

您可以创建多个 PowerPoint 实例,将它们设置为可见/隐藏,然后当一张幻灯片结束时,以编程方式取消隐藏下一张幻灯片并将其显示以运行,但这会遇到与您已经遇到的相同的闪烁问题。

您能做的最好的事情就是读取目录中的所有 ppt,按照您需要的顺序将它们全部合并到一个新的幻灯片中(并指定布局等),然后在信息亭循环中运行该单个幻灯片。

Unfortunately, no, you can't do this with multiple PowerPoint files. Prior to PowerPoint 2010, you cannot have more than one PPT running at the same time (and even with PP2010 it's wonky to do so). So by shutting one down and opening a new one to run, you lose the main run window.

You could create multiple PowerPoint instance, set them as visible/hidden and then when one slideshow ends, programmatically unhide the next one and display it to run, but that would suffer from the same flicker issue as you already have.

The best you can do is read all the ppts in the directory, merge them all into a new deck in the order you need (and specifying layouts, etc.) and then run that single deck in a kiosk-loop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文