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

@@ -88,7 +88,6 @@
</UserControl.Resources> </UserControl.Resources>
<ScrollViewer x:Name="DialogContentScrollViewer" <ScrollViewer x:Name="DialogContentScrollViewer"
Height="570"
Padding="0 0 5 0" Padding="0 0 5 0"
VerticalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
Focusable="True"> Focusable="True">

View File

@@ -2736,6 +2736,23 @@ namespace FasdDesktopUi.Basics.UserControls
} }
} }
public void SetDialogContentMaxHeight(double maxHeight)
{
try
{
if (DialogContentScrollViewer == null)
return;
// Keep dialog usable on very small screens, but allow larger monitors to use space.
var clamped = Math.Max(220, Math.Min(900, maxHeight));
DialogContentScrollViewer.MaxHeight = clamped;
}
catch (Exception E)
{
LogException(E);
}
}
private void DropDownClosed(object sender, EventArgs e) private void DropDownClosed(object sender, EventArgs e)
{ {
if (!(sender is FrameworkElement fe)) return; if (!(sender is FrameworkElement fe)) return;

View File

@@ -3,13 +3,16 @@ using FasdDesktopUi.Basics;
using FasdDesktopUi.Basics.Models; using FasdDesktopUi.Basics.Models;
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using static C4IT.Logging.cLogManager; using System.Windows.Interop;
using System.Windows.Media;
using WinForms = System.Windows.Forms;
using static C4IT.Logging.cLogManager;
namespace FasdDesktopUi.Pages.TicketCompletion namespace FasdDesktopUi.Pages.TicketCompletion
{ {
@@ -42,13 +45,25 @@ namespace FasdDesktopUi.Pages.TicketCompletion
CloseCaseDialogUc.DataProvider = _dataProvider; CloseCaseDialogUc.DataProvider = _dataProvider;
} }
protected override void OnInitialized(EventArgs e) protected override void OnInitialized(EventArgs e)
{ {
base.OnInitialized(e); base.OnInitialized(e);
cFocusInvoker.GotFocus += ElementGotFocus; cFocusInvoker.GotFocus += ElementGotFocus;
cFocusInvoker.LostFocus += ElementLostFocus; 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 #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 #region Internal Focus Events
private void ElementGotFocus(object sender, EventArgs e) private void ElementGotFocus(object sender, EventArgs e)