mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
- Add Logic in settingwindow
This commit is contained in:
parent
ab40e7a2e4
commit
5df7362674
1 changed files with 28 additions and 6 deletions
|
|
@ -112,23 +112,45 @@ public partial class SettingWindow
|
|||
{
|
||||
if (_settings.SettingWindowTop == null || _settings.SettingWindowLeft == null)
|
||||
{
|
||||
Top = WindowTop();
|
||||
Left = WindowLeft();
|
||||
SetWindowPosition(WindowTop(), WindowLeft());
|
||||
}
|
||||
else
|
||||
{
|
||||
Top = _settings.SettingWindowTop.Value;
|
||||
Left = _settings.SettingWindowLeft.Value;
|
||||
double left = _settings.SettingWindowLeft.Value;
|
||||
double top = _settings.SettingWindowTop.Value;
|
||||
AdjustWindowPosition(ref top, ref left);
|
||||
SetWindowPosition(top, left);
|
||||
}
|
||||
WindowState = _settings.SettingWindowState;
|
||||
}
|
||||
|
||||
private void SetWindowPosition(double top, double left)
|
||||
{
|
||||
// Ensure window does not exceed screen boundaries
|
||||
top = Math.Max(top, SystemParameters.VirtualScreenTop);
|
||||
left = Math.Max(left, SystemParameters.VirtualScreenLeft);
|
||||
top = Math.Min(top, SystemParameters.VirtualScreenHeight - ActualHeight);
|
||||
left = Math.Min(left, SystemParameters.VirtualScreenWidth - ActualWidth);
|
||||
|
||||
Top = top;
|
||||
Left = left;
|
||||
}
|
||||
|
||||
private void AdjustWindowPosition(ref double top, ref double left)
|
||||
{
|
||||
// Adjust window position if it exceeds screen boundaries
|
||||
top = Math.Max(top, SystemParameters.VirtualScreenTop);
|
||||
left = Math.Max(left, SystemParameters.VirtualScreenLeft);
|
||||
top = Math.Min(top, SystemParameters.VirtualScreenHeight - ActualHeight);
|
||||
left = Math.Min(left, SystemParameters.VirtualScreenWidth - ActualWidth);
|
||||
}
|
||||
|
||||
private double WindowLeft()
|
||||
{
|
||||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
|
||||
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
|
||||
var left = (dip2.X - this.ActualWidth) / 2 + dip1.X;
|
||||
var left = (dip2.X - ActualWidth) / 2 + dip1.X;
|
||||
return left;
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +159,7 @@ public partial class SettingWindow
|
|||
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
|
||||
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
|
||||
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
|
||||
var top = (dip2.Y - this.ActualHeight) / 2 + dip1.Y - 20;
|
||||
var top = (dip2.Y - ActualHeight) / 2 + dip1.Y;
|
||||
return top;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue