fixed #19 and maybe #20

This commit is contained in:
Manuel Kamper 2024-08-18 15:34:44 +02:00
parent 0bbe5f2aa0
commit 339d9e328c

View File

@ -48,16 +48,18 @@ namespace Mk0.Software.ImageSorter
public string[] Args; public string[] Args;
private FormWindowState lastState = FormWindowState.Minimized; private FormWindowState lastState = FormWindowState.Minimized;
private string defaultWindowName; private string defaultWindowName;
private bool blockZoom = false;
public Main() public Main()
{ {
blockZoom = true;
InitializeComponent(); InitializeComponent();
defaultWindowName = Text; defaultWindowName = Text;
banner = new Banner(components, panelBanner, pictureBoxBanner1, pictureBoxBanner2, labelBanner1, labelBanner2); banner = new Banner(components, panelBanner, pictureBoxBanner1, pictureBoxBanner2, labelBanner1, labelBanner2);
pictureBoxImage.Cursor = grabCursor; pictureBoxImage.Cursor = grabCursor;
DoubleBuffered = true; DoubleBuffered = true;
blockZoom = false;
SetDefaultPath(); SetDefaultPath();
comboBoxZoom.SelectedIndex = Properties.Settings.Default.zoom;
//file assoc prüfen und in einstellungen richtig setzen //file assoc prüfen und in einstellungen richtig setzen
if(FileAssociation.Check("Image_Sorter_JPG", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico") && if(FileAssociation.Check("Image_Sorter_JPG", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico") &&
@ -159,6 +161,7 @@ namespace Mk0.Software.ImageSorter
/// <param name="e"></param> /// <param name="e"></param>
private void Main_Shown(object sender, EventArgs e) private void Main_Shown(object sender, EventArgs e)
{ {
comboBoxZoom.SelectedIndex = Properties.Settings.Default.zoom;
if (Properties.Settings.Default.fullScreen) if (Properties.Settings.Default.fullScreen)
{ {
WindowState = FormWindowState.Maximized; WindowState = FormWindowState.Maximized;
@ -1096,50 +1099,60 @@ namespace Mk0.Software.ImageSorter
/// <param name="e"></param> /// <param name="e"></param>
private void Zoom() private void Zoom()
{ {
string zoom = comboBoxZoom.SelectedItem.ToString(); if (!blockZoom)
{
string zoom = comboBoxZoom.SelectedItem.ToString();
if (zoom == "Original") 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
{ {
pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom;
pictureBoxImage.Size = new Size(pictureBoxImage.Image.Width, pictureBoxImage.Image.Height); 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.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); } 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; moveable = true;
} }
} else if (zoom == "Vollbild")
else {
{ pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom;
return; 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; if (pictureBoxImage.Image != null)
yFaktor = pictureBoxImage.Height / (double)pictureBoxImage.Image.Height; {
labelZoom2.Text = "x" + Math.Round(yFaktor, 1); 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?";
}
}
} }
/// <summary> /// <summary>
@ -1780,7 +1793,7 @@ namespace Mk0.Software.ImageSorter
Properties.Settings.Default.zoom = comboBoxZoom.SelectedIndex; Properties.Settings.Default.zoom = comboBoxZoom.SelectedIndex;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
if(pictureBoxImage.Image != null) if (pictureBoxImage.Image != null)
{ {
Zoom(); Zoom();
} }