5.1.0.5: Scaling gefixt, maxwidth binding aus gridToday entfernt
This commit is contained in:
parent
7477d8a130
commit
a658357c7e
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Win32;
|
using MahApps.Metro.Controls;
|
||||||
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -36,6 +37,7 @@ namespace ZKuP
|
|||||||
{
|
{
|
||||||
public static double width = 0;
|
public static double width = 0;
|
||||||
public static double height = 0;
|
public static double height = 0;
|
||||||
|
public static double scale = 0;
|
||||||
public static bool? IsFileLocked(FileInfo file)
|
public static bool? IsFileLocked(FileInfo file)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -809,54 +811,67 @@ namespace ZKuP
|
|||||||
return GetCell(grid, rowContainer, column);
|
return GetCell(grid, rowContainer, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal static void initScaler(double Width, double Height)
|
||||||
|
{
|
||||||
|
width = Width;
|
||||||
|
height = Height;
|
||||||
|
}
|
||||||
|
|
||||||
static double lastDpiScale = -1;
|
static double lastDpiScale = -1;
|
||||||
static bool _isCurrentlyScaled = false;
|
static bool _isCurrentlyScaled = false;
|
||||||
internal static async void CheckScale(Window mainWindow)
|
internal static async void CheckScale(Window mainWindow)
|
||||||
{
|
{
|
||||||
var dpi = VisualTreeHelper.GetDpi(mainWindow);
|
if (!(width == 0 || height == 0))
|
||||||
double dpiScale = dpi.DpiScaleX; // or DpiScaleY
|
|
||||||
|
|
||||||
|
|
||||||
double scaledWidth = width * dpiScale;
|
|
||||||
double scaledHeight = height * dpiScale;
|
|
||||||
|
|
||||||
var screen = WpfScreenHelper.Screen.FromHandle(new WindowInteropHelper(mainWindow).Handle);
|
|
||||||
var workingArea = screen.WorkingArea;
|
|
||||||
|
|
||||||
bool needsScaling = (width * dpiScale) > workingArea.Width || (height * dpiScale) > workingArea.Height;
|
|
||||||
|
|
||||||
lastDpiScale = dpiScale;
|
|
||||||
|
|
||||||
if (needsScaling)
|
|
||||||
{
|
{
|
||||||
// Calculate the scale to fit in working area
|
var dpi = VisualTreeHelper.GetDpi(mainWindow);
|
||||||
double scaleX = workingArea.Width / width;
|
double dpiScale = dpi.DpiScaleX; // or DpiScaleY
|
||||||
double scaleY = workingArea.Height / height;
|
|
||||||
double scale = Math.Min(scaleX, scaleY);
|
|
||||||
|
|
||||||
scale = Math.Round(scale * 4) / 4.0;
|
|
||||||
|
|
||||||
mainWindow.MinWidth = scale * width;
|
double scaledWidth = width * dpiScale;
|
||||||
mainWindow.MinHeight = scale * height;
|
double scaledHeight = height * dpiScale;
|
||||||
mainWindow.LayoutTransform = new ScaleTransform(scale, scale);
|
|
||||||
|
|
||||||
mainWindow.Width = mainWindow.MinWidth;
|
var screen = WpfScreenHelper.Screen.FromHandle(new WindowInteropHelper(mainWindow).Handle);
|
||||||
mainWindow.Height = mainWindow.MinHeight;
|
var workingArea = screen.WorkingArea;
|
||||||
|
|
||||||
TextOptions.SetTextFormattingMode(mainWindow, TextFormattingMode.Display);
|
bool needsScaling = (width * dpiScale) > workingArea.Width || (height * dpiScale) > workingArea.Height;
|
||||||
TextOptions.SetTextRenderingMode(mainWindow, TextRenderingMode.ClearType);
|
|
||||||
_isCurrentlyScaled = true;
|
|
||||||
}
|
|
||||||
else if (_isCurrentlyScaled)
|
|
||||||
{
|
|
||||||
// Reset to normal scale
|
|
||||||
mainWindow.LayoutTransform = Transform.Identity;
|
|
||||||
|
|
||||||
mainWindow.MinWidth = width != 0 ? width : mainWindow.MinWidth;
|
lastDpiScale = dpiScale;
|
||||||
mainWindow.MinHeight = height != 0 ? height : mainWindow.MinHeight;
|
|
||||||
|
|
||||||
TextOptions.SetTextFormattingMode(mainWindow, TextFormattingMode.Ideal);
|
if (needsScaling && !_isCurrentlyScaled)
|
||||||
TextOptions.SetTextRenderingMode(mainWindow, TextRenderingMode.Auto);
|
{
|
||||||
|
// Calculate the scale to fit in working area
|
||||||
|
double scaleX = width / workingArea.Width;
|
||||||
|
double scaleY = height / workingArea.Height;
|
||||||
|
scale = Math.Min(scaleX, scaleY);
|
||||||
|
|
||||||
|
scale = Math.Round(scale * 4) / 4.0;
|
||||||
|
|
||||||
|
mainWindow.MinWidth = scale * width;
|
||||||
|
mainWindow.MinHeight = scale * height;
|
||||||
|
mainWindow.LayoutTransform = new ScaleTransform(scale, scale);
|
||||||
|
|
||||||
|
|
||||||
|
mainWindow.Width = mainWindow.MinWidth;
|
||||||
|
mainWindow.Height = mainWindow.MinHeight;
|
||||||
|
|
||||||
|
TextOptions.SetTextFormattingMode(mainWindow, TextFormattingMode.Display);
|
||||||
|
TextOptions.SetTextRenderingMode(mainWindow, TextRenderingMode.ClearType);
|
||||||
|
_isCurrentlyScaled = true;
|
||||||
|
}
|
||||||
|
else if (_isCurrentlyScaled && !needsScaling)
|
||||||
|
{
|
||||||
|
// Reset to normal scale
|
||||||
|
mainWindow.LayoutTransform = Transform.Identity;
|
||||||
|
|
||||||
|
mainWindow.MinWidth = width != 0 ? width : mainWindow.MinWidth;
|
||||||
|
mainWindow.MinHeight = height != 0 ? height : mainWindow.MinHeight;
|
||||||
|
|
||||||
|
TextOptions.SetTextFormattingMode(mainWindow, TextFormattingMode.Ideal);
|
||||||
|
TextOptions.SetTextRenderingMode(mainWindow, TextRenderingMode.Auto);
|
||||||
|
|
||||||
|
_isCurrentlyScaled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -607,7 +607,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
<Grid x:Name="gridToday" Grid.Row="1" Visibility="Collapsed" VerticalAlignment="Stretch" MinHeight="100" Margin="0,-10,0,0" MaxWidth="{Binding ActualWidth, ElementName=metroWindow, Mode=OneWay}">
|
<Grid x:Name="gridToday" Grid.Row="1" Visibility="Collapsed" VerticalAlignment="Stretch" MinHeight="100" Margin="0,-10,0,0" >
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition x:Name="columnLeft" Width="1.456*" MinWidth="1000"/>
|
<ColumnDefinition x:Name="columnLeft" Width="1.456*" MinWidth="1000"/>
|
||||||
<ColumnDefinition Width="15"/>
|
<ColumnDefinition Width="15"/>
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace ZKuP
|
|||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public const string Version = "5.1.0.4";
|
public const string Version = "5.1.0.5";
|
||||||
public static Roles LoggedInRole { get; private set; } = Roles.None;
|
public static Roles LoggedInRole { get; private set; } = Roles.None;
|
||||||
|
|
||||||
|
|
||||||
@ -291,8 +291,7 @@ namespace ZKuP
|
|||||||
if (actualheight <= 191) gridBackground.RowDefinitions[1].Height = new GridLength(maxheight);
|
if (actualheight <= 191) gridBackground.RowDefinitions[1].Height = new GridLength(maxheight);
|
||||||
|
|
||||||
//gridSpinner.Visibility = Visibility.Collapsed;
|
//gridSpinner.Visibility = Visibility.Collapsed;
|
||||||
Helper.width = this.MinWidth;
|
Helper.initScaler(this.MinWidth, this.MinHeight);
|
||||||
Helper.height = this.MinHeight;
|
|
||||||
|
|
||||||
|
|
||||||
connTimer.Interval = TimeSpan.FromSeconds(2);
|
connTimer.Interval = TimeSpan.FromSeconds(2);
|
||||||
@ -3038,10 +3037,10 @@ namespace ZKuP
|
|||||||
|
|
||||||
Point splitterPosition = splitter.TransformToAncestor(window).Transform(new Point(0, 0));
|
Point splitterPosition = splitter.TransformToAncestor(window).Transform(new Point(0, 0));
|
||||||
|
|
||||||
if (splitterPosition.Y > (this.ActualHeight - 190))
|
if (splitterPosition.Y > ((this.ActualHeight - 190) / Helper.scale))
|
||||||
{
|
{
|
||||||
e.Handled = true; // Bewegung stoppen
|
e.Handled = true; // Bewegung stoppen
|
||||||
gridRowTop.Height = new GridLength(this.ActualHeight - 160 - 190);
|
gridRowTop.Height = new GridLength((this.ActualHeight - 160 - 190) / Helper.scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user