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;
@ -1095,6 +1098,8 @@ namespace Mk0.Software.ImageSorter
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
private void Zoom() private void Zoom()
{
if (!blockZoom)
{ {
string zoom = comboBoxZoom.SelectedItem.ToString(); string zoom = comboBoxZoom.SelectedItem.ToString();
@ -1117,7 +1122,7 @@ namespace Mk0.Software.ImageSorter
else if (zoom == "Auto") else if (zoom == "Auto")
{ {
pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom; pictureBoxImage.SizeMode = PictureBoxSizeMode.Zoom;
if(pictureBoxImage.Image.Width>panelImageBackground.Width || pictureBoxImage.Image.Height>panelImageBackground.Height) if (pictureBoxImage.Image.Width > panelImageBackground.Width || pictureBoxImage.Image.Height > panelImageBackground.Height)
{ {
pictureBoxImage.Size = new Size(panelImageBackground.Width, panelImageBackground.Height); pictureBoxImage.Size = new Size(panelImageBackground.Width, panelImageBackground.Height);
pictureBoxImage.Top = 0; pictureBoxImage.Top = 0;
@ -1137,10 +1142,18 @@ namespace Mk0.Software.ImageSorter
return; return;
} }
if (pictureBoxImage.Image != null)
{
xFaktor = pictureBoxImage.Width / (double)pictureBoxImage.Image.Width; xFaktor = pictureBoxImage.Width / (double)pictureBoxImage.Image.Width;
yFaktor = pictureBoxImage.Height / (double)pictureBoxImage.Image.Height; yFaktor = pictureBoxImage.Height / (double)pictureBoxImage.Image.Height;
labelZoom2.Text = "x" + Math.Round(yFaktor, 1); labelZoom2.Text = "x" + Math.Round(yFaktor, 1);
} }
else
{
labelZoom2.Text = "x?";
}
}
}
/// <summary> /// <summary>
/// Mausklicks in picturebox verwalten /// Mausklicks in picturebox verwalten
@ -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();
} }