2017-02-15 78 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(); 
    } 
} 
相關問題