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); } }
//<SnippetStartStopAnnotations> //<SnippetStartAnnotations> // ------------------------- 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); } }// end:StartAnnotations()
private void StartFixedDocumentAnnotations() { //If there is no AnnotationService yet, create one. if (fixedAnnotationService == null) { fixedAnnotationService = new AnnotationService(dvDocumentViewer); } //If the AnnotationService is currently enabled, disable it //as you'll need to re-enable it with a new store object. if (fixedAnnotationService.IsEnabled) { fixedAnnotationService.Disable(); } //Open a memory stream for storing annotations. fixedAnnotationBuffer = new MemoryStream(); //Create a new AnnotationStore using the above stream. fixedAnntationStore = new XmlStreamStore(fixedAnnotationBuffer); //Enable the AnnotationService using the new store object. fixedAnnotationService.Enable(fixedAnntationStore); }
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 StartFixedDocumentAnnotations() { //If there is no AnnotationService yet, create one. if (fixedAnnotationService == null) { fixedAnnotationService = new AnnotationService(dvViewer); } //If the AnnotationService is currently enabled, disable it //as you'll need to re-enable it with a new store object. if (fixedAnnotationService.IsEnabled) { fixedAnnotationService.Disable(); } //Open a stream to the file for storing annotations. fixedAnnotationBuffer = GetAnnotationPart(GetFixedDocumentSequenceUri()).GetStream(); //Create a new AnnotationStore using the file stream. fixedAnntationStore = new XmlStreamStore(fixedAnnotationBuffer); //Enable the AnnotationService using the new store object. fixedAnnotationService.Enable(fixedAnntationStore); }
private void EnableAnnotations() { AnnotationService anoService = new AnnotationService(myDocumentReader); MemoryStream anoStream = new MemoryStream(); AnnotationStore store = new XmlStreamStore(anoStream); anoService.Enable(store); }
private void EnableAnnotations() { var anoService = new AnnotationService(MyDocumentReader); var anoStream = new MemoryStream(); var 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 StartFlowDocumentAnnotations() { //Create a new annotation service for the fixed document viewer. flowAnnotationService = new AnnotationService(fdv); //Open a stream for our annotation store. flowAnnotationBuffer = new MemoryStream(); //Create an AnnotationStore using the stream. flowAnntationStore = new XmlStreamStore(flowAnnotationBuffer); //Enable the AnnotationService against the new annotation store. flowAnnotationService.Enable(flowAnntationStore); }
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); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { // Use permanent annotation storage _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()); }
// ----------------------------- 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()
public Window1() { InitializeComponent(); // Creates a FlowDocument from the XML files and assigns the FlowDocument to the proper FlowDocumentReader galaxiesFlowDocumentReader.Document = ConvertXmlToFlowDocument("Galaxies.xml"); carsFlowDocumentReader.Document = ConvertXmlToFlowDocument("Cars.xml"); // Initialize the AnnotationServices and point them to their respective FlowDocumentReaders greekAnnotService = new AnnotationService(greekFlowDocumentReader); galaxiesAnnotService = new AnnotationService(galaxiesFlowDocumentReader); carsAnnotService = new AnnotationService(carsFlowDocumentReader); // Enable the AnnotationServices and point them to their respective FileStreams greekAnnotService.Enable(new XmlStreamStore(greekFileStream)); galaxiesAnnotService.Enable(new XmlStreamStore(galaxiesFileStream)); carsAnnotService.Enable(new XmlStreamStore(carsFileStream)); // App starts off with the greek article, so set the currentFlowDocumentReader and currentAnnotService to reflect this. currentFlowDocumentReader = greekFlowDocumentReader; currentAnnotService = greekAnnotService; }
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); }
// ------------------------- OnStyleSelected -------------------------- /// <summary> /// Replaces the default StickyNote style when a new /// style is selected from the drop down combo box.</summary> private void OnStyleSelected(object sender, SelectionChangedEventArgs e) { // Extract the selected style. ComboBox source = (ComboBox)e.Source; StyleMetaData selectedStyle = (StyleMetaData)source.SelectedItem; Style newStyle = new Style(typeof(StickyNoteControl)); newStyle.BasedOn = selectedStyle.Value; // Replace the default StickyNote style with the one that was just selected. Type defaultKey = typeof(StickyNoteControl); if (Viewer.Resources.Contains(defaultKey)) { Viewer.Resources.Remove(defaultKey); } Viewer.Resources.Add(defaultKey, newStyle); // Re-load annotations so that they pickup new style. AnnotationService service = AnnotationService.GetService(Viewer); service.Disable(); service.Enable(service.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); } }
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); } }