-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SolverVizTools: Fixed issues: dialogs now open properly centered to p…
…arent windows, Linux should now show the version properly in the window title, latest used paths in file open dialogs are persisted and saved to a config file.
- Loading branch information
Showing
13 changed files
with
190 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/WatneyAstrometry.SolverVizTools/Utils/WindowWorkarounds.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
|
||
namespace WatneyAstrometry.SolverVizTools.Utils; | ||
|
||
public static class WindowWorkarounds | ||
{ | ||
/// <summary> | ||
/// From: https://github.com/AvaloniaUI/Avalonia/issues/6433#issuecomment-1001766862 | ||
/// Essentially the window centering bugs out in Linux. This fixes it. | ||
/// </summary> | ||
/// <param name="window"></param> | ||
public static void ApplyWindowCenteringWorkaround(Window window) | ||
{ | ||
if (OperatingSystem.IsWindows()) | ||
{ | ||
// Not needed for Windows | ||
return; | ||
} | ||
|
||
var scale = window.PlatformImpl?.DesktopScaling ?? 1.0; | ||
var pOwner = window.Owner?.PlatformImpl; | ||
if (pOwner != null) | ||
{ | ||
scale = pOwner.DesktopScaling; | ||
} | ||
var rect = new PixelRect(PixelPoint.Origin, | ||
PixelSize.FromSize(window.ClientSize, scale)); | ||
if (window.WindowStartupLocation == WindowStartupLocation.CenterScreen) | ||
{ | ||
var screen = window.Screens.ScreenFromPoint(pOwner?.Position ?? window.Position); | ||
if (screen == null) | ||
{ | ||
return; | ||
} | ||
window.Position = screen.WorkingArea.CenterRect(rect).Position; | ||
} | ||
else | ||
{ | ||
if (pOwner == null || | ||
window.WindowStartupLocation != WindowStartupLocation.CenterOwner) | ||
{ | ||
return; | ||
} | ||
window.Position = new PixelRect(pOwner.Position, | ||
PixelSize.FromSize(pOwner.ClientSize, scale)).CenterRect(rect).Position; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.