44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
|
|
namespace Orbit.Module.View
|
|
{
|
|
class CustomScrollViewer : ScrollViewer
|
|
{
|
|
private Point _scrollMousePoint;
|
|
private double _hOff = 1;
|
|
private double _vOff = 1;
|
|
|
|
protected override void OnKeyDown(KeyEventArgs e)
|
|
{
|
|
//Disable key presses
|
|
}
|
|
|
|
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
|
|
{
|
|
_scrollMousePoint = e.GetPosition(this);
|
|
_vOff = VerticalOffset;
|
|
_hOff = HorizontalOffset;
|
|
CaptureMouse();
|
|
}
|
|
|
|
protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e)
|
|
{
|
|
if (IsMouseCaptured)
|
|
ReleaseMouseCapture();
|
|
}
|
|
|
|
protected override void OnPreviewMouseMove(MouseEventArgs e)
|
|
{
|
|
if (IsMouseCaptured)
|
|
{
|
|
base.OnPreviewMouseMove(e);
|
|
var newOffsetY = _vOff + (_scrollMousePoint.Y - e.GetPosition(this).Y);
|
|
var newOffsetX = _hOff + (_scrollMousePoint.X - e.GetPosition(this).X);
|
|
ScrollToVerticalOffset(newOffsetY);
|
|
ScrollToHorizontalOffset(newOffsetX);
|
|
}
|
|
}
|
|
}
|
|
}
|