[英]Show a Powerpoint Presentation in a Frame in WPF
What I try to achieve is to show a PowerPoint Presentation directly without opening Powerpoint beforhand in a WPF Window. 我试图实现的是直接显示PowerPoint演示文稿,而无需在WPF窗口中打开Powerpoint。 Right now I'm using this code to start the Presentation:
现在我正在使用此代码启动演示文稿:
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE";
proc.StartInfo.Arguments = " /s " + source.ToString();
proc.Start();
with the variable source being the path to the desired file. 变量源是所需文件的路径。 This Code opens the PowerPoint Presentation in Fullscreen, which would be fine, but my Application is running on a Touch Device with no Keyboard or Mouse connected.
此代码以全屏模式打开PowerPoint演示文稿,这很好,但我的应用程序在没有连接键盘或鼠标的触摸设备上运行。 So I would like to be able to put a overlay above the presentation itself with a "Close"-Button for example.
所以我希望能够在演示文稿本身上方放置一个覆盖图,例如“Close”-Button。
I already found this topic Hosting external app in WPF window , but I'm having a hard time understanding what's actually going on there. 我已经在WPF窗口中找到了这个主题托管外部应用程序 ,但我很难理解实际上在那里发生了什么。
I hope someone can help me. 我希望有一个人可以帮助我。
Thanks in advance. 提前致谢。
I managed to do it in a way I'm comfortable with. 我设法以一种我很舒服的方式做到了。 Here is the Code:
这是代码:
XAML: 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">
The important part being: Background, Topmost and AllowTransparency 重要的部分是:Background,Topmost和AllowTransparency
Code Behind: 代码背后:
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.