mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-22 13:50:14 +00:00
43caff1ca9
commit 2bbda3c4e4969fdf05566908fde01f1c9e4e23f7 Author: Stanley <hawkeyesk@outlook.com> Date: Mon Sep 5 23:54:39 2022 -0400 Added in-game panel support commit ec29b0ec2612b10e45ab9a73c10b88a98fcf6eaf Author: Stanley <hawkeyesk@outlook.com> Date: Sun Sep 4 21:21:37 2022 -0400 Added in-game panel support commit 97edc184f349e1fde74a15a643fb90fb9bd90395 Author: Stanley <hawkeyesk@outlook.com> Date: Thu Sep 1 18:08:44 2022 -0400 Update touch panel commit da48ca0a272290466952c5c1bd1ca035d56f930c Author: Stanley <hawkeyesk@outlook.com> Date: Mon Aug 29 22:19:38 2022 -0400 Added pop out panel temporary display commit 701346193804f93616b0e6e2222d9d55223f516f Author: Stanley <hawkeyesk@outlook.com> Date: Wed Aug 24 10:33:59 2022 -0400 Added auto resize window display mode commit 98cbcd949f1555b44db22267ce5c54858bef47cd Author: Stanley <hawkeyesk@outlook.com> Date: Wed Aug 24 09:39:38 2022 -0400 Added auto resize window display mode
64 lines
2.3 KiB
C#
64 lines
2.3 KiB
C#
using MSFSPopoutPanelManager.Shared;
|
|
using MSFSPopoutPanelManager.WindowsAgent;
|
|
using System;
|
|
using System.Windows;
|
|
using System.Windows.Interop;
|
|
|
|
namespace MSFSPopoutPanelManager.WpfApp
|
|
{
|
|
public partial class PanelCoorOverlay : Window
|
|
{
|
|
private const int TOP_ADJUSTMENT = 15; // half of window height
|
|
private const int LEFT_ADJUSTMENT = 15; // half of window width
|
|
private int _xCoor;
|
|
private int _yCoor;
|
|
|
|
public bool IsEditingPanelLocation { get; set; }
|
|
|
|
public IntPtr WindowHandle { get; set; }
|
|
|
|
public event EventHandler<System.Drawing.Point> WindowLocationChanged;
|
|
|
|
public PanelCoorOverlay(int panelIndex)
|
|
{
|
|
InitializeComponent();
|
|
this.lblPanelIndex.Content = panelIndex;
|
|
IsEditingPanelLocation = false;
|
|
this.Topmost = true;
|
|
|
|
this.LocationChanged += PanelCoorOverlay_LocationChanged;
|
|
}
|
|
|
|
public void MoveWindow(int x, int y)
|
|
{
|
|
_xCoor = x - LEFT_ADJUSTMENT;
|
|
_yCoor = y - TOP_ADJUSTMENT;
|
|
}
|
|
|
|
private void PanelCoorOverlay_LocationChanged(object sender, EventArgs e)
|
|
{
|
|
if (this.Top is double.NaN || this.Left is double.NaN)
|
|
return;
|
|
|
|
// Fixed broken window left/top coordinate for DPI Awareness Per Monitor
|
|
var handle = new WindowInteropHelper(this).Handle;
|
|
var rect = WindowActionManager.GetWindowRect(handle);
|
|
WindowLocationChanged?.Invoke(this, new System.Drawing.Point(rect.X + LEFT_ADJUSTMENT, rect.Y + TOP_ADJUSTMENT));
|
|
}
|
|
|
|
private void Window_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
|
{
|
|
if (IsEditingPanelLocation && e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
|
|
this.DragMove();
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
// Fixed broken window left/top coordinate for DPI Awareness Per Monitor
|
|
var handle = new WindowInteropHelper(this).Handle;
|
|
WindowActionManager.MoveWindow(handle, _xCoor, _yCoor, Convert.ToInt32(this.Width), Convert.ToInt32(this.Height));
|
|
|
|
WindowActionManager.ApplyAlwaysOnTop(handle, PanelType.WPFWindow, true);
|
|
}
|
|
}
|
|
}
|