Класс WpfDragDropSelectionTool
Визуальный инструмент для перетаскивания области изображения в просмотрщике изображений.
Прямоугольную область изображения в просмотрщике изображений можно перетаскивать следующим образом:
- поместите мышь в нужную позицию
- выберите область "перетаскивания" с помощью кнопки действия (ActionButton)
- нажмите и удерживайте кнопку перетаскивания (DragButton) внутри области "перетаскивания", чтобы начать перетаскивание; нажмите любую кнопку мыши за пределами области "перетаскивания" для отмены перетаскивания области изображения
- потяните кнопку "Перетаскивание" (DragButton) и перетащите область "перетаскивания"
- отпустите кнопку "Перетаскивание" (DragButton), когда "перетаскиваемая" область будет перетащена в нужную позицию
- нажмите кнопку "Отпустить" (DropButton) за пределами области "перетаскивания", чтобы отпустить область; нажмите любую кнопку мыши за пределами области "перетаскивания" для отмены перетаскивания области изображения
Перетаскиваемая область не изменяется, если нажата клавиша
CTRL.
Вот C#/VB.NET код, который демонстрирует, как программно перетаскивать область изображения.
Class WpfDragDropSelectionToolExample
' Programmatically drag and drop a region of image.
Public Sub ProgrammaticallyDragAndDropImageInViewer(viewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer)
' create an instance of the DragDropSelectionTool class
Dim dragDropSelectionTool As New Vintasoft.Imaging.Wpf.UI.VisualTools.WpfDragDropSelectionTool()
' set the tool as the current tool of the ImageViewer
viewer.VisualTool = dragDropSelectionTool
' set the region of interest on image
dragDropSelectionTool.Rectangle = New System.Windows.Rect(50, 50, 250, 150)
' drag and drop the selected region of image to the specified location within the image
dragDropSelectionTool.DragAndDrop(New System.Windows.Point(200, 250))
End Sub
End Class
class WpfDragDropSelectionToolExample
{
// Programmatically drag and drop a region of image.
public void ProgrammaticallyDragAndDropImageInViewer(Vintasoft.Imaging.Wpf.UI.WpfImageViewer viewer)
{
// create an instance of the DragDropSelectionTool class
Vintasoft.Imaging.Wpf.UI.VisualTools.WpfDragDropSelectionTool dragDropSelectionTool =
new Vintasoft.Imaging.Wpf.UI.VisualTools.WpfDragDropSelectionTool();
// set the tool as the current tool of the ImageViewer
viewer.VisualTool = dragDropSelectionTool;
// set the region of interest on image
dragDropSelectionTool.Rectangle = new System.Windows.Rect(50, 50, 250, 150);
// drag and drop the selected region of image to the specified location within the image
dragDropSelectionTool.DragAndDrop(new System.Windows.Point(200, 250));
}
}
Целевые платформы: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5