This is logic for dragging some cropper over image, and it works. But i have multiple images on different windows (and because of that different files) and I want to assign same logic to all of them, but i dont want to copy same code everywhere. Is there any way to do it?
private bool isDragging;
private Point clickPosition;
private void OnMouseMove(object sender, MouseEventArgs e)
{
if (isDragging)
{
Point currentPosition = e.GetPosition(this.Parent as UIElement);
double xdiff = currentPosition.X - clickPosition.X;
double ydiff = currentPosition.Y - clickPosition.Y;
croppingAdorner.HandleThumb(1, 1, 0, 0, xdiff, ydiff);
clickPosition = e.GetPosition(this);
}
}
private void OnMouseDown(object sender, MouseButtonEventArgs e)
{
if (CropHelper.IsPointInsideRect(e.GetPosition(this.originalImage), rc))
{
isDragging = true;
clickPosition = e.GetPosition(this);
}
}
private void OnMouseUp(object sender, MouseButtonEventArgs e)
{
isDragging = false;
}
private void OnMouseLeave(object sender, MouseEventArgs e)
{
isDragging = false;
}