From 339d9e328cfe1fc0fb6a087b5f90eb7f361c76e5 Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Sun, 18 Aug 2024 15:34:44 +0200 Subject: [PATCH] fixed #19 and maybe #20 --- Mk0.Software.ImageSorter/Main.cs | 89 ++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/Mk0.Software.ImageSorter/Main.cs b/Mk0.Software.ImageSorter/Main.cs index dc59e31..682c7df 100644 --- a/Mk0.Software.ImageSorter/Main.cs +++ b/Mk0.Software.ImageSorter/Main.cs @@ -48,16 +48,18 @@ namespace Mk0.Software.ImageSorter public string[] Args; private FormWindowState lastState = FormWindowState.Minimized; private string defaultWindowName; + private bool blockZoom = false; public Main() { + blockZoom = true; InitializeComponent(); defaultWindowName = Text; banner = new Banner(components, panelBanner, pictureBoxBanner1, pictureBoxBanner2, labelBanner1, labelBanner2); pictureBoxImage.Cursor = grabCursor; DoubleBuffered = true; + blockZoom = false; SetDefaultPath(); - comboBoxZoom.SelectedIndex = Properties.Settings.Default.zoom; //file assoc prüfen und in einstellungen richtig setzen if(FileAssociation.Check("Image_Sorter_JPG", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico") && @@ -159,6 +161,7 @@ namespace Mk0.Software.ImageSorter /// private void Main_Shown(object sender, EventArgs e) { + comboBoxZoom.SelectedIndex = Properties.Settings.Default.zoom; if (Properties.Settings.Default.fullScreen) { WindowState = FormWindowState.Maximized; @@ -1096,50 +1099,60 @@ namespace Mk0.Software.ImageSorter /// private void Zoom() { - string zoom = comboBoxZoom.SelectedItem.ToString(); + if (!blockZoom) + { + string zoom = comboBoxZoom.SelectedItem.ToString(); - if (zoom == "Original") - { - pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom; - pictureBoxImage.Size = new Size(pictureBoxImage.Image.Width, pictureBoxImage.Image.Height); - if (pictureBoxImage.Image.Width > panelImageBackground.Width) { pictureBoxImage.Left = (panelImageBackground.Width / 2) - (pictureBoxImage.Width / 2); } else { pictureBoxImage.Left = (panelImageBackground.Width / 2) - (pictureBoxImage.Image.Width / 2); } - if (pictureBoxImage.Image.Height > panelImageBackground.Height) { pictureBoxImage.Top = (panelImageBackground.Height / 2) - (pictureBoxImage.Height / 2); } else { pictureBoxImage.Top = (panelImageBackground.Height / 2) - (pictureBoxImage.Image.Height / 2); } - moveable = true; - } - else if (zoom == "Vollbild") - { - pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom; - pictureBoxImage.Size = new Size(panelImageBackground.Width, panelImageBackground.Height); - pictureBoxImage.Top = 0; - pictureBoxImage.Left = 0; - moveable = false; - } - else if (zoom == "Auto") - { - pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom; - if(pictureBoxImage.Image.Width>panelImageBackground.Width || pictureBoxImage.Image.Height>panelImageBackground.Height) - { - pictureBoxImage.Size = new Size(panelImageBackground.Width, panelImageBackground.Height); - pictureBoxImage.Top = 0; - pictureBoxImage.Left = 0; - moveable = false; - } - else + if (zoom == "Original") { + pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom; pictureBoxImage.Size = new Size(pictureBoxImage.Image.Width, pictureBoxImage.Image.Height); if (pictureBoxImage.Image.Width > panelImageBackground.Width) { pictureBoxImage.Left = (panelImageBackground.Width / 2) - (pictureBoxImage.Width / 2); } else { pictureBoxImage.Left = (panelImageBackground.Width / 2) - (pictureBoxImage.Image.Width / 2); } if (pictureBoxImage.Image.Height > panelImageBackground.Height) { pictureBoxImage.Top = (panelImageBackground.Height / 2) - (pictureBoxImage.Height / 2); } else { pictureBoxImage.Top = (panelImageBackground.Height / 2) - (pictureBoxImage.Image.Height / 2); } moveable = true; } - } - else - { - return; - } + else if (zoom == "Vollbild") + { + pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom; + pictureBoxImage.Size = new Size(panelImageBackground.Width, panelImageBackground.Height); + pictureBoxImage.Top = 0; + pictureBoxImage.Left = 0; + moveable = false; + } + else if (zoom == "Auto") + { + pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom; + if (pictureBoxImage.Image.Width > panelImageBackground.Width || pictureBoxImage.Image.Height > panelImageBackground.Height) + { + pictureBoxImage.Size = new Size(panelImageBackground.Width, panelImageBackground.Height); + pictureBoxImage.Top = 0; + pictureBoxImage.Left = 0; + moveable = false; + } + else + { + pictureBoxImage.Size = new Size(pictureBoxImage.Image.Width, pictureBoxImage.Image.Height); + if (pictureBoxImage.Image.Width > panelImageBackground.Width) { pictureBoxImage.Left = (panelImageBackground.Width / 2) - (pictureBoxImage.Width / 2); } else { pictureBoxImage.Left = (panelImageBackground.Width / 2) - (pictureBoxImage.Image.Width / 2); } + if (pictureBoxImage.Image.Height > panelImageBackground.Height) { pictureBoxImage.Top = (panelImageBackground.Height / 2) - (pictureBoxImage.Height / 2); } else { pictureBoxImage.Top = (panelImageBackground.Height / 2) - (pictureBoxImage.Image.Height / 2); } + moveable = true; + } + } + else + { + return; + } - xFaktor = pictureBoxImage.Width / (double)pictureBoxImage.Image.Width; - yFaktor = pictureBoxImage.Height / (double)pictureBoxImage.Image.Height; - labelZoom2.Text = "x" + Math.Round(yFaktor, 1); + if (pictureBoxImage.Image != null) + { + xFaktor = pictureBoxImage.Width / (double)pictureBoxImage.Image.Width; + yFaktor = pictureBoxImage.Height / (double)pictureBoxImage.Image.Height; + labelZoom2.Text = "x" + Math.Round(yFaktor, 1); + } + else + { + labelZoom2.Text = "x?"; + } + } } /// @@ -1780,7 +1793,7 @@ namespace Mk0.Software.ImageSorter Properties.Settings.Default.zoom = comboBoxZoom.SelectedIndex; Properties.Settings.Default.Save(); - if(pictureBoxImage.Image != null) + if (pictureBoxImage.Image != null) { Zoom(); }