fixing auto zooming

This commit is contained in:
Manuel Kamper 2024-08-18 16:46:13 +02:00
parent dd2239531d
commit 2aaa004696
2 changed files with 86 additions and 82 deletions

View File

@ -76,6 +76,7 @@
</Mk0.Software.ImageSorter.Properties.Settings>
</userSettings>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="SystemDPIAware"/>
<add key="DpiAwareness" value="PerMonitorV2" />
<add key="EnableWindowsFormsHighDpiAutoResizing" value="false" />
</System.Windows.Forms.ApplicationConfigurationSection>
</configuration>

View File

@ -49,9 +49,11 @@ namespace Mk0.Software.ImageSorter
private FormWindowState lastState = FormWindowState.Minimized;
private string defaultWindowName;
private bool blockZoom = false;
private float scaling;
public Main()
{
scaling = (float)DeviceDpi / 96;
blockZoom = true;
InitializeComponent();
defaultWindowName = Text;
@ -754,13 +756,12 @@ namespace Mk0.Software.ImageSorter
{
imageIndex = 0;
}
pictureBoxImage.ImageLocation = CropImageBorders(images.ElementAt(imageIndex));
//blockZoom = true;
pictureBoxImage.LoadAsync(CropImageBorders(images.ElementAt(imageIndex)));
string resolutionTitle = "";
//if(pictureBoxImage.Image != null)
//{
// resolutionTitle = " (" + pictureBoxImage.Image.Width + "px x " + pictureBoxImage.Image.Height + "px)";
//}
Text = defaultWindowName + " - " + Path.GetFileName(pictureBoxImage.ImageLocation) + resolutionTitle;
//Zoom();
//Zoom();
}
else
{
@ -1125,6 +1126,8 @@ namespace Mk0.Software.ImageSorter
if (pictureBoxImage.Image.Width > panelImageBackground.Width || pictureBoxImage.Image.Height > panelImageBackground.Height)
{
pictureBoxImage.Size = new Size(panelImageBackground.Width, panelImageBackground.Height);
if (pictureBoxImage.Width != panelImageBackground.Width) { pictureBoxImage.Width = panelImageBackground.Width; }
if (pictureBoxImage.Height != panelImageBackground.Height) { pictureBoxImage.Height = panelImageBackground.Height; }
pictureBoxImage.Top = 0;
pictureBoxImage.Left = 0;
moveable = false;
@ -1297,7 +1300,7 @@ namespace Mk0.Software.ImageSorter
/// <param name="e"></param>
private void PictureBox_LoadCompleted(object sender, AsyncCompletedEventArgs e)
{
var x = comboBoxZoom.SelectedItem;
//if (blockZoom) { blockZoom = false; } else { Zoom(); }
Zoom();
}