本文整理汇总了C#中System.IO.Packaging.PackageStore.GetPackage方法的典型用法代码示例。如果您正苦于以下问题:C# PackageStore.GetPackage方法的具体用法?C# PackageStore.GetPackage怎么用?C# PackageStore.GetPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了PackageStore.GetPackage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenDocument
// --------------------------- OpenDocument ---------------------------
/// <summary>
/// Loads and displays a given XPS document file.</summary>
/// <param name="filename">
/// The path and file name of the XPS
/// document to load and display.</param>
/// <returns>
/// true if the document loads successfully; otherwise false.</returns>
public bool OpenDocument(string xpsFile)
{
// Check to see if the document is encrypted.
// If encrypted, use OpenEncryptedDocument().
if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(xpsFile))
return OpenEncryptedDocument(xpsFile);
// Document is not encrypted, open normally.
ShowStatus("Opening '" + Filename(xpsFile) + "'");
_packageUri = new Uri(xpsFile, UriKind.Absolute);
try
{
_xpsDocument = new XpsDocument(xpsFile, FileAccess.Read);
}
catch (System.IO.FileFormatException ex)
{
MessageBox.Show(xpsFile + "\n\nThe file " +
"is not a valid XPS document.\n\n" +
"Exception: " + ex.Message + "\n\n" +
ex.GetType().ToString() + "\n\n" + ex.StackTrace,
"Invalid File Format",
MessageBoxButton.OK, MessageBoxImage.Error);
return false;
}
// Get the document's PackageStore into which
// new user annotations will be added and saved.
_xpsPackage = PackageStore.GetPackage(_packageUri);
if ((_xpsPackage == null) || (_xpsDocument == null))
{
MessageBox.Show("Unable to get Package from file.");
return false;
}
// Get the FixedDocumentSequence from the open document.
FixedDocumentSequence fds = _xpsDocument.GetFixedDocumentSequence();
if (fds == null)
{
MessageBox.Show(xpsFile + "\n\nThe document package within " +
"the specified file does not contain a " +
"FixedDocumentSequence.", "Package Error");
return false;
}
// Load the FixedDocumentSequence to the DocumentViewer control.
DocViewer.Document = fds;
// Enable document menu controls.
menuFileClose.IsEnabled = true;
menuFilePrint.IsEnabled = true;
menuViewIncreaseZoom.IsEnabled = true;
menuViewDecreaseZoom.IsEnabled = true;
// Give the DocumentViewer focus.
docViewer.Focus();
this.Title = "RightsManagedPackageViewer SDK Sample - " +
Filename(xpsFile);
return true;
}// end:OpenDocument()