Exemplo n.º 1
0
        private void Viewer_TextMarkupAnnotationCreating(DependencyObject d, PdfAnnotationCreatingEventArgs e)
        {
            if (e.Builder.AnnotationType == PdfAnnotationType.Text || e.Builder.AnnotationType == PdfAnnotationType.TextMarkup)
            {
                IPdfViewerMarkupAnnotationBuilder annotationBuilder = e.Builder.AsMarkupAnnotationBuilder();

                annotationBuilder.Author   = "John Smith";
                annotationBuilder.Contents = "Note";
                annotationBuilder.Color    = new PdfRGBColor(0.23, 0.48, 0.34);
            }
        }
Exemplo n.º 2
0
 private void pdfViewer1_TextMarkupAnnotationCreating(object sender, PdfAnnotationCreatingEventArgs e)
 {
     //Specify options for text markup and text annotations:
     if (e.Builder.AnnotationType == PdfAnnotationType.TextMarkup || e.Builder.AnnotationType == PdfAnnotationType.Text)
     {
         //Retrieve common options for text and text markup annotations:
         var annotationBuilder = e.Builder.AsMarkupAnnotationBuilder();
         annotationBuilder.Author   = "John Smith";
         annotationBuilder.Color    = new PdfRGBColor(0.20, 0.60, 1.00);
         annotationBuilder.Contents = "Note";
     }
 }
Exemplo n.º 3
0
        public void CreateMarkup(PdfAnnotationCreatingEventArgs e)
        {
            if (e.Builder.AnnotationType == PdfAnnotationType.TextMarkup)
            {
                IPdfViewerTextMarkupAnnotationBuilder annotationBuilder = e.Builder.AsTextMarkupAnnotationBuilder();

                if (String.IsNullOrWhiteSpace(annotationBuilder.SelectedText))
                {
                    e.Cancel  = true;
                    e.Handled = true;
                    return;
                }

                SearchResult[] result = AsyncHelper.RunSync(() => DictionaryManager.Search(annotationBuilder.SelectedText, InputCulture, OutputCulture));
                if (result == null || result.Length == 0)
                {
                    e.Cancel  = true;
                    e.Handled = true;
                    return;
                }

                annotationBuilder.Name     = String.Format("{0}-{1}", DictionaryBookmark.DictionaryEntry, annotationBuilder.Name);
                annotationBuilder.Author   = result[0].Word;
                annotationBuilder.Subject  = result[0].WordClass;
                annotationBuilder.Contents = result[0].Definition;

                DictionaryBookmarks.Add(new DictionaryBookmark
                {
                    PageNumber = annotationBuilder.PageNumber,
                    Name       = annotationBuilder.Name,
                    Word       = result[0].Word,
                    WordClass  = result[0].WordClass,
                    Definition = result[0].Definition
                });

                Cursor.Position = new System.Drawing.Point(Cursor.Position.X - 1, Cursor.Position.Y - 1);
            }
        }