fixed fallabschluss höhe

This commit is contained in:
Meik
2026-02-10 11:29:57 +01:00
parent 764a8cffb8
commit f89e2de60d

View File

@@ -18,8 +18,10 @@ namespace FasdDesktopUi.Pages.TicketCompletion
{ {
public partial class TicketCompletion : Window, IBlurInvoker, INotifyPropertyChanged public partial class TicketCompletion : Window, IBlurInvoker, INotifyPropertyChanged
{ {
private const double MinWindowHeightDip = 220d;
private const double WindowWorkingAreaMarginDip = 12d; private const double WindowWorkingAreaMarginDip = 12d;
private const double DialogNonContentReserveDip = 180d; private const double DialogNonContentReserveDip = 180d;
private bool isUpdatingDialogBounds;
private bool isCanceled = false; private bool isCanceled = false;
private bool _WaitForClosing = false; private bool _WaitForClosing = false;
@@ -53,6 +55,8 @@ namespace FasdDesktopUi.Pages.TicketCompletion
cFocusInvoker.GotFocus += ElementGotFocus; cFocusInvoker.GotFocus += ElementGotFocus;
cFocusInvoker.LostFocus += ElementLostFocus; cFocusInvoker.LostFocus += ElementLostFocus;
SizeChanged += TicketCompletion_SizeChanged;
Loaded += TicketCompletion_Loaded;
} }
protected override void OnSourceInitialized(EventArgs e) protected override void OnSourceInitialized(EventArgs e)
@@ -66,6 +70,10 @@ namespace FasdDesktopUi.Pages.TicketCompletion
base.OnLocationChanged(e); base.OnLocationChanged(e);
UpdateDialogMaxHeightToScreen(); UpdateDialogMaxHeightToScreen();
} }
private void TicketCompletion_Loaded(object sender, RoutedEventArgs e) => UpdateDialogMaxHeightToScreen();
private void TicketCompletion_SizeChanged(object sender, SizeChangedEventArgs e) => UpdateDialogMaxHeightToScreen();
#region ClosingBusy #region ClosingBusy
@@ -145,6 +153,10 @@ namespace FasdDesktopUi.Pages.TicketCompletion
private void UpdateDialogMaxHeightToScreen() private void UpdateDialogMaxHeightToScreen()
{ {
if (isUpdatingDialogBounds)
return;
isUpdatingDialogBounds = true;
try try
{ {
WinForms.Screen screen = null; WinForms.Screen screen = null;
@@ -164,15 +176,45 @@ namespace FasdDesktopUi.Pages.TicketCompletion
screen = screen ?? WinForms.Screen.PrimaryScreen; screen = screen ?? WinForms.Screen.PrimaryScreen;
var workingArea = screen?.WorkingArea ?? WinForms.Screen.PrimaryScreen.WorkingArea; var workingArea = screen?.WorkingArea ?? WinForms.Screen.PrimaryScreen.WorkingArea;
var dpiScaleY = VisualTreeHelper.GetDpi(this).DpiScaleY; var dpiScaleY = VisualTreeHelper.GetDpi(this).DpiScaleY;
var maxHeightDip = (workingArea.Height / Math.Max(0.1, dpiScaleY)) - WindowWorkingAreaMarginDip; var safeDpiScaleY = Math.Max(0.1, dpiScaleY);
var workingAreaTopDip = workingArea.Top / safeDpiScaleY;
var workingAreaBottomDip = workingArea.Bottom / safeDpiScaleY;
var workingAreaHeightDip = workingArea.Height / safeDpiScaleY;
var availableWindowHeightDip = workingAreaHeightDip - (WindowWorkingAreaMarginDip * 2);
MaxHeight = Math.Max(220, maxHeightDip); MaxHeight = Math.Max(MinWindowHeightDip, availableWindowHeightDip);
CloseCaseDialogUc?.SetDialogContentMaxHeight(MaxHeight - DialogNonContentReserveDip);
if (!double.IsNaN(Top))
{
var minTop = workingAreaTopDip + WindowWorkingAreaMarginDip;
var maxBottom = workingAreaBottomDip - WindowWorkingAreaMarginDip;
if (Top < minTop)
Top = minTop;
var currentBottom = Top + ActualHeight;
if (currentBottom > maxBottom)
Top = Math.Max(minTop, maxBottom - ActualHeight);
}
double nonDialogReserve = DialogNonContentReserveDip;
if (CloseCaseDialogUc != null && CloseCaseDialogUc.IsLoaded)
{
var estimatedReserve = ActualHeight - CloseCaseDialogUc.ActualHeight;
if (estimatedReserve > 0)
nonDialogReserve = Math.Max(nonDialogReserve, estimatedReserve + WindowWorkingAreaMarginDip);
}
CloseCaseDialogUc?.SetDialogContentMaxHeight(MaxHeight - nonDialogReserve);
} }
catch (Exception ex) catch (Exception ex)
{ {
LogException(ex); LogException(ex);
} }
finally
{
isUpdatingDialogBounds = false;
}
} }
#region Internal Focus Events #region Internal Focus Events