您可以使用OLE(对象链接和嵌入)将PowerPoint作为WPF中的ActiveX控件托管。不幸的是,WPF不直接支持OLE,而是WinForms。您将不得不使用WindowsFormsHost
来放置一个WinForms控件,该控件将在您的WPF应用程序中执行OLE嵌入。
这一切都开始得到很复杂,很快,但它是可能。有一篇关于如何去做的微软文章here。您可能想将PowerPoint而不是Windows Media Player包装起来,但这个想法是一样的。这将要求最终用户安装了Power Point,并且很可能与应用程序编译的版本相同。
// Create the interop host control.
System.Windows.Forms.Integration.WindowsFormsHost host =
new System.Windows.Forms.Integration.WindowsFormsHost();
// Create the ActiveX control.
AxWMPLib.AxWindowsMediaPlayer axWmp = new AxWMPLib.AxWindowsMediaPlayer();
// Assign the ActiveX control as the host control's child.
host.Child = axWmp;
// Add the interop host control to the Grid
// control's collection of child controls.
this.grid1.Children.Add(host);
将自己存储在数据库中将是一件容易的事。
从here复制:
public static void databaseFilePut(string varFilePath) {
byte[] file;
using (var stream = new FileStream(varFilePath, FileMode.Open, FileAccess.Read)) {
using (var reader = new BinaryReader(stream)) {
file = reader.ReadBytes((int) stream.Length);
}
}
using (var varConnection = Locale.sqlConnectOneTime(Locale.sqlDataConnectionDetails))
using (var sqlWrite = new SqlCommand("INSERT INTO Raporty (RaportPlik) Values(@File)", varConnection)) {
sqlWrite.Parameters.Add("@File", SqlDbType.VarBinary, file.Length).Value = file;
sqlWrite.ExecuteNonQuery();
}
}
为什么一个数据库,而不是文件系统? –
你的实际问题是你如何编辑你实施的WPF应用程序中的PowerPoint文件?如果是这种情况,我认为没有办法做到这一点。只有当你自己实现PowerPoint文件的解析器和表示层时 –