@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public string Title { get; set; } = "Untitled window";
[Parameter]
public double X { get; set; } = 60;
[Parameter]
public double Y { get; set; } = 60;
[Parameter]
public Action OnCloseClicked { get; set; }
private double _x = 60;
private double _y = 60;
protected override void OnInitialized() {
_x = X;
_y = Y;
}
private void WindowDrag(DragEventArgs obj) {
Console.WriteLine("Drag: " + obj.ToJson());
_x += obj.MovementX;
_y += obj.MovementY;
StateHasChanged();
}
private bool isDragging = false;
private double dragX = 0;
private double dragY = 0;
private void MouseDown(MouseEventArgs obj) {
isDragging = true;
dragX = obj.ClientX;
dragY = obj.ClientY;
}
private void MouseUp(MouseEventArgs obj) {
isDragging = false;
}
private void MouseMove(MouseEventArgs obj) {
if (isDragging) {
_x += obj.ClientX - dragX;
_y += obj.ClientY - dragY;
dragX = obj.ClientX;
dragY = obj.ClientY;
StateHasChanged();
}
}
}