public async void SelectUploadImages()
        {
            var dlg = new OpenFileDialog
            {
                DefaultExt       = ".jpg",
                InitialDirectory = AppDomain.CurrentDomain.BaseDirectory,
                Filter           = "Images (.jpg)|*.jpg",
                Multiselect      = true
            };

            var result = dlg.ShowDialog();

            if (result != true)
            {
                return;
            }

            foreach (var group in dlg.SafeFileNames.Where(s => s.EndsWith("pl.jpg")))
            {
                var uploadInfo = new UploadInfo(@group.Substring(0, @group.Length - 6));
                UploadResults.Add(uploadInfo);
                uploadInfo.UploadList = new List <UploadImage>();

                foreach (var image in dlg.FileNames.Where(s => s.IndexOf(uploadInfo.Id, StringComparison.OrdinalIgnoreCase) >= 0))
                {
                    var uploadImage = new UploadImage
                    {
                        Name = Path.GetFileName(image),
                        Path = image,
                        Data = File.ReadAllBytes(image)
                    };

                    if (image.EndsWith("pl.jpg"))
                    {
                        uploadInfo.UploadList.Insert(0, uploadImage);
                    }
                    else
                    {
                        uploadInfo.UploadList.Add(uploadImage);
                    }
                }
            }
        }
        public async void Upload()
        {
            if (!UploadResults.Any())
            {
                return;
            }

            IsUploadFinished = false;
            Message          = "";
            Blogger.StartPosting();

            UploadInfo.RemoveSignature(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\west.txt");
            UploadInfo.RemoveSignature(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\west_pornbb.txt");

            var rnd = new Random();

            foreach (var uploadInfo in UploadResults)
            {
                var megaLinks = MEGA.GetEnabled ? await MEGA.GetLinks(uploadInfo.Id) : Enumerable.Empty <string>();

                var rapidgatorLinks = Rapidgator.GetEnabled ? await Rapidgator.GetLinks(uploadInfo.Id) : Enumerable.Empty <string>();

                if (MEGA.GetEnabled && !megaLinks.Any())
                {
                    uploadInfo.Id += "\n(No MEGA links!)";
                    continue;
                }
                if (Rapidgator.GetEnabled && !rapidgatorLinks.Any())
                {
                    uploadInfo.Id += "\n(No Rapidgator links!)";
                    continue;
                }

                if (MEGA.GetEnabled && Rapidgator.GetEnabled && megaLinks.Count() != rapidgatorLinks.Count())
                {
                    uploadInfo.Id += "\n(Missing some Mega/Rapidgator links!)";
                    continue;
                }

                // TODO: refactor
                var zippyshareLinks = Enumerable.Empty <string>();
                var linkSuccess     = true;
                foreach (var fileHost in FileHosts)
                {
                    if (!fileHost.Enabled)
                    {
                        continue;
                    }

                    var links = await fileHost.GetLinks(uploadInfo.Id);

                    if (!links.Any())
                    {
                        uploadInfo.Id += $"\n(No {fileHost.Name} links!)";
                        linkSuccess    = false;
                        break;
                    }
                    if (MEGA.GetEnabled && megaLinks.Count() != links.Count)
                    {
                        uploadInfo.Id += $"\n(Missing some Mega/{fileHost.Name} links!)";
                        linkSuccess    = false;
                        break;
                    }

                    zippyshareLinks = links;
                }
                if (!linkSuccess)
                {
                    continue;
                }

                var uploadTasks = new List <Task <List <string> > >();

                if (ImgChili.LoggedIn && ImgChili.Enabled)
                {
                    uploadTasks.Add(ImgChili.Upload(uploadInfo.UploadList));
                }
                if (ImgRock.LoggedIn && ImgRock.Enabled)
                {
                    uploadTasks.Add(ImgRock.Upload(uploadInfo.UploadList));
                }
                if (PixSense.LoggedIn && PixSense.Enabled)
                {
                    uploadTasks.Add(PixSense.Upload(uploadInfo.UploadList));
                }

                var taskCount = uploadTasks.Count;

                var uploadCount = 0;
                while (uploadTasks.Count > 0)
                {
                    try
                    {
                        var finishedTask = await Task.WhenAny(uploadTasks);

                        uploadTasks.Remove(finishedTask);

                        var links = await Task.Run(() => finishedTask);

                        if (links == null)
                        {
                            continue;
                        }

                        if (links[0].Contains("imgchili"))
                        {
                            uploadInfo.WebLinks1   = links[0].Trim();
                            uploadInfo.ForumLinks1 = ToLowerForumCode(links[1].Trim());
                            uploadCount++;
                        }
                        else if (links[0].Contains("imgrock"))
                        {
                            uploadInfo.WebLinks2   = links[0].Trim();
                            uploadInfo.ForumLinks2 = links[1].Trim();
                            uploadCount++;
                        }
                        else if (links[0].Contains("pixsense") || links[0].Contains("iceimg") || links[0].Contains("imgvip"))
                        {
                            uploadInfo.WebLinks3   = links[0].Trim();
                            uploadInfo.ForumLinks3 = links[1].Trim();
                            uploadCount++;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains(ImgChili.Name))
                        {
                            uploadInfo.WarningBrush1 = Brushes.Red;
                        }
                        else if (ex.Message.Contains(ImgRock.Name))
                        {
                            uploadInfo.WarningBrush2 = Brushes.Red;
                        }
                        else if (ex.Message.Contains(PixSense.Name))
                        {
                            uploadInfo.WarningBrush3 = Brushes.Red;
                        }

                        uploadInfo.IdColor = Colors.Red;
                        Message            = ex.InnerException.Message;
                    }
                }

                try
                {
                    if (Rapidgator.GetEnabled)
                    {
                        await uploadInfo.WriteOutput(string.Join("\\n", megaLinks), string.Join("\\n", rapidgatorLinks));
                    }
                    else if (Zippyshare.Enabled)
                    {
                        await uploadInfo.WriteOutput(string.Join("\\n", megaLinks), string.Join("\\n", zippyshareLinks));
                    }
                    else
                    {
                        await uploadInfo.WriteOutput(string.Join("\\n", megaLinks), string.Join("\\n", rapidgatorLinks));
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error(string.Format("Failed to write output: {0}", uploadInfo.Id), ex);
                    if (ex.InnerException != null)
                    {
                        Logger.Error(string.Format("Failed to write output (InnerException): {0}", uploadInfo.Id), ex.InnerException);
                    }
                }

                // Delete or Move images
                if (uploadCount == taskCount)
                {
                    foreach (var image in uploadInfo.UploadList)
                    {
                        try
                        {
                            File.Delete(image.Path);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error(string.Format("Failed to delete images: {0}", uploadInfo.Id), ex);
                        }
                    }
                }
                else
                {
                    foreach (var image in uploadInfo.UploadList)
                    {
                        try
                        {
                            var dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Handled");
                            if (!Directory.Exists(dir))
                            {
                                Directory.CreateDirectory(dir);
                            }
                            File.Move(image.Path, Path.Combine(dir, Path.GetFileName(image.Path)));
                        }
                        catch (Exception ex)
                        {
                            Logger.ErrorException(string.Format("Failed to move images: {0}", uploadInfo.Id), ex);
                        }
                    }
                }

                // Move files
                foreach (var path in UploadInfo.UploadPaths)
                {
                    if (!Directory.Exists(path))
                    {
                        continue;
                    }
                    var files = Directory.GetFiles(path, string.Format("{0}*.part*.rar", uploadInfo.Id), SearchOption.TopDirectoryOnly);
                    foreach (var file in files)
                    {
                        var fileInfo = new FileInfo(file);
                        var donePath = Path.Combine(fileInfo.DirectoryName, "Done");
                        if (!Directory.Exists(donePath))
                        {
                            Directory.CreateDirectory(donePath);
                        }

                        try
                        {
                            File.Move(file, Path.Combine(donePath, fileInfo.Name));
                        }
                        catch (IOException)
                        {
                            break;
                        }
                    }
                    if (files.Any())
                    {
                        break;
                    }
                }

                SpinWait.SpinUntil(() => false, rnd.Next(600, 1200));
            }

            UploadInfo.WriteSignature(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\west.txt");
            UploadInfo.WriteSignature(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\west_pornbb.txt");
            IsUploadFinished = true;
            Message          = "Upload done";
        }