示例#1
0
        private void window_Loaded(object sender, RoutedEventArgs e)
        {
            doc = new XpsDocument("ch19.xps", FileAccess.ReadWrite);
            docViewer.Document = doc.GetFixedDocumentSequence();

            service = AnnotationService.GetService(docViewer);
            if (service == null)
            {
                Uri annotationUri = PackUriHelper.CreatePartUri(new Uri("AnnotationStream", UriKind.Relative));
                Package package = PackageStore.GetPackage(doc.Uri);
                PackagePart annotationPart = null;
                if (package.PartExists(annotationUri))
                {                    
                    annotationPart = package.GetPart(annotationUri);
                }
                else                
                {                    
                    annotationPart = package.CreatePart(annotationUri, "Annotations/Stream");
                }

                // Load annotations from the package.
                AnnotationStore store = new XmlStreamStore(annotationPart.GetStream());
                service = new AnnotationService(docViewer);
                service.Enable(store);
                
            }
        }
示例#2
0
 private void Window_Initialized(object sender, EventArgs e)
 {
     // Enables and Loads Annotations
     AnnotationService service = AnnotationService.GetService(reader);
     if (service == null)
     {
         stream = new FileStream("storage.xml", FileMode.OpenOrCreate);
         service = new AnnotationService(reader);
         AnnotationStore store = new XmlStreamStore(stream);
         store.AutoFlush = true;
         service.Enable(store);
     }
 }
示例#3
0
 protected void OnInitialized(object sender, EventArgs e)
 {
     // Включить и загрузить комментарии 
     AnnotationService service = AnnotationService.GetService(reader);
     if (service == null)
     {
         stream = new FileStream("storage.xml", FileMode.OpenOrCreate);
         service = new AnnotationService(reader);
         AnnotationStore store = new XmlStreamStore(stream);
         store.AutoFlush = true;
         service.Enable(store);
     }
 }
示例#4
0
 // ----------------------------- OnLoaded -----------------------------
 /// <summary>
 ///     Turns Annotations on.
 /// </summary>
 protected void OnLoaded(object sender, RoutedEventArgs e)
 {
     // Make sure that an AnnotationService isn�t already enabled.
     var service = AnnotationService.GetService(Viewer);
     if (service == null)
     {
         // (a) Create a Stream for the annotations to be stored in.
         _annotationStream =
             new FileStream("annotations.xml", FileMode.OpenOrCreate);
         // (b) Create an AnnotationService on our
         // FlowDocumentPageViewer.
         service = new AnnotationService(Viewer);
         // (c) Create an AnnotationStore and give it the stream we
         // created. (Autoflush == false)
         AnnotationStore store = new XmlStreamStore(_annotationStream);
         // (d) "Turn on annotations". Annotations will be persisted in
         // the stream created at (a).
         service.Enable(store);
     }
 } // end:OnLoaded
示例#5
0
        // ------------------------ AddCommandHandlers ------------------------
        private void AddCommandHandlers(FrameworkElement uiScope)
        {
            CommandManager.RegisterClassCommandBinding( typeof(ThumbViewer),
                new CommandBinding( ApplicationCommands.Open,
                            new ExecutedRoutedEventHandler(OnOpen),
                            new CanExecuteRoutedEventHandler(OnNewQuery) ) );

            // Add Command Handlers
            CommandBindingCollection commandBindings = uiScope.CommandBindings;

            commandBindings.Add(
                new CommandBinding( ThumbViewer.Exit,
                            new ExecutedRoutedEventHandler(OnExit),
                            new CanExecuteRoutedEventHandler(OnNewQuery) ) );

            commandBindings.Add(
                new CommandBinding( ThumbViewer.SaveAs,
                            new ExecutedRoutedEventHandler(OnSaveAs),
                            new CanExecuteRoutedEventHandler(OnNewQuery) ) );

            commandBindings.Add(
                new CommandBinding(ThumbViewer.AddBookmark,
                            new ExecutedRoutedEventHandler(OnAddBookmark),
                            new CanExecuteRoutedEventHandler(OnNewQuery) ) );

            commandBindings.Add(
                new CommandBinding(ThumbViewer.AddComment,
                            new ExecutedRoutedEventHandler(OnAddComment),
                            new CanExecuteRoutedEventHandler(OnNewQuery) ) );

            // Enable Annotations
            _annotationBuffer = new MemoryStream();
            _annStore = new XmlStreamStore(_annotationBuffer);
            _annServ  = new AnnotationService(FDPV);
            _annStore.StoreContentChanged +=
                new StoreContentChangedEventHandler(_annStore_StoreContentChanged);
            _annServ.Enable(_annStore);

        }// end:AddCommandHandlers()
        protected void window_Loaded(object sender, RoutedEventArgs e)
        {
            WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
            this.Resources["AuthorName"] = identity.Name;

            service = AnnotationService.GetService(docReader);

            if (service == null)
            {
                // Create a stream for the annotations to be stored in.
                //AnnotationStream =
                 // new FileStream("annotations.xml", FileMode.OpenOrCreate);
                annotationStream = new MemoryStream();

                // Create the on the document container. 
                service = new AnnotationService(docReader);
                
                // Create the AnnotationStore using the stream.
                AnnotationStore store = new XmlStreamStore(annotationStream);

                // Enable annotations.
                service.Enable(store);                
            }
        }
示例#7
0
        private void EnableAnnotations()
        {
            // Create the AnnotationService object that works
            // with our FlowDocumentReader.
            AnnotationService anoService = new AnnotationService(myDocumentReader);

            // Create a MemoryStream which will hold the annotations.
            MemoryStream anoStream = new MemoryStream();

            // Now, create a XML-based store based on the MemoryStream.
            // You could use this object to programmatically add, delete
            // or find annotations.
            AnnotationStore store = new XmlStreamStore(anoStream);

            // Enable the annotation services.
            anoService.Enable(store);
        }