public void UploadImages(StringCollection files)
{
if (files.Count == 0)
return;
Icon defIcon = (Icon)Tray.Icon.Clone();
Tray.Icon = new Icon("Addons/Imgur/Icon.ico");
string finalCopy = "";
foreach (string file in files) {
if (!(file.EndsWith(".png") || file.EndsWith(".jpg") || file.EndsWith(".gif")))
continue;
Image img = Image.FromFile(file);
MemoryStream ms = new MemoryStream(File.ReadAllBytes(file));
string url = this.UploadToImgur(ms, img.Width, img.Height);
img.Dispose();
if (url == "CANCELED") {
finalCopy = "CANCELED";
break;
}
if (url != "") {
finalCopy += url + "\n";
}
}
if (finalCopy != "CANCELED") {
if (finalCopy != "") {
this.SetClipboardText(finalCopy.Substring(0, finalCopy.Length - 1));
Tray.ShowBalloonTip(1000, "Upload success!", "Image(s) uploaded to Imgur and URL(s) copied to clipboard.", ToolTipIcon.Info);
} else {
this.ProgressBar.Done();
Tray.ShowBalloonTip(1000, "Upload failed!", "You didn't copy any images, or the image format is not supported.", ToolTipIcon.Error);
}
}
Tray.Icon = defIcon;
}