maximized close case dialog

This commit is contained in:
Meik
2026-02-09 20:18:31 +01:00
parent 9e5a7f7946
commit bf9d37d7af
3 changed files with 78 additions and 15 deletions

View File

@@ -3,13 +3,16 @@ using FasdDesktopUi.Basics;
using FasdDesktopUi.Basics.Models;
using System;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using static C4IT.Logging.cLogManager;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using WinForms = System.Windows.Forms;
using static C4IT.Logging.cLogManager;
namespace FasdDesktopUi.Pages.TicketCompletion
{
@@ -42,13 +45,25 @@ namespace FasdDesktopUi.Pages.TicketCompletion
CloseCaseDialogUc.DataProvider = _dataProvider;
}
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
cFocusInvoker.GotFocus += ElementGotFocus;
cFocusInvoker.LostFocus += ElementLostFocus;
}
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
cFocusInvoker.GotFocus += ElementGotFocus;
cFocusInvoker.LostFocus += ElementLostFocus;
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
UpdateDialogMaxHeightToScreen();
}
protected override void OnLocationChanged(EventArgs e)
{
base.OnLocationChanged(e);
UpdateDialogMaxHeightToScreen();
}
#region ClosingBusy
@@ -126,6 +141,38 @@ namespace FasdDesktopUi.Pages.TicketCompletion
}
}
private void UpdateDialogMaxHeightToScreen()
{
try
{
WinForms.Screen screen = null;
IntPtr currentHandle = new WindowInteropHelper(this).Handle;
if (currentHandle != IntPtr.Zero)
{
screen = WinForms.Screen.FromHandle(currentHandle);
}
else if (Owner != null)
{
IntPtr ownerHandle = new WindowInteropHelper(Owner).Handle;
if (ownerHandle != IntPtr.Zero)
screen = WinForms.Screen.FromHandle(ownerHandle);
}
screen = screen ?? WinForms.Screen.PrimaryScreen;
var workingArea = screen?.WorkingArea ?? WinForms.Screen.PrimaryScreen.WorkingArea;
var dpiScaleY = VisualTreeHelper.GetDpi(this).DpiScaleY;
var maxHeightDip = (workingArea.Height / Math.Max(0.1, dpiScaleY)) - 12;
MaxHeight = Math.Max(220, maxHeightDip);
CloseCaseDialogUc?.SetDialogContentMaxHeight(MaxHeight - 180);
}
catch (Exception ex)
{
LogException(ex);
}
}
#region Internal Focus Events
private void ElementGotFocus(object sender, EventArgs e)