restructure project for part 2

This commit is contained in:
TheXamlGuy
2024-01-27 10:55:53 +00:00
parent a322893166
commit 48925b89ff
96 changed files with 383 additions and 351 deletions
+48
View File
@@ -0,0 +1,48 @@
using Hyperbar.Interop.Windows;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Windows.Graphics;
using WinRT.Interop;
namespace Hyperbar.UI.Windows;
public static class WindowExtensions
{
public static WindowMessageListener CreateMessageListener(this Window window) =>
WindowMessageListener.Create(window.GetHandle());
public static IntPtr GetHandle(this Window window) =>
window is not null ? WindowNative.GetWindowHandle(window) : default;
public static void MoveAndResize(this Window window,
double x,
double y,
double width,
double height)
{
float num = HwndExtensions.GetDpiForWindow(window.GetHandle()) / 96f;
window.AppWindow.MoveAndResize(new RectInt32((int)x, (int)y, (int)(width * (double)num), (int)(height * (double)num)));
}
public static void SetIsAvailableInSwitchers(this Window window,
bool value) => window.AppWindow.IsShownInSwitchers = value;
public static void SetOpacity(this Window window,
byte value) => window.GetHandle().SetWindowOpacity(value);
public static void SetStyle(this Window window,
WindowStyle style) => window.GetHandle().SetWindowStyle(style);
public static void SetStyle(this Window window,
ExtendedWindowStyle style) => window.GetHandle().SetExtendedWindowStyle(style);
public static void SetTopMost(this Window window,
bool value)
{
AppWindow appWindow = window.AppWindow;
if (appWindow.Presenter is OverlappedPresenter presenter)
{
presenter.IsAlwaysOnTop = value;
}
}
}