您可以使用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文件的解析器和表示層時 –