2017-02-15 85 views
1

我试图实现的是直接在WPF窗口中打开PowerPoint演示文稿而无需打开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”按钮在演示文稿上方放置叠加层。

我已经找到这个话题 Hosting external app in WPF window,但我很难理解实际发生了什么。

我希望有人能帮助我。

在此先感谢。

+0

这可能帮助:HTTP:// stackoverflow.com/questions/32094792/convert-selected-powerpoint-shapes-or-drawingml-to-xaml – Ron

回答

0

我设法以我熟悉的方式做到这一点。 这里是代码:

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"> 

最重要的部分是:背景,最上和最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(); 
    } 
} 
相关问题