繁体   English   中英

在WPF中的帧中显示Powerpoint演示文稿

[英]Show a Powerpoint Presentation in a Frame in WPF

我试图实现的是直接显示PowerPoint演示文稿,而无需在WPF窗口中打开Powerpoint。 现在我正在使用此代码启动演示文稿:

    Process proc = new Process();
    proc.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE";
    proc.StartInfo.Arguments = " /s " + source.ToString();
    proc.Start();

变量源是所需文件的路径。 此代码以全屏模式打开PowerPoint演示文稿,这很好,但我的应用程序在没有连接键盘或鼠标的触摸设备上运行。 所以我希望能够在演示文稿本身上方放置一个覆盖图,例如“Close”-Button。

我已经在WPF窗口中找到了这个主题托管外部应用程序 ,但我很难理解实际上在那里发生了什么。

我希望有一个人可以帮助我。

提前致谢。

我设法以一种我很舒服的方式做到了。 这是代码:

XAML:

<Window x:Name="window" x:Class="Project.PowerPointViewer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Project"
        mc:Ignorable="d"
        Title="PowerPointViewer" Background="Transparent" Topmost="True" AllowsTransparency="True" ResizeMode="NoResize" WindowStyle="None" WindowState="Maximized">  

重要的部分是:Background,Topmost和AllowTransparency

代码背后:

public partial class PowerPointViewer : Window
{
    Process proc = new Process();
    Window main;
    public PowerPointViewer(Window main)
    {
        InitializeComponent();
        this.main = main;
    }

    public void open(string source)
    {
        proc.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE";
        proc.StartInfo.Arguments = " /s " + source;
        proc.Start();
        Show();
    }

    private void bt_close_Click(object sender, RoutedEventArgs e)
    {
        if (!proc.HasExited)
            proc.Kill();
        Close();
        main.Focus();
    }
}

暂无
暂无

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

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