コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Window1.xaml.cs プロジェクト: dandanyouxiang/wpf-1
        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);
        }
コード例 #3
0
 private void MainWindow_Closed(object sender, EventArgs e)
 {
     if (_service != null && _service.IsEnabled)
     {
         _service.Disable();
         _stream.Close();
     }
 }
コード例 #4
0
        protected void OnClosed(object sender, EventArgs e)
        {
            // Выключить и сохранить комментарии
            AnnotationService service = AnnotationService.GetService(reader);

            if (service != null && service.IsEnabled)
            {
                service.Disable();
                stream.Close();
            }
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
    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();
        }
    }
コード例 #7
0
        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();
            }
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        }// 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();
            }
        }
コード例 #10
0
        // ------------------------- 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);
        }