implemented enhanced keyboard control #22

implemented adjustment of possible worst duplicate #21
This commit is contained in:
Manuel Kamper 2022-10-31 19:39:12 +01:00
parent 7b74eca31b
commit 73dec49ac7
2 changed files with 91 additions and 23 deletions

View File

@ -41,10 +41,10 @@ namespace Mk0.Software.Bildduplikate
this.label3 = new System.Windows.Forms.Label();
this.buttonReload = new System.Windows.Forms.Button();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.buttonAPISetting = new System.Windows.Forms.Button();
this.buttonAPILoad = new System.Windows.Forms.Button();
this.richTextBoxDesc1 = new System.Windows.Forms.RichTextBox();
this.richTextBoxDesc2 = new System.Windows.Forms.RichTextBox();
this.buttonAPISetting = new System.Windows.Forms.Button();
this.buttonAPILoad = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@ -191,26 +191,6 @@ namespace Mk0.Software.Bildduplikate
this.splitContainer2.TabIndex = 12;
this.splitContainer2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
//
// buttonAPISetting
//
this.buttonAPISetting.Location = new System.Drawing.Point(174, 12);
this.buttonAPISetting.Name = "buttonAPISetting";
this.buttonAPISetting.Size = new System.Drawing.Size(75, 23);
this.buttonAPISetting.TabIndex = 13;
this.buttonAPISetting.Text = "API Setting";
this.buttonAPISetting.UseVisualStyleBackColor = true;
this.buttonAPISetting.Click += new System.EventHandler(this.ButtonAPI_Click);
//
// buttonAPILoad
//
this.buttonAPILoad.Location = new System.Drawing.Point(255, 12);
this.buttonAPILoad.Name = "buttonAPILoad";
this.buttonAPILoad.Size = new System.Drawing.Size(75, 23);
this.buttonAPILoad.TabIndex = 14;
this.buttonAPILoad.Text = "Load API";
this.buttonAPILoad.UseVisualStyleBackColor = true;
this.buttonAPILoad.Click += new System.EventHandler(this.ButtonAPILoad_Click);
//
// richTextBoxDesc1
//
this.richTextBoxDesc1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -242,6 +222,26 @@ namespace Mk0.Software.Bildduplikate
this.richTextBoxDesc2.Text = "";
this.richTextBoxDesc2.Visible = false;
//
// buttonAPISetting
//
this.buttonAPISetting.Location = new System.Drawing.Point(174, 12);
this.buttonAPISetting.Name = "buttonAPISetting";
this.buttonAPISetting.Size = new System.Drawing.Size(75, 23);
this.buttonAPISetting.TabIndex = 13;
this.buttonAPISetting.Text = "API Setting";
this.buttonAPISetting.UseVisualStyleBackColor = true;
this.buttonAPISetting.Click += new System.EventHandler(this.ButtonAPI_Click);
//
// buttonAPILoad
//
this.buttonAPILoad.Location = new System.Drawing.Point(255, 12);
this.buttonAPILoad.Name = "buttonAPILoad";
this.buttonAPILoad.Size = new System.Drawing.Size(75, 23);
this.buttonAPILoad.TabIndex = 14;
this.buttonAPILoad.Text = "Load API";
this.buttonAPILoad.UseVisualStyleBackColor = true;
this.buttonAPILoad.Click += new System.EventHandler(this.ButtonAPILoad_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -17,6 +17,7 @@ namespace Mk0.Software.Bildduplikate
private int line = 0, total = 0, offset = 0;
private string file;
private bool api = false;
private int worst = 0;
private List<Duplicate> duplicates = new List<Duplicate>();
@ -140,6 +141,39 @@ namespace Mk0.Software.Bildduplikate
dup1++;
dup2++;
}
else
{
if (fileName1.Count(Char.IsDigit) < fileName2.Count(Char.IsDigit))
{
fileName1 = @"\b " + GetRtfUnicodeEscapedString(fileName1) + @" \b0 ";
fileName2 = GetRtfUnicodeEscapedString(fileName2);
dup1++;
}
else if(fileName2.Count(Char.IsDigit) < fileName1.Count(Char.IsDigit))
{
fileName1 = GetRtfUnicodeEscapedString(fileName1);
fileName2 = @"\b " + GetRtfUnicodeEscapedString(fileName2) + @" \b0 ";
dup2++;
}
else
{
if (fileName1.Length > fileName2.Length)
{
fileName1 = GetRtfUnicodeEscapedString(fileName1);
fileName2 = @"\b " + GetRtfUnicodeEscapedString(fileName2) + @" \b0 ";
dup2++;
}
else if (fileName2.Length > fileName1.Length)
{
fileName1 = @"\b " + GetRtfUnicodeEscapedString(fileName1) + @" \b0 ";
fileName2 = GetRtfUnicodeEscapedString(fileName2);
dup1++;
}
else
{
}
}
}
DateTime lastTime1 = f1.LastWriteTime;
DateTime lastTime2 = f2.LastWriteTime;
@ -283,16 +317,19 @@ namespace Mk0.Software.Bildduplikate
{
buttonDel1.Font = new Font(buttonDel1.Font.Name, buttonDel1.Font.Size, FontStyle.Bold);
buttonDel2.Font = new Font(buttonDel2.Font.Name, buttonDel2.Font.Size, FontStyle.Regular);
worst = 1;
}
else if (dup2 < dup1)
{
buttonDel1.Font = new Font(buttonDel1.Font.Name, buttonDel1.Font.Size, FontStyle.Regular);
buttonDel2.Font = new Font(buttonDel2.Font.Name, buttonDel2.Font.Size, FontStyle.Bold);
worst = 2;
}
else
{
buttonDel1.Font = new Font(buttonDel1.Font.Name, buttonDel1.Font.Size, FontStyle.Regular);
buttonDel2.Font = new Font(buttonDel2.Font.Name, buttonDel2.Font.Size, FontStyle.Regular);
worst = 0;
}
}
@ -497,7 +534,7 @@ namespace Mk0.Software.Bildduplikate
{
ButtonDel2_Click(sender, e);
}
else if (e.KeyCode == Keys.D0 || e.KeyCode == Keys.NumPad0)
else if (e.KeyCode == Keys.D0 || e.KeyCode == Keys.NumPad0 || e.KeyCode == Keys.K)
{
ButtonKeinDuplikat_Click(sender, e);
}
@ -505,6 +542,37 @@ namespace Mk0.Software.Bildduplikate
{
ButtonReload_Click(sender, e);
}
else if (e.KeyCode == Keys.D)
{
DeleteWorstDuplicate();
}
else if (e.KeyCode == Keys.A)
{
ButtonAPI_Click(sender, e);
}
else if (e.KeyCode==Keys.C)
{
ButtonCSV_Click(sender, e);
}
}
/// <summary>
/// Deletes the most probably worst duplicate
/// </summary>
private void DeleteWorstDuplicate()
{
if (worst == 1)
{
ButtonDel1_Click(null, null);
}
else if (worst == 2)
{
ButtonDel2_Click(null, null);
}
else
{
MessageBox.Show("Ooops...", "Keines der beiden Bilder konnte als besser oder schlechter erkannt werden, bitte wählen sie selbst!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
/// <summary>