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); } }
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); } }
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); } }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { // Load annotations store _stream = new FileStream("storage.xml", FileMode.OpenOrCreate); _service = new AnnotationService(flowDocumentReader); _store = new XmlStreamStore(_stream) {AutoFlush = true}; _service.Enable(_store); // Detect when annotations are added or deleted _service.Store.StoreContentChanged += AnnotationStore_StoreContentChanged; // Bind to annotations in store BindToAnnotations(_store.GetAnnotations()); }
void Window1_Loaded(object sender, RoutedEventArgs e) { //throw new NotImplementedException(); XpsDocument xd = new XpsDocument("annotation.xps", System.IO.FileAccess.ReadWrite); dv.Document = xd.GetFixedDocumentSequence(); ans = new AnnotationService(dv); fs= new FileStream( "annotation.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite); ans.Enable(new XmlStreamStore(fs)); ans.Store.AutoFlush = true; }
// ----------------------------- 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
// ------------------------ 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); } }
private void EnableAnnotations() { AnnotationService anoService = new AnnotationService(myDocumentReader); using (MemoryStream anoStream = new MemoryStream()) { anoService.Enable(new XmlStreamStore(anoStream)); } }
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); }
// ------------------------- StartAnnotations ------------------------- /// <summary> /// Enables annotations processing and /// displays viewable annotations.</summary> /// <remarks> /// SetSource must be called first before /// calling StartAnnotations().</remarks> public void StartAnnotations() { if (_docViewer == null) throw new InvalidOperationException( "Required DocumentViewer control has not been specified."); if ((_packageUri == null) || (_rootUri == null)) throw new InvalidOperationException( "Required SetSource() has not been called."); // If there is no AnnotationService yet, create one. if (_annotService == null) { // Get the annotations data stream from the XPS container. _annotStream = GetAnnotationPart(_rootUri).GetStream(); // Create the AnnotationService. _annotService = new AnnotationService(_docViewer); // Enable the service with the annotation data stream. _annotService.Enable(new XmlStreamStore(_annotStream)); } // Else if the annotationService exists but is not enabled, enable it. else if (!_annotService.IsEnabled) _annotService.Enable(_annotService.Store); }