Initial commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace DelauneyTriangulation.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private bool _isPanning;
|
||||
private Point _panStart;
|
||||
private Vector _panOffset = new();
|
||||
private readonly TranslateTransform _panTransform = new();
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
SceneContent.RenderTransform = _panTransform;
|
||||
}
|
||||
|
||||
private void OnTitleBarPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
|
||||
BeginMoveDrag(e);
|
||||
}
|
||||
private void OnTitleBarDoubleTapped(object? sender, RoutedEventArgs e) => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
private void Scene_OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (!e.GetCurrentPoint(Scene).Properties.IsLeftButtonPressed)
|
||||
return;
|
||||
|
||||
_isPanning = true;
|
||||
_panStart = e.GetPosition(this);
|
||||
Scene.Cursor = new Cursor(StandardCursorType.SizeAll);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void Scene_OnPointerMoved(object? sender, PointerEventArgs e)
|
||||
{
|
||||
if (!_isPanning) return;
|
||||
|
||||
var pos = e.GetPosition(this);
|
||||
var delta = pos - _panStart;
|
||||
var current = _panOffset + delta;
|
||||
_panTransform.X = current.X;
|
||||
_panTransform.Y = current.Y;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void Scene_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||
{
|
||||
if (!_isPanning) return;
|
||||
|
||||
var pos = e.GetPosition(this);
|
||||
var delta = pos - _panStart;
|
||||
_panOffset += delta;
|
||||
|
||||
_isPanning = false;
|
||||
Scene.Cursor = new Cursor(StandardCursorType.Arrow);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void Scene_OnWheel(object? sender, PointerWheelEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user