Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Manuel Kamper | 6f1e371d33 | |
Manuel Kamper | be84e1e144 | |
Manuel Kamper | 33941b3518 |
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Mk0.Software.Bildduplikate
|
||||
|
@ -17,12 +18,37 @@ namespace Mk0.Software.Bildduplikate
|
|||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
Properties.Settings.Default.ApiUrl = textBoxApiUrl.Text.Trim();
|
||||
Properties.Settings.Default.ReplacePath = textBoxPath1.Text.Trim();
|
||||
Properties.Settings.Default.ReplaceWith = textBoxPath2.Text.Trim();
|
||||
Properties.Settings.Default.imagesFromAPI = (int)numericUpDown1.Value;
|
||||
Properties.Settings.Default.autoload = checkBoxAutoLoad.Checked;
|
||||
Properties.Settings.Default.Save();
|
||||
if (!CheckWebsite(textBoxApiUrl.Text.Trim() + "?test"))
|
||||
{
|
||||
MessageBox.Show("The URL of the API is not valid!" + Environment.NewLine + "Settings not saved!", "No valid API", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
Properties.Settings.Default.ApiUrl = textBoxApiUrl.Text.Trim();
|
||||
Properties.Settings.Default.ReplacePath = textBoxPath1.Text.Trim();
|
||||
Properties.Settings.Default.ReplaceWith = textBoxPath2.Text.Trim();
|
||||
Properties.Settings.Default.imagesFromAPI = (int)numericUpDown1.Value;
|
||||
Properties.Settings.Default.autoload = checkBoxAutoLoad.Checked;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckWebsite(string URL)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebClient wc = new WebClient();
|
||||
string HTMLSource = wc.DownloadString(URL);
|
||||
if (HTMLSource.Contains("API is working properly"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,6 +241,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
this.buttonAPILoad.TabIndex = 14;
|
||||
this.buttonAPILoad.Text = "Load API";
|
||||
this.buttonAPILoad.UseVisualStyleBackColor = true;
|
||||
this.buttonAPILoad.Visible = false;
|
||||
this.buttonAPILoad.Click += new System.EventHandler(this.ButtonAPILoad_Click);
|
||||
//
|
||||
// buttonUndo
|
||||
|
@ -252,6 +253,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
this.buttonUndo.TabIndex = 15;
|
||||
this.buttonUndo.Text = "undo";
|
||||
this.buttonUndo.UseVisualStyleBackColor = true;
|
||||
this.buttonUndo.Visible = false;
|
||||
this.buttonUndo.Click += new System.EventHandler(this.ButtonUndo_Click);
|
||||
//
|
||||
// Main
|
||||
|
@ -273,7 +275,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
this.MinimumSize = new System.Drawing.Size(1000, 590);
|
||||
this.Name = "Main";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Bildduplikate v1.8 by kmpr.at";
|
||||
this.Text = "Bildduplikate v1.10 by kmpr.at";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing);
|
||||
this.Shown += new System.EventHandler(this.Main_Shown);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
|
||||
|
|
|
@ -101,8 +101,8 @@ namespace Mk0.Software.Bildduplikate
|
|||
string size1, size2;
|
||||
if (f1.Length == f2.Length)
|
||||
{
|
||||
size1 = @"\b " + FormatSize(f1.Length) + @" \b0 ";
|
||||
size2 = @"\b " + FormatSize(f2.Length) + @" \b0 ";
|
||||
size1 = @" \b " + FormatSize(f1.Length) + @" \b0 ";
|
||||
size2 = @" \b " + FormatSize(f2.Length) + @" \b0 ";
|
||||
dup1++;
|
||||
dup1++;
|
||||
dup2++;
|
||||
|
@ -110,7 +110,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
}
|
||||
else if (f1.Length > f2.Length)
|
||||
{
|
||||
size1 = @"\b " + FormatSize(f1.Length) + @" \b0 ";
|
||||
size1 = @" \b " + FormatSize(f1.Length) + @" \b0 ";
|
||||
size2 = FormatSize(f2.Length);
|
||||
dup1++;
|
||||
dup1++;
|
||||
|
@ -118,7 +118,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
else
|
||||
{
|
||||
size1 = FormatSize(f1.Length);
|
||||
size2 = @"\b " + FormatSize(f2.Length) + @" \b0 ";
|
||||
size2 = @" \b " + FormatSize(f2.Length) + @" \b0 ";
|
||||
dup2++;
|
||||
dup2++;
|
||||
}
|
||||
|
@ -127,8 +127,8 @@ namespace Mk0.Software.Bildduplikate
|
|||
string filePath2 = GetRtfUnicodeEscapedString(Path.GetDirectoryName(Duplicates.ElementAt(lineDup).Path2));
|
||||
if (filePath1 == filePath2)
|
||||
{
|
||||
filePath1 = @"\b " + filePath1 + @" \b0 ";
|
||||
filePath2 = @"\b " + filePath2 + @" \b0 ";
|
||||
filePath1 = @" \b " + filePath1 + @" \b0 ";
|
||||
filePath2 = @" \b " + filePath2 + @" \b0 ";
|
||||
dup1++;
|
||||
dup2++;
|
||||
}
|
||||
|
@ -137,8 +137,8 @@ namespace Mk0.Software.Bildduplikate
|
|||
string fileName2 = Path.GetFileName(Duplicates.ElementAt(lineDup).Path2);
|
||||
if (fileName1 == fileName2)
|
||||
{
|
||||
fileName1 = @"\b " + GetRtfUnicodeEscapedString(fileName1) + @" \b0 ";
|
||||
fileName2 = @"\b " + GetRtfUnicodeEscapedString(fileName2) + @" \b0 ";
|
||||
fileName1 = @" \b " + GetRtfUnicodeEscapedString(fileName1) + @" \b0 ";
|
||||
fileName2 = @" \b " + GetRtfUnicodeEscapedString(fileName2) + @" \b0 ";
|
||||
dup1++;
|
||||
dup2++;
|
||||
}
|
||||
|
@ -146,14 +146,14 @@ namespace Mk0.Software.Bildduplikate
|
|||
{
|
||||
if (fileName1.Count(Char.IsDigit) < fileName2.Count(Char.IsDigit))
|
||||
{
|
||||
fileName1 = @"\b " + GetRtfUnicodeEscapedString(fileName1) + @" \b0 ";
|
||||
fileName1 = @" \b " + GetRtfUnicodeEscapedString(fileName1) + @" \b0 ";
|
||||
fileName2 = GetRtfUnicodeEscapedString(fileName2);
|
||||
dup1++;
|
||||
}
|
||||
else if(fileName2.Count(Char.IsDigit) < fileName1.Count(Char.IsDigit))
|
||||
else if (fileName2.Count(Char.IsDigit) < fileName1.Count(Char.IsDigit))
|
||||
{
|
||||
fileName1 = GetRtfUnicodeEscapedString(fileName1);
|
||||
fileName2 = @"\b " + GetRtfUnicodeEscapedString(fileName2) + @" \b0 ";
|
||||
fileName2 = @" \b " + GetRtfUnicodeEscapedString(fileName2) + @" \b0 ";
|
||||
dup2++;
|
||||
}
|
||||
else
|
||||
|
@ -161,12 +161,12 @@ namespace Mk0.Software.Bildduplikate
|
|||
if (fileName1.Length > fileName2.Length)
|
||||
{
|
||||
fileName1 = GetRtfUnicodeEscapedString(fileName1);
|
||||
fileName2 = @"\b " + GetRtfUnicodeEscapedString(fileName2) + @" \b0 ";
|
||||
fileName2 = @" \b " + GetRtfUnicodeEscapedString(fileName2) + @" \b0 ";
|
||||
dup2++;
|
||||
}
|
||||
else if (fileName2.Length > fileName1.Length)
|
||||
{
|
||||
fileName1 = @"\b " + GetRtfUnicodeEscapedString(fileName1) + @" \b0 ";
|
||||
fileName1 = @" \b " + GetRtfUnicodeEscapedString(fileName1) + @" \b0 ";
|
||||
fileName2 = GetRtfUnicodeEscapedString(fileName2);
|
||||
dup1++;
|
||||
}
|
||||
|
@ -181,21 +181,21 @@ namespace Mk0.Software.Bildduplikate
|
|||
string lastTime1str, lastTime2str;
|
||||
if (lastTime1 == lastTime2)
|
||||
{
|
||||
lastTime1str = @"\b " + lastTime1.ToString() + @" \b0 ";
|
||||
lastTime2str = @"\b " + lastTime2.ToString() + @" \b0 ";
|
||||
lastTime1str = @" \b " + lastTime1.ToString() + @" \b0 ";
|
||||
lastTime2str = @" \b " + lastTime2.ToString() + @" \b0 ";
|
||||
dup1++;
|
||||
dup2++;
|
||||
}
|
||||
else if (lastTime1 > lastTime2)
|
||||
{
|
||||
lastTime1str = @"\b " + lastTime1.ToString() + @" \b0 ";
|
||||
lastTime1str = @" \b " + lastTime1.ToString() + @" \b0 ";
|
||||
lastTime2str = lastTime2.ToString();
|
||||
dup1++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastTime1str = lastTime1.ToString();
|
||||
lastTime2str = @"\b " + lastTime2.ToString() + @" \b0 ";
|
||||
lastTime2str = @" \b " + lastTime2.ToString() + @" \b0 ";
|
||||
dup2++;
|
||||
}
|
||||
|
||||
|
@ -206,8 +206,8 @@ namespace Mk0.Software.Bildduplikate
|
|||
{
|
||||
if (img1.Height == img2.Height && img1.Width == img2.Width)
|
||||
{
|
||||
res1str = @"\b " + img1.Width + "x" + img1.Height + " @ " + res1 + " DPI" + @" \b0 ";
|
||||
res2str = @"\b " + img2.Width + "x" + img2.Height + " @ " + res2 + " DPI" + @" \b0 ";
|
||||
res1str = @" \b " + img1.Width + "x" + img1.Height + " @ " + res1 + " DPI" + @" \b0 ";
|
||||
res2str = @" \b " + img2.Width + "x" + img2.Height + " @ " + res2 + " DPI" + @" \b0 ";
|
||||
dup1++;
|
||||
dup1++;
|
||||
dup2++;
|
||||
|
@ -215,7 +215,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
}
|
||||
else if (img1.Height > img2.Height && img1.Width > img2.Width)
|
||||
{
|
||||
res1str = @"\b " + img1.Width + "x" + img1.Height + " @ " + res1 + " DPI" + @" \b0 ";
|
||||
res1str = @" \b " + img1.Width + "x" + img1.Height + " @ " + res1 + " DPI" + @" \b0 ";
|
||||
res2str = img2.Width + "x" + img2.Height + " @ " + res2 + " DPI";
|
||||
dup1++;
|
||||
dup1++;
|
||||
|
@ -223,7 +223,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
else if (img2.Height > img1.Height && img2.Width > img1.Width)
|
||||
{
|
||||
res1str = img1.Width + "x" + img1.Height + " @ " + res1 + " DPI";
|
||||
res2str = @"\b " + img2.Width + "x" + img2.Height + " @ " + res2 + " DPI" + @" \b0 ";
|
||||
res2str = @" \b " + img2.Width + "x" + img2.Height + " @ " + res2 + " DPI" + @" \b0 ";
|
||||
dup2++;
|
||||
dup2++;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
}
|
||||
else if (res1 > res2)
|
||||
{
|
||||
res1str = @"\b " + img1.Width + "x" + img1.Height + " @ " + res1 + " DPI" + @" \b0 ";
|
||||
res1str = @" \b " + img1.Width + "x" + img1.Height + " @ " + res1 + " DPI" + @" \b0 ";
|
||||
res2str = img2.Width + "x" + img2.Height + " @ " + res2 + " DPI";
|
||||
dup1++;
|
||||
dup1++;
|
||||
|
@ -243,7 +243,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
else
|
||||
{
|
||||
res1str = img1.Width + "x" + img1.Height + " @ " + res1 + " DPI";
|
||||
res2str = @"\b " + img2.Width + "x" + img2.Height + " @ " + res2 + " DPI" + @" \b0 ";
|
||||
res2str = @" \b " + img2.Width + "x" + img2.Height + " @ " + res2 + " DPI" + @" \b0 ";
|
||||
dup2++;
|
||||
dup2++;
|
||||
}
|
||||
|
@ -293,11 +293,6 @@ namespace Mk0.Software.Bildduplikate
|
|||
if (api)
|
||||
{
|
||||
ButtonAPILoad_Click(null, null);
|
||||
if (Duplicates.Count > lineDup)
|
||||
{
|
||||
UIElementsVisible(false);
|
||||
MessageBox.Show("Alle Duplikate von API abgearbeitet", "Fertig!", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -415,6 +410,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
{
|
||||
MessageBox.Show("Fehler bei der Kommunikation mit der API:" + Environment.NewLine + ex.ToString(), "API Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
buttonUndo.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -450,6 +446,8 @@ namespace Mk0.Software.Bildduplikate
|
|||
LoadDuplicates(line, api);
|
||||
lastStep = 2;
|
||||
}
|
||||
//todo erst einkommentieren, wenn es die möglichkeit gibt, gelöschte wiederherzustellen
|
||||
//buttonUndo.Visible = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -491,6 +489,8 @@ namespace Mk0.Software.Bildduplikate
|
|||
LoadDuplicates(line, api);
|
||||
lastStep = 2;
|
||||
}
|
||||
//todo erst einkommentieren, wenn es die möglichkeit gibt, gelöschte wiederherzustellen
|
||||
//buttonUndo.Visible = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -596,6 +596,18 @@ namespace Mk0.Software.Bildduplikate
|
|||
{
|
||||
API api = new API();
|
||||
api.ShowDialog();
|
||||
if (Properties.Settings.Default.ApiUrl != String.Empty)
|
||||
{
|
||||
buttonAPILoad.Visible = true;
|
||||
if (Properties.Settings.Default.autoload)
|
||||
{
|
||||
ButtonAPILoad_Click(null, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonAPILoad.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -636,7 +648,15 @@ namespace Mk0.Software.Bildduplikate
|
|||
total = int.Parse(resObj2.totalDuplicates);
|
||||
}
|
||||
|
||||
LoadDuplicates(line, true);
|
||||
if (total == 0)
|
||||
{
|
||||
UIElementsVisible(false);
|
||||
MessageBox.Show("Alle Duplikate von API abgearbeitet", "Fertig!", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadDuplicates(line, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -705,9 +725,13 @@ namespace Mk0.Software.Bildduplikate
|
|||
}
|
||||
}
|
||||
|
||||
if (Properties.Settings.Default.autoload && Properties.Settings.Default.ApiUrl != String.Empty)
|
||||
if (Properties.Settings.Default.ApiUrl != String.Empty)
|
||||
{
|
||||
ButtonAPILoad_Click(null, null);
|
||||
buttonAPILoad.Visible = true;
|
||||
if (Properties.Settings.Default.autoload)
|
||||
{
|
||||
ButtonAPILoad_Click(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -725,7 +749,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
{
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
|
||||
string json = webClient.UploadString(Properties.Settings.Default.ApiUrl + "?undoDuplicate", "{\"duplicateId\":" + Duplicates.ElementAt(line-1).ID + "}");
|
||||
string json = webClient.UploadString(Properties.Settings.Default.ApiUrl + "?undoDuplicate", "{\"duplicateId\":" + Duplicates.ElementAt(line - 1).ID + "}");
|
||||
var resObj = new JavaScriptSerializer().Deserialize<APIResponse>(json);
|
||||
if (resObj.response_code != "200") { MessageBox.Show(resObj.response_desc, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); }
|
||||
else
|
||||
|
@ -741,6 +765,7 @@ namespace Mk0.Software.Bildduplikate
|
|||
{
|
||||
MessageBox.Show("Fehler bei der Kommunikation mit der API:" + Environment.NewLine + ex.ToString(), "API Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
buttonUndo.Visible = false;
|
||||
}
|
||||
else if (lastStep == 2)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.8.0.0</ApplicationVersion>
|
||||
<ApplicationVersion>1.10.0.0</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
|
|
|
@ -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.8.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.8.0.0")]
|
||||
[assembly: AssemblyVersion("1.10.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.10.0.0")]
|
||||
|
|
Loading…
Reference in New Issue