mirror of
https://github.com/egmont11/NetworkDiagram.git
synced 2026-07-24 07:09:43 +02:00
Sort of fixed. The diagrams now actually get placed where they're supposed to, but just to be safe, the camera no longer gets teleported to the diagrams coordinates.
This commit is contained in:
@@ -78,14 +78,11 @@ namespace NetworkDiagram
|
||||
private void CenterView()
|
||||
{
|
||||
if (CanvasTranslate == null || CanvasScale == null) return;
|
||||
double vw = CanvasViewport.Bounds.Width > 0 ? CanvasViewport.Bounds.Width : 1000;
|
||||
double vh = CanvasViewport.Bounds.Height > 0 ? CanvasViewport.Bounds.Height : 700;
|
||||
|
||||
CanvasScale.ScaleX = 1.0;
|
||||
CanvasScale.ScaleY = 1.0;
|
||||
// Place canvas center (20000,20000) in viewport center
|
||||
CanvasTranslate.X = vw / 2 - CanvasCenterX;
|
||||
CanvasTranslate.Y = vh / 2 - CanvasCenterY;
|
||||
// Změna na 0,0 aby levý horní roh plátna odpovídal levému hornímu rohu viewportu
|
||||
CanvasTranslate.X = 0;
|
||||
CanvasTranslate.Y = 0;
|
||||
}
|
||||
|
||||
#region Panning and Zooming
|
||||
@@ -713,10 +710,9 @@ namespace NetworkDiagram
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for Avalonia to measure/arrange the newly added controls, then center
|
||||
// Wait for Avalonia to measure/arrange the newly added controls
|
||||
await Dispatcher.UIThread.InvokeAsync(() => { }, DispatcherPriority.Loaded);
|
||||
await Dispatcher.UIThread.InvokeAsync(() => { }, DispatcherPriority.Render);
|
||||
CenterOnContent();
|
||||
} catch (Exception ex) {
|
||||
Console.WriteLine("Load failed: " + ex.Message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user