在 WPF 框架中显示 Powerpoint 演示文稿
Show a Powerpoint Presentation in a Frame in WPF
我试图实现的是直接显示 PowerPoint 演示文稿,而无需事先在 WPF 中打开 Powerpoint Window。
现在我正在使用此代码开始演示:
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 在演示文稿本身之上放置一个叠加层。
我已经找到这个主题了
Hosting external app in WPF window,但我很难理解那里到底发生了什么。
希望有人能帮助我。
提前致谢。
我设法以我喜欢的方式做到了。
这是代码:
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();
}
}
我试图实现的是直接显示 PowerPoint 演示文稿,而无需事先在 WPF 中打开 Powerpoint Window。 现在我正在使用此代码开始演示:
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 在演示文稿本身之上放置一个叠加层。
我已经找到这个主题了 Hosting external app in WPF window,但我很难理解那里到底发生了什么。
希望有人能帮助我。
提前致谢。
我设法以我喜欢的方式做到了。 这是代码:
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();
}
}