From 861174edcd1aecaa18d3f7907e551c54ff660e20 Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Fri, 11 Aug 2023 10:30:48 +0200 Subject: [PATCH] implemented #6 --- Mk0.Software.ImageSorter/Main.Designer.cs | 12 +- Mk0.Software.ImageSorter/Main.cs | 138 ++++++++++++++---- .../Mk0.Software.ImageSorter.csproj | 2 +- .../Properties/AssemblyInfo.cs | 2 +- 4 files changed, 114 insertions(+), 40 deletions(-) diff --git a/Mk0.Software.ImageSorter/Main.Designer.cs b/Mk0.Software.ImageSorter/Main.Designer.cs index a8256cc..e017e72 100644 --- a/Mk0.Software.ImageSorter/Main.Designer.cs +++ b/Mk0.Software.ImageSorter/Main.Designer.cs @@ -491,7 +491,7 @@ this.groupBoxRander.Controls.Add(this.buttonRandOben); this.groupBoxRander.Location = new System.Drawing.Point(161, 397); this.groupBoxRander.Name = "groupBoxRander"; - this.groupBoxRander.Size = new System.Drawing.Size(125, 136); + this.groupBoxRander.Size = new System.Drawing.Size(123, 136); this.groupBoxRander.TabIndex = 18; this.groupBoxRander.TabStop = false; this.groupBoxRander.Text = "Ränder schneiden"; @@ -504,7 +504,7 @@ this.buttonRandAlle.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRandAlle.FlatAppearance.BorderColor = System.Drawing.Color.Silver; this.buttonRandAlle.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.buttonRandAlle.Location = new System.Drawing.Point(64, 102); + this.buttonRandAlle.Location = new System.Drawing.Point(76, 102); this.buttonRandAlle.Name = "buttonRandAlle"; this.buttonRandAlle.Size = new System.Drawing.Size(23, 23); this.buttonRandAlle.TabIndex = 16; @@ -519,7 +519,7 @@ this.buttonRandObenUnten.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRandObenUnten.FlatAppearance.BorderColor = System.Drawing.Color.Silver; this.buttonRandObenUnten.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.buttonRandObenUnten.Location = new System.Drawing.Point(35, 102); + this.buttonRandObenUnten.Location = new System.Drawing.Point(47, 102); this.buttonRandObenUnten.Name = "buttonRandObenUnten"; this.buttonRandObenUnten.Size = new System.Drawing.Size(23, 23); this.buttonRandObenUnten.TabIndex = 15; @@ -534,7 +534,7 @@ this.buttonRandLinksRechts.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRandLinksRechts.FlatAppearance.BorderColor = System.Drawing.Color.Silver; this.buttonRandLinksRechts.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.buttonRandLinksRechts.Location = new System.Drawing.Point(6, 102); + this.buttonRandLinksRechts.Location = new System.Drawing.Point(18, 102); this.buttonRandLinksRechts.Name = "buttonRandLinksRechts"; this.buttonRandLinksRechts.Size = new System.Drawing.Size(23, 23); this.buttonRandLinksRechts.TabIndex = 14; @@ -738,7 +738,7 @@ this.groupBoxTransformation.Controls.Add(this.buttonMirrorHorizontal); this.groupBoxTransformation.Location = new System.Drawing.Point(46, 445); this.groupBoxTransformation.Name = "groupBoxTransformation"; - this.groupBoxTransformation.Size = new System.Drawing.Size(109, 88); + this.groupBoxTransformation.Size = new System.Drawing.Size(99, 88); this.groupBoxTransformation.TabIndex = 17; this.groupBoxTransformation.TabStop = false; this.groupBoxTransformation.Text = "Transformation"; @@ -871,7 +871,7 @@ this.KeyPreview = true; this.MinimumSize = new System.Drawing.Size(983, 605); this.Name = "Main"; - this.Text = "Image Sorter v2.5 | © 2015-2023 by kmpr.at"; + this.Text = "Image Sorter v2.6 | © 2015-2023 by kmpr.at"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing); this.Load += new System.EventHandler(this.Main_Load); this.Shown += new System.EventHandler(this.Main_Shown); diff --git a/Mk0.Software.ImageSorter/Main.cs b/Mk0.Software.ImageSorter/Main.cs index 758dd4d..a1cb4d9 100644 --- a/Mk0.Software.ImageSorter/Main.cs +++ b/Mk0.Software.ImageSorter/Main.cs @@ -17,6 +17,7 @@ using System.Threading; using System.Windows.Forms; using Mk0.Software.OnlineUpdater; using System.Threading.Tasks; +using System.Reflection; namespace Mk0.Software.ImageSorter { @@ -865,7 +866,7 @@ namespace Mk0.Software.ImageSorter CountPicsInPath(); LoadPicture(imageIndex); CheckUndo(); - ShowPreviewImages(); + ShowPreviewImages(false, true); if (Properties.Settings.Default.fading) { @@ -970,7 +971,7 @@ namespace Mk0.Software.ImageSorter CountPicsInPath(); LoadPicture(imageIndex); CheckUndo(); - ShowPreviewImages(); + ShowPreviewImages(true); } /// @@ -1072,7 +1073,7 @@ namespace Mk0.Software.ImageSorter CountPicsInPath(); LoadPicture(imageIndex); ShowDeletedMessage(myImg, pfad); - ShowPreviewImages(); + ShowPreviewImages(false, true); } /// @@ -1769,7 +1770,7 @@ namespace Mk0.Software.ImageSorter CountPicsInPath(); LoadPicture(imageIndex - 1); CheckUndo(); - ShowPreviewImages(); + ShowPreviewImages(true); } /// @@ -1782,7 +1783,7 @@ namespace Mk0.Software.ImageSorter CountPicsInPath(); LoadPicture(imageIndex + 1); CheckUndo(); - ShowPreviewImages(); + ShowPreviewImages(false, true); } /// @@ -1827,7 +1828,7 @@ namespace Mk0.Software.ImageSorter Image myImg = CopyImage.GetCopyImage(targetPath); ShowDuplicatedMessage(myImg, targetPath); - ShowPreviewImages(); + ShowPreviewImages(true); } /// @@ -2008,11 +2009,10 @@ namespace Mk0.Software.ImageSorter /// /// Bildvorschau erzeugen und laden /// - private void ShowPreviewImages() + private void ShowPreviewImages(bool left = false, bool right = false) { try { - panelPreview.Controls.Clear(); int panelWidthAvailable = panelPreview.Width - 11; //verfügbare breite abzüglich ränder links+rechts int previewImageWidth = 80; //breite eines preview-bildes int previewImageAbstand = 11; //abstand zwischen preview-bildern @@ -2020,44 +2020,118 @@ namespace Mk0.Software.ImageSorter int previewNumber = panelWidthAvailable / previewBildmitAbstand; //anzahl der möglichen preview-bilder int bildAbstand = (panelPreview.Width - 22 - (previewNumber * previewImageWidth)) / previewNumber; //errechneter Bildabstand für bessere verteilung - for (int i = 1; i <= previewNumber; i++) + if (left) { - int moveNext = (i * previewImageWidth) + (bildAbstand * i) - 80; - PictureBox pb = new PictureBox + //links neues bild laden + //rechte pb entfernen + panelPreview.Controls.Remove(panelPreview.Controls.OfType().Last()); + int newPbX = panelPreview.Controls.OfType().First().Location.X; + //alle nach rechts verschieben + foreach (PictureBox pb in panelPreview.Controls.OfType()) + { + pb.Location = new Point(pb.Location.X + bildAbstand + previewImageWidth, pb.Location.Y); + } + //links neue pb erstellen + int pIndex = imageIndex; + pIndex += 1; + if (pIndex >= images.Count() || pIndex < 0) + { + pIndex = 0; + } + PictureBox pbn = new PictureBox { Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left, - BackgroundImage = Resources.no_picture, BackgroundImageLayout = ImageLayout.Stretch, BorderStyle = BorderStyle.None, - Location = new Point(moveNext, previewImageAbstand), - Name = "pictureBoxPreview" + i, + Location = new Point(newPbX, previewImageAbstand), Size = new Size(previewImageWidth, previewImageWidth), TabIndex = 0, TabStop = false, - SizeMode = PictureBoxSizeMode.Zoom + SizeMode = PictureBoxSizeMode.Zoom, + ImageLocation = images.ElementAt(pIndex), + Tag = pIndex }; - panelPreview.Controls.Add(pb); + panelPreview.SuspendLayout(); + panelPreview.Controls.Add(pbn); + panelPreview.Controls.SetChildIndex(pbn, 0); + panelPreview.ResumeLayout(); + pbn.Click += new EventHandler(LoadPictureFromPreview_Click); } - - int pIndex = imageIndex; - foreach (PictureBox pb in panelPreview.Controls.OfType()) + else if (right) { - //preview laden - if (images.Count() > pIndex) + //rechts neues bild laden + //linke pb entfernen + panelPreview.Controls.Remove(panelPreview.Controls.OfType().First()); + int newPbX = panelPreview.Controls.OfType().Last().Location.X; + //alle nach links verschieben + foreach (PictureBox pb in panelPreview.Controls.OfType()) { - pIndex += 1; - if (pIndex >= images.Count() || pIndex < 0) - { - pIndex = 0; - } - pb.ImageLocation = images.ElementAt(pIndex); - pb.BackgroundImage = null; - pb.Tag = pIndex; - pb.Click += new System.EventHandler(this.LoadPictureFromPreview_Click); + pb.Location = new Point(pb.Location.X - bildAbstand - previewImageWidth, pb.Location.Y); } - else + //rechts neue pb erstellen + int pIndex = imageIndex; + pIndex += previewNumber; + if (pIndex >= images.Count() || pIndex < 0) { - pb.BackgroundImage = Resources.no_picture; + pIndex = 0; + } + PictureBox pbn = new PictureBox + { + Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left, + BackgroundImageLayout = ImageLayout.Stretch, + BorderStyle = BorderStyle.None, + Location = new Point(newPbX, previewImageAbstand), + Size = new Size(previewImageWidth, previewImageWidth), + TabIndex = 0, + TabStop = false, + SizeMode = PictureBoxSizeMode.Zoom, + ImageLocation = images.ElementAt(pIndex), + Tag = pIndex + }; + panelPreview.Controls.Add(pbn); + pbn.Click += new EventHandler(LoadPictureFromPreview_Click); + } + else + { + panelPreview.Controls.Clear(); + for (int i = 1; i <= previewNumber; i++) + { + int moveNext = (i * previewImageWidth) + (bildAbstand * i) - 80; + PictureBox pb = new PictureBox + { + Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left, + BackgroundImage = Resources.no_picture, + BackgroundImageLayout = ImageLayout.Stretch, + BorderStyle = BorderStyle.None, + Location = new Point(moveNext, previewImageAbstand), + Name = "pictureBoxPreview" + i, + Size = new Size(previewImageWidth, previewImageWidth), + TabIndex = 0, + TabStop = false, + SizeMode = PictureBoxSizeMode.Zoom + }; + panelPreview.Controls.Add(pb); + } + int pIndex = imageIndex; + foreach (PictureBox pb in panelPreview.Controls.OfType()) + { + //preview laden + if (images.Count() > pIndex) + { + pIndex += 1; + if (pIndex >= images.Count() || pIndex < 0) + { + pIndex = 0; + } + pb.ImageLocation = images.ElementAt(pIndex); + pb.BackgroundImage = null; + pb.Tag = pIndex; + pb.Click += new EventHandler(LoadPictureFromPreview_Click); + } + else + { + pb.BackgroundImage = Resources.no_picture; + } } } } diff --git a/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj b/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj index 4143573..f952875 100644 --- a/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj +++ b/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj @@ -33,7 +33,7 @@ manuelkamper.com false 0 - 2.5.0.0 + 2.6.0.0 true true true diff --git a/Mk0.Software.ImageSorter/Properties/AssemblyInfo.cs b/Mk0.Software.ImageSorter/Properties/AssemblyInfo.cs index 01a9485..54fdd50 100644 --- a/Mk0.Software.ImageSorter/Properties/AssemblyInfo.cs +++ b/Mk0.Software.ImageSorter/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.5.*")] +[assembly: AssemblyVersion("2.6.*")] //[assembly: AssemblyFileVersion("1.6.0.0")]