From 368831e2bcb53d50c710725c2020274316fedc1e Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Mon, 24 Oct 2022 12:44:10 +0200 Subject: [PATCH] fix #1 --- Mk0.Software.Bildduplikate/Form1.Designer.cs | 70 ++++++++++++---- Mk0.Software.Bildduplikate/Form1.cs | 79 ++++++++++++------- .../Mk0.Software.Bildduplikate.csproj | 43 +++++++++- .../Properties/AssemblyInfo.cs | 12 +-- 4 files changed, 152 insertions(+), 52 deletions(-) diff --git a/Mk0.Software.Bildduplikate/Form1.Designer.cs b/Mk0.Software.Bildduplikate/Form1.Designer.cs index 5d2f6f7..dba0206 100644 --- a/Mk0.Software.Bildduplikate/Form1.Designer.cs +++ b/Mk0.Software.Bildduplikate/Form1.Designer.cs @@ -40,12 +40,18 @@ namespace Mk0.Software.Bildduplikate this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.label3 = new System.Windows.Forms.Label(); + this.buttonReload = new System.Windows.Forms.Button(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); this.SuspendLayout(); // // buttonCSV @@ -60,8 +66,8 @@ namespace Mk0.Software.Bildduplikate // // buttonDel1 // - this.buttonDel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonDel1.Location = new System.Drawing.Point(12, 359); + this.buttonDel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDel1.Location = new System.Drawing.Point(313, 3); this.buttonDel1.Name = "buttonDel1"; this.buttonDel1.Size = new System.Drawing.Size(75, 23); this.buttonDel1.TabIndex = 2; @@ -72,8 +78,7 @@ namespace Mk0.Software.Bildduplikate // // buttonDel2 // - this.buttonDel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDel2.Location = new System.Drawing.Point(404, 359); + this.buttonDel2.Location = new System.Drawing.Point(0, 3); this.buttonDel2.Name = "buttonDel2"; this.buttonDel2.Size = new System.Drawing.Size(75, 23); this.buttonDel2.TabIndex = 3; @@ -84,20 +89,19 @@ namespace Mk0.Software.Bildduplikate // // label1 // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 385); + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label1.Location = new System.Drawing.Point(-219, 29); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(35, 13); + this.label1.Size = new System.Drawing.Size(604, 50); this.label1.TabIndex = 4; this.label1.Text = "label1"; + this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight; this.label1.Visible = false; // // label2 // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(401, 385); + this.label2.Location = new System.Drawing.Point(3, 29); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(35, 13); this.label2.TabIndex = 5; @@ -173,29 +177,61 @@ namespace Mk0.Software.Bildduplikate this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight; this.label3.Visible = false; // + // buttonReload + // + this.buttonReload.Location = new System.Drawing.Point(93, 12); + this.buttonReload.Name = "buttonReload"; + this.buttonReload.Size = new System.Drawing.Size(75, 23); + this.buttonReload.TabIndex = 11; + this.buttonReload.Text = "reload"; + this.buttonReload.UseVisualStyleBackColor = true; + this.buttonReload.Click += new System.EventHandler(this.ButtonReload_Click); + // + // splitContainer2 + // + this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.splitContainer2.Location = new System.Drawing.Point(12, 362); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.buttonDel1); + this.splitContainer2.Panel1.Controls.Add(this.label1); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.buttonDel2); + this.splitContainer2.Panel2.Controls.Add(this.label2); + this.splitContainer2.Size = new System.Drawing.Size(775, 81); + this.splitContainer2.SplitterDistance = 388; + this.splitContainer2.TabIndex = 12; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.splitContainer2); + this.Controls.Add(this.buttonReload); this.Controls.Add(this.label3); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.buttonKeinDuplikat); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Controls.Add(this.buttonDel2); - this.Controls.Add(this.buttonDel1); this.Controls.Add(this.buttonCSV); this.Name = "Form1"; - this.Text = "Bildduplikate by kmpr.at"; + this.Text = "Bildduplikate v1.1 by kmpr.at"; ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); this.splitContainer1.ResumeLayout(false); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + this.splitContainer2.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); + this.splitContainer2.ResumeLayout(false); this.ResumeLayout(false); - this.PerformLayout(); } @@ -212,6 +248,8 @@ namespace Mk0.Software.Bildduplikate private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button buttonReload; + private System.Windows.Forms.SplitContainer splitContainer2; } } diff --git a/Mk0.Software.Bildduplikate/Form1.cs b/Mk0.Software.Bildduplikate/Form1.cs index 5511f02..648a8de 100644 --- a/Mk0.Software.Bildduplikate/Form1.cs +++ b/Mk0.Software.Bildduplikate/Form1.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; @@ -14,7 +15,7 @@ namespace Mk0.Software.Bildduplikate private int line = 0, total = 0; private string file; - List duplicates = new List(); + private List duplicates = new List(); public Form1() { @@ -39,7 +40,9 @@ namespace Mk0.Software.Bildduplikate private void LoadCSV(string fileName) { line = 0; + total = 0; file = fileName; + duplicates.Clear(); using (StreamReader reader = new StreamReader(fileName)) { @@ -56,47 +59,59 @@ namespace Mk0.Software.Bildduplikate total = duplicates.Count; LoadDuplicates(line); - - buttonDel1.Visible = true; - buttonDel2.Visible = true; - buttonKeinDuplikat.Visible = true; - pictureBox1.Visible = true; - pictureBox2.Visible = true; - label1.Visible = true; - label2.Visible = true; - label3.Visible = true; } - private void LoadDuplicates(int line) + private void LoadDuplicates(int lineDup) { - if(File.Exists(duplicates.ElementAt(line).Path1) && File.Exists(duplicates.ElementAt(line).Path2)) + if (duplicates.Count > lineDup) { - Image img1 = GetCopyImage(duplicates.ElementAt(line).Path1); - Image img2 = GetCopyImage(duplicates.ElementAt(line).Path2); - pictureBox1.Image = img1; - pictureBox2.Image = img2; - FileInfo f1 = new FileInfo(duplicates.ElementAt(line).Path1); - FileInfo f2 = new FileInfo(duplicates.ElementAt(line).Path2); - label1.Text = Path.GetFileName(duplicates.ElementAt(line).Path1) + Environment.NewLine + FormatSize(f1.Length) + Environment.NewLine + f1.LastWriteTime; - label2.Text = Path.GetFileName(duplicates.ElementAt(line).Path2) + Environment.NewLine + FormatSize(f2.Length) + Environment.NewLine + f2.LastWriteTime; - label3.Text = total + " Duplikate"; + if (File.Exists(duplicates.ElementAt(lineDup).Path1) && File.Exists(duplicates.ElementAt(lineDup).Path2)) + { + Image img1 = GetCopyImage(duplicates.ElementAt(lineDup).Path1); + Image img2 = GetCopyImage(duplicates.ElementAt(lineDup).Path2); + pictureBox1.Image = img1; + pictureBox2.Image = img2; + FileInfo f1 = new FileInfo(duplicates.ElementAt(lineDup).Path1); + FileInfo f2 = new FileInfo(duplicates.ElementAt(lineDup).Path2); + label1.Text = Path.GetFileName(duplicates.ElementAt(lineDup).Path1) + Environment.NewLine + FormatSize(f1.Length) + Environment.NewLine + f1.LastWriteTime; + label2.Text = Path.GetFileName(duplicates.ElementAt(lineDup).Path2) + Environment.NewLine + FormatSize(f2.Length) + Environment.NewLine + f2.LastWriteTime; + label3.Text = total + " Duplikate"; + UIElementsVisible(true); + } + else + { + File_DeleteLine(lineDup); + total--; + line++; + LoadDuplicates(line); + } } else { - File_DeleteLine(line); - total--; - line++; - LoadDuplicates(line); + MessageBox.Show("Alle Duplikate in CSV abgearbeitet", "Fertig!", MessageBoxButtons.OK, MessageBoxIcon.Information); + UIElementsVisible(false); } } + private void UIElementsVisible(bool vis) + { + label1.Visible = vis; + label2.Visible = vis; + label3.Visible = vis; + buttonDel1.Visible = vis; + buttonDel2.Visible = vis; + buttonKeinDuplikat.Visible = vis; + pictureBox1.Visible = vis; + pictureBox2.Visible = vis; + } + private string FormatSize(long length) { int counter = 0; decimal number = (decimal)length; while (Math.Round(number / 1024) >= 1) { - number = number / 1024; + number /= 1024; counter++; } return string.Format("{0:n1}{1}", number, suffixes[counter]); @@ -137,9 +152,14 @@ namespace Mk0.Software.Bildduplikate } } - private void File_DeleteLine(int line) + private void ButtonReload_Click(object sender, EventArgs e) { - line = line + 1; + LoadDuplicates(line); + } + + private void File_DeleteLine(int lineFile) + { + lineFile++; StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader(file)) { @@ -147,7 +167,7 @@ namespace Mk0.Software.Bildduplikate while (!sr.EndOfStream) { Countup++; - if (Countup != line) + if (Countup != lineFile) { using (StringWriter sw = new StringWriter(sb)) { @@ -164,6 +184,7 @@ namespace Mk0.Software.Bildduplikate { sw.Write(sb.ToString()); } + Debug.Print("lösche Zeile " + lineFile); } } } diff --git a/Mk0.Software.Bildduplikate/Mk0.Software.Bildduplikate.csproj b/Mk0.Software.Bildduplikate/Mk0.Software.Bildduplikate.csproj index 5d9c95e..60da468 100644 --- a/Mk0.Software.Bildduplikate/Mk0.Software.Bildduplikate.csproj +++ b/Mk0.Software.Bildduplikate/Mk0.Software.Bildduplikate.csproj @@ -7,11 +7,27 @@ {2DBB67D4-1312-4FCF-BA49-0A856A3EE544} WinExe Mk0.Software.Bildduplikate - Mk0.Software.Bildduplikate + Bildduplikate v4.8 512 true true + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 1 + 1.0.0.%2a + false + true + true AnyCPU @@ -32,6 +48,18 @@ prompt 4 + + 6BCF527F7020A7756FB1D5660249CDEFD0DA95A2 + + + Mk0.Software.Bildduplikate_TemporaryKey.pfx + + + true + + + true + @@ -67,6 +95,7 @@ True Resources.resx + SettingsSingleFileGenerator Settings.Designer.cs @@ -80,5 +109,17 @@ + + + False + Microsoft .NET Framework 4.8 %28x86 und x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/Mk0.Software.Bildduplikate/Properties/AssemblyInfo.cs b/Mk0.Software.Bildduplikate/Properties/AssemblyInfo.cs index 4e376d1..ac679d1 100644 --- a/Mk0.Software.Bildduplikate/Properties/AssemblyInfo.cs +++ b/Mk0.Software.Bildduplikate/Properties/AssemblyInfo.cs @@ -5,13 +5,13 @@ using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // die einer Assembly zugeordnet sind. -[assembly: AssemblyTitle("Mk0.Software.Bildduplikate")] +[assembly: AssemblyTitle("Bildduplikate")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] +[assembly: AssemblyCompany("kmpr.at")] [assembly: AssemblyProduct("Mk0.Software.Bildduplikate")] -[assembly: AssemblyCopyright("Copyright © 2022")] -[assembly: AssemblyTrademark("")] +[assembly: AssemblyCopyright("Copyright © 2022 kmpr.at")] +[assembly: AssemblyTrademark("kmpr.at")] [assembly: AssemblyCulture("")] // Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")]