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 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); }
private void MainWindow_Closed(object sender, EventArgs e) { if (_service != null && _service.IsEnabled) { _service.Disable(); _stream.Close(); } }
protected void OnClosed(object sender, EventArgs e) { // Выключить и сохранить комментарии AnnotationService service = AnnotationService.GetService(reader); if (service != null && service.IsEnabled) { service.Disable(); stream.Close(); } }
protected void window_Unloaded(object sender, RoutedEventArgs e) { if (service != null && service.IsEnabled) { // Flush annotations to stream. service.Store.Flush(); // Disable annotations. service.Disable(); annotationStream.Close(); } }
protected void OnClosed(object sender, EventArgs e) { // Disable and save annotations AnnotationService service = AnnotationService.GetService(reader); if (service != null && service.IsEnabled) { service.Store.Flush(); service.Disable(); stream.Close(); } }
private void OnWindowUnloaded(object sender, RoutedEventArgs e) { if (_service != null && _service.IsEnabled) { // Flush annotations to stream. _service.Store.Flush(); // Disable annotations. _service.Disable(); _annotationStream.Close(); } }
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); }
}// end:OnLoaded // ---------------------------- OnUnLoaded ---------------------------- /// <summary> /// Turns Annotations off.</summary> private void OnUnloaded(object sender, RoutedEventArgs e) { // (a) Check that an AnnotationService // actually existed and was Enabled. AnnotationService service = AnnotationService.GetService(Viewer); if (service != null && service.IsEnabled) { // (b) Flush changes to annotations to our stream. service.Store.Flush(); // (c) Turn off annotations. service.Disable(); // (d) Close our stream. AnnotationStream.Close(); } }
// ------------------------- 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); }