Ejemplo n.º 1
0
        XpsPackagingPolicy(
            System.Windows.Xps.Packaging.XpsDocument xpsPackage,
            PackageInterleavingOrder interleavingType
            ) :
            base()
        {
            if (xpsPackage == null)
            {
                throw new ArgumentNullException("xpsPackage");
            }

            this._reachPackage = xpsPackage;
            Initialize();

            _interleavingPolicy = new XpsInterleavingPolicy(interleavingType, true);
            _interleavingPolicy.AddItem((INode)xpsPackage, 0, null);

            _fontAcquireMode = ResourceAcquireMode.NoneAcquired;
            _fontsCache      = new Hashtable(11);

            _fontResourceStream               = null;
            _imageResourceStream              = null;
            _colorContextResourceStream       = null;
            _resourceDictionaryResourceStream = null;

            InitializeResourceReferences();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new instance of the document viewer, open the xps document, and navigate to the
        /// designated page.
        /// </summary>
        private void ShowHelp()
        {
            xpsDocumentViewer = new XPSDocumentViewer();

            System.Windows.Xps.Packaging.XpsDocument xpsDoc = new System.Windows.Xps.Packaging.XpsDocument(_env.strAppDir + "\\Help\\" + _strXPSFile, System.IO.FileAccess.Read);
            xpsDocumentViewer.xpsViewer1.Document = xpsDoc.GetFixedDocumentSequence();
            xpsDocumentViewer.ReferenceHelp       = this;



            m_intCurrentPageNumber = PageNumber;
            System.Windows.Documents.DocumentPage oPage = xpsDocumentViewer.xpsViewer1.Document.DocumentPaginator.GetPage(PageNumber);

            xpsDocumentViewer.xpsViewer1.GoToPage(PageNumber);

            xpsDocumentViewer.WindowState           = WindowState.Normal;
            xpsDocumentViewer.Top                   = frmMain.g_oFrmMain.Top;
            xpsDocumentViewer.Height                = frmMain.g_oFrmMain.ClientSize.Height;
            xpsDocumentViewer.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            xpsDocumentViewer.IsEnabled             = true;
            xpsDocumentViewer.Visibility            = Visibility.Visible;

            m_oXpsDocument = xpsDoc;



            xpsDocumentViewer.ShowDialog();
        }
Ejemplo n.º 3
0
        public override void Load()
        {
            if (!this.Uri.IsFile)
                throw new NotImplementedException("Loading XPS document from remote URI not implemented yet.");

            Document = new Xps.XpsDocument(this.Uri.LocalPath, FileAccess.Read);
        }
Ejemplo n.º 4
0
        public HelpPage()
        {
            InitializeComponent();
            var doc = new System.Windows.Xps.Packaging.XpsDocument(Environment.CurrentDirectory + "\\X758Helps.xps", System.IO.FileAccess.Read);
            var xps = doc.GetFixedDocumentSequence();

            DocumentViewer1.Document = xps;
        }
Ejemplo n.º 5
0
        public override void Load()
        {
            if (!this.Uri.IsFile)
            {
                throw new NotImplementedException("Loading XPS document from remote URI not implemented yet.");
            }

            Document = new Xps.XpsDocument(this.Uri.LocalPath, FileAccess.Read);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Convert an XPS document to a Bitmap image
        /// </summary>
        /// <param name="xpsFileName">The path of the XPS document</param>
        /// <param name="bitmapFileName">The path of the bitmap image to create</param>
        static public void ToBitmap(string xpsFileName, string bitmapFileName)
        {
            // Create a new instance of the Xps documr
            System.Windows.Xps.Packaging.XpsDocument xpsDoc =
                new System.Windows.Xps.Packaging.XpsDocument(xpsFileName, System.IO.FileAccess.Read);
            FixedDocumentSequence docSeq = xpsDoc.GetFixedDocumentSequence();

            // Interate throught the total number of pages.
            for (int pageNum = 0; pageNum < docSeq.DocumentPaginator.PageCount; ++pageNum)
            {
                // Get the current document page.
                DocumentPage docPage = docSeq.DocumentPaginator.GetPage(pageNum);

                // Create a new bitmap image.
                BitmapImage bitmap = new BitmapImage();

                // Create a new bitmap render engine.
                RenderTargetBitmap renderTarget =
                    new RenderTargetBitmap((int)docPage.Size.Width,
                                           (int)docPage.Size.Height,
                                           96,  // WPF (Avalon) units are 96dpi based
                                           96,
                                           System.Windows.Media.PixelFormats.Default);

                // Render the current page to the image
                renderTarget.Render(docPage.Visual);

                // Encode the image as a bitmap
                BitmapEncoder encoder = new BmpBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(renderTarget));

                // Save the image to the file
                using (FileStream pageOutStream = new FileStream(bitmapFileName, FileMode.Create, FileAccess.Write))
                {
                    // Save the image to the image file.
                    encoder.Save(pageOutStream);
                    pageOutStream.Close();
                }
            }
        }
Ejemplo n.º 7
0
 XpsPackagingPolicy(
     System.Windows.Xps.Packaging.XpsDocument xpsPackage
     ) : this(xpsPackage, PackageInterleavingOrder.None)
 {
 }
Ejemplo n.º 8
0
 public int Read(string FileName)
 {
     System.Windows.Xps.Packaging.XpsDocument doc =
         new System.Windows.Xps.Packaging.XpsDocument(FileName, System.IO.FileAccess.Read);
     return(0);
 }