Класс WpfCommentVisualTool
Представляет визуальный инструмент, позволяющий комментировать изображения в просмотрщике изображений WPF.
Вот C#/VB.NET код, который демонстрирует, как инициализировать просмотрщик изображений WPF для отображения комментариев аннотаций.
''' <summary>
''' Initializes WPF image viewer for displaying PDF annotation comments.
''' </summary>
''' <param name="imageViewer">WPF image viewer, which must be initialized for displaying PDF annotation comments.</param>
Public Shared Sub InitViewerToDisplayPdfAnnotationComments(imageViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer)
' create new PDF annotation comment controller
Dim annotationCommentController As New Vintasoft.Imaging.Annotation.Comments.Pdf.ImageCollectionPdfAnnotationCommentController()
' create the comment visual tool, which is associated with PDF annotation comment controller
Dim commentVisualTool As Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool = CreateCommentTool(annotationCommentController)
' specify that comment visual tool must be used in WPF image viewer
imageViewer.VisualTool = New Vintasoft.Imaging.Wpf.UI.VisualTools.WpfCompositeVisualTool(commentVisualTool, imageViewer.VisualTool)
End Sub
''' <summary>
''' Initializes WPF annotation viewer for displaying Vintasoft annotation comments.
''' </summary>
''' <param name="annotationViewer">WPF annotation viewer, which must be initialized for displaying Vintasoft annotation comments.</param>
Public Shared Sub InitViewerToDisplayVintasoftAnnotationComments(annotationViewer As Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationViewer)
' create the annotation comment controller, which is associated with annotation data controller
Dim annotationCommentController As New Vintasoft.Imaging.Annotation.Comments.AnnotationCommentController(annotationViewer.AnnotationDataController)
' create the comment visual tool, which is associated with annotation comment controller
Dim commentVisualTool As Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool = CreateCommentTool(annotationCommentController)
' specify that comment visual tool must be used in WinForms annotation viewer
annotationViewer.VisualTool = New Vintasoft.Imaging.Wpf.UI.VisualTools.WpfCompositeVisualTool(commentVisualTool, annotationViewer.VisualTool)
End Sub
''' <summary>
''' Creates the comment visual tool using the specified comment controller.
''' </summary>
''' <param name="imageCollectionCommentController">The image collection comment controller.</param>
''' <returns>The comment visual tool.</returns>
Public Shared Function CreateCommentTool(imageCollectionCommentController As Vintasoft.Imaging.Annotation.Comments.ImageCollectionCommentController) As Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool
' create the comment controller for WPF image viewer
Dim commentController As New Vintasoft.Imaging.Annotation.Wpf.UI.Comments.WpfImageViewerCommentController(imageCollectionCommentController)
' create the comment visual tool, which uses the CommentControlFactory class for creating the comment controls
Return New Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool(commentController, New CommentControlFactory())
End Function
''' <summary>
''' Represents a factory that allows to create comment controls.
''' </summary>
Public Class CommentControlFactory
Implements Vintasoft.Imaging.Annotation.UI.Comments.ICommentControlFactory
''' <summary>
''' Creates the comment control that displays specified comment.
''' </summary>
''' <param name="comment">The comment.</param>
''' <returns>Comment control that displays specified comment.</returns>
Public Function Create(comment As Vintasoft.Imaging.Annotation.Comments.Comment) As Vintasoft.Imaging.Annotation.UI.Comments.ICommentControl Implements Vintasoft.Imaging.Annotation.UI.Comments.ICommentControlFactory.Create
' create a comment control that displays comment in WPF image viewer
Return New CommentControl(comment)
End Function
End Class
' see code of CommentControl class for PDF annotation comment in file
' "%INSTALL_PATH%\Examples\WPF\CSharp\WpfPdfEditorDemo\DemosCommonCode.Annotation\Comments\CommentControl.xaml"
'
' see code of CommentControl class for Vintasoft annotation comment in file
' "%INSTALL_PATH%\Examples\WPF\CSharp\WpfAnnotationDemo\DemosCommonCode.Annotation\Comments\CommentControl.xaml"
/// <summary>
/// Initializes WPF image viewer for displaying PDF annotation comments.
/// </summary>
/// <param name="imageViewer">WPF image viewer, which must be initialized for displaying PDF annotation comments.</param>
public static void InitViewerToDisplayPdfAnnotationComments(Vintasoft.Imaging.Wpf.UI.WpfImageViewer imageViewer)
{
// create new PDF annotation comment controller
Vintasoft.Imaging.Annotation.Comments.Pdf.ImageCollectionPdfAnnotationCommentController annotationCommentController =
new Vintasoft.Imaging.Annotation.Comments.Pdf.ImageCollectionPdfAnnotationCommentController();
// create the comment visual tool, which is associated with PDF annotation comment controller
Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool commentVisualTool = CreateCommentTool(annotationCommentController);
// specify that comment visual tool must be used in WPF image viewer
imageViewer.VisualTool = new Vintasoft.Imaging.Wpf.UI.VisualTools.WpfCompositeVisualTool(commentVisualTool, imageViewer.VisualTool);
}
/// <summary>
/// Initializes WPF annotation viewer for displaying Vintasoft annotation comments.
/// </summary>
/// <param name="annotationViewer">WPF annotation viewer, which must be initialized for displaying Vintasoft annotation comments.</param>
public static void InitViewerToDisplayVintasoftAnnotationComments(Vintasoft.Imaging.Annotation.Wpf.UI.WpfAnnotationViewer annotationViewer)
{
// create the annotation comment controller, which is associated with annotation data controller
Vintasoft.Imaging.Annotation.Comments.AnnotationCommentController annotationCommentController =
new Vintasoft.Imaging.Annotation.Comments.AnnotationCommentController(annotationViewer.AnnotationDataController);
// create the comment visual tool, which is associated with annotation comment controller
Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool commentVisualTool = CreateCommentTool(annotationCommentController);
// specify that comment visual tool must be used in WinForms annotation viewer
annotationViewer.VisualTool = new Vintasoft.Imaging.Wpf.UI.VisualTools.WpfCompositeVisualTool(commentVisualTool, annotationViewer.VisualTool);
}
/// <summary>
/// Creates the comment visual tool using the specified comment controller.
/// </summary>
/// <param name="imageCollectionCommentController">The image collection comment controller.</param>
/// <returns>The comment visual tool.</returns>
public static Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool CreateCommentTool(
Vintasoft.Imaging.Annotation.Comments.ImageCollectionCommentController imageCollectionCommentController)
{
// create the comment controller for WPF image viewer
Vintasoft.Imaging.Annotation.Wpf.UI.Comments.WpfImageViewerCommentController commentController =
new Vintasoft.Imaging.Annotation.Wpf.UI.Comments.WpfImageViewerCommentController(imageCollectionCommentController);
// create the comment visual tool, which uses the CommentControlFactory class for creating the comment controls
return new Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool(commentController, new CommentControlFactory());
}
/// <summary>
/// Represents a factory that allows to create comment controls.
/// </summary>
public class CommentControlFactory : Vintasoft.Imaging.Annotation.UI.Comments.ICommentControlFactory
{
/// <summary>
/// Creates the comment control that displays specified comment.
/// </summary>
/// <param name="comment">The comment.</param>
/// <returns>Comment control that displays specified comment.</returns>
public Vintasoft.Imaging.Annotation.UI.Comments.ICommentControl Create(Vintasoft.Imaging.Annotation.Comments.Comment comment)
{
// create a comment control that displays comment in WPF image viewer
return new CommentControl(comment);
}
}
// see code of CommentControl class for PDF annotation comment in file
// "%INSTALL_PATH%\Examples\WPF\CSharp\WpfPdfEditorDemo\DemosCommonCode.Annotation\Comments\CommentControl.xaml"
//
// see code of CommentControl class for Vintasoft annotation comment in file
// "%INSTALL_PATH%\Examples\WPF\CSharp\WpfAnnotationDemo\DemosCommonCode.Annotation\Comments\CommentControl.xaml"
System.Object
 System.Windows.Threading.DispatcherObject
   System.Windows.DependencyObject
     System.Windows.Media.Visual
       System.Windows.UIElement
         System.Windows.FrameworkElement
           System.Windows.Controls.Control
             System.Windows.Controls.ContentControl
               Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool
                 Vintasoft.Imaging.Annotation.Wpf.UI.VisualTools.WpfCommentVisualTool
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5