}// end:GetPackage() //<SnippetDocViewXmlStartStopAnnotat> //<SnippetDocViewXmlStartAnnotations> // ------------------------ StartAnnotations -------------------------- /// <summary> /// Enables annotations and displays all that are viewable.</summary> private void StartAnnotations() { // If there is no AnnotationService yet, create one. if (_annotService == null) { // docViewer is a document viewing control named in Window1.xaml. _annotService = new AnnotationService(docViewer); } // If the AnnotationService is currently enabled, disable it. if (_annotService.IsEnabled == true) { _annotService.Disable(); } // Open a stream to the file for storing annotations. _annotStream = new FileStream( _annotStorePath, FileMode.OpenOrCreate, FileAccess.ReadWrite); // Create an AnnotationStore using the file stream. _annotStore = new XmlStreamStore(_annotStream); // Enable the AnnotationService using the new store. _annotService.Enable(_annotStore); }// end:StartAnnotations()
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); } }
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() { var anoService = new AnnotationService(MyDocumentReader); var anoStream = new MemoryStream(); var store = new XmlStreamStore(anoStream); anoService.Enable(store); }
private void EnableAnnotations() { AnnotationService anoService = new AnnotationService(myDocumentReader); MemoryStream anoStream = new MemoryStream(); AnnotationStore store = new XmlStreamStore(anoStream); anoService.Enable(store); }
public void EnableAnnotations() { // Now, create a XML-based store based on the MemoryStream. // You could use this object to programmatically add, delete // or find annotations. _storeXML = new XmlStreamStore(_storeMemory); // Enable the annotation services. _anoService.Enable(_storeXML); }
private void EnableAnnotations() { //Create the AnnotationService object that works with our FlowDocumentReader. AnnotationService anoService = new AnnotationService(myDocumentReader); //Create a MemoryStream that will hld the annotations. MemoryStream anoStream = new MemoryStream(); //Now, create an 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); }
protected void OnInitialized(object sender, EventArgs e) { // Enable and load 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); 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 EnableAnnotations() { // Create the AnnotationService object for the FlowDocumentReader AnnotationService annoService = new AnnotationService(myDocumentReader); // Create the MemoryStream to hold the annotations MemoryStream annoMem = new MemoryStream(); // Create an XML based store interpreter into the MemoryStream // This object would be used to programmatically add, delete, or find annotations AnnotationStore store = new XmlStreamStore(annoMem); // Enable annotation with the XML store annoService.Enable(store); }
private void EnableAnnotations() { // 创建用于FlowDocumentReader的AnnotationService对象 AnnotationService anoService = new AnnotationService(myDocumentReader); // 创建用于存放批注的MemoryStream MemoryStream anoStream = new MemoryStream(); // 根据MemoryStream创建基于XML的存储 // 可以使用这个对象以编程的方式添加、删除或查找批注 AnnotationStore store = new XmlStreamStore(anoStream); // 启用批注服务 anoService.Enable(store); }
private void StartAnnotations() { var annotate = new AnnotationService(Viewer); if (annotate.IsEnabled) { annotate.Disable(); } var annotateStream = new FileStream("annots.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); AnnotationStore annotateStore = new XmlStreamStore(annotateStream); annotate.Enable(annotateStore); }
// ----------------------------- OnLoaded ----------------------------- /// <summary> /// Turns Annotations on.</summary> private void OnLoaded(object sender, RoutedEventArgs e) { // Make sure that an AnnotationService isn’t already enabled. AnnotationService 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))); //<SnippetDocSerEnableAnn> // Enable Annotations _annotationBuffer = new MemoryStream(); _annStore = new XmlStreamStore(_annotationBuffer); _annServ = new AnnotationService(FDPV); _annStore.StoreContentChanged += new StoreContentChangedEventHandler(_annStore_StoreContentChanged); _annServ.Enable(_annStore); //</SnippetDocSerEnableAnn> }// end:AddCommandHandlers()
private void WindowLoaded(object sender, RoutedEventArgs e) { service = AnnotationService.GetService(docReader); if (service == null) { annotationStream = new MemoryStream(); service = new AnnotationService(docReader); var store = new XmlStreamStore(annotationStream); service.Enable(store); } Observable.FromEventPattern <TextChangedEventHandler, TextChangedEventArgs>( handler => this.expressionTextBox.TextChanged += handler, handler => this.expressionTextBox.TextChanged -= handler) .Throttle(TimeSpan.FromMilliseconds(800)) .ObserveOnDispatcher() .Select(args => this.expressionTextBox.Text) .DistinctUntilChanged() .Where(text => !String.IsNullOrWhiteSpace(text)) .Subscribe(this.FindMatches); }
private void OnWindowLoaded(object sender, RoutedEventArgs e) { var identity = WindowsIdentity.GetCurrent(); 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 OnLoaded(object sender, RoutedEventArgs e) { _doc = new XpsDocument("ch19.xps", FileAccess.ReadWrite); DocViewer.Document = _doc.GetFixedDocumentSequence(); _service = AnnotationService.GetService(DocViewer); if (_service != null) { return; } var annotationUri = PackUriHelper.CreatePartUri(new Uri("AnnotationStream", UriKind.Relative)); var package = PackageStore.GetPackage(_doc.Uri); var annotationPart = package.PartExists(annotationUri) ? package.GetPart(annotationUri) : package.CreatePart(annotationUri, "Annotations/Stream"); // Load annotations from the package. if (annotationPart != null) { AnnotationStore store = new XmlStreamStore(annotationPart.GetStream()); _service = new AnnotationService(DocViewer); _service.Enable(store); } }