private void UpdateCustomUploader() { if (lbCustomUploaderList.SelectedIndex != -1) { CustomUploaderInfo iUploader = GetCustomUploaderFromFields(); iUploader.Name = lbCustomUploaderList.SelectedItem.ToString(); Config.CustomUploadersList[lbCustomUploaderList.SelectedIndex] = iUploader; } }
private void btnCustomUploaderAdd_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtCustomUploaderName.Text)) { CustomUploaderInfo iUploader = GetCustomUploaderFromFields(); Config.CustomUploadersList.Add(iUploader); lbCustomUploaderList.Items.Add(iUploader.Name); lbCustomUploaderList.SelectedIndex = lbCustomUploaderList.Items.Count - 1; } }
private CustomUploaderInfo GetCustomUploaderFromFields() { CustomUploaderInfo iUploader = new CustomUploaderInfo(txtCustomUploaderName.Text); foreach (ListViewItem lvItem in lvCustomUploaderArguments.Items) { iUploader.Arguments.Add(new Argument(lvItem.Text, lvItem.SubItems[1].Text)); } iUploader.UploadURL = txtCustomUploaderURL.Text; iUploader.FileFormName = txtCustomUploaderFileForm.Text; foreach (ListViewItem lvItem in lvCustomUploaderRegexps.Items) { iUploader.RegexpList.Add(lvItem.Text); } iUploader.URL = txtCustomUploaderFullImage.Text; iUploader.ThumbnailURL = txtCustomUploaderThumbnail.Text; return(iUploader); }
private void TestCustomUploader(CustomUploaderInfo cui) { UploadResult ur = null; AsyncHelper.AsyncJob(() => { try { using (Stream stream = Resources.ZScreen_256.GetStream()) { CustomUploader cu = new CustomUploader(cui); ur = cu.Upload(stream, "Test.png"); ur.Errors = cu.Errors; } } catch { } }, () => { if (ur != null) { if (!string.IsNullOrEmpty(ur.URL)) { txtCustomUploaderLog.AppendText("URL: " + ur.URL + Environment.NewLine); } else if (ur.IsError) { txtCustomUploaderLog.AppendText("Error: " + ur.ErrorsToString() + Environment.NewLine); } else { txtCustomUploaderLog.AppendText("Error: Result is empty." + Environment.NewLine); } txtCustomUploaderLog.ScrollToCaret(); } btnCustomUploaderTest.Enabled = true; }); }
private void LoadCustomUploader(CustomUploaderInfo imageUploader) { txtCustomUploaderArgName.Text = string.Empty; txtCustomUploaderArgValue.Text = string.Empty; lvCustomUploaderArguments.Items.Clear(); foreach (Argument arg in imageUploader.Arguments) { lvCustomUploaderArguments.Items.Add(arg.Name).SubItems.Add(arg.Value); } txtCustomUploaderURL.Text = imageUploader.UploadURL; txtCustomUploaderFileForm.Text = imageUploader.FileFormName; txtCustomUploaderRegexp.Text = string.Empty; lvCustomUploaderRegexps.Items.Clear(); foreach (string regexp in imageUploader.RegexpList) { lvCustomUploaderRegexps.Items.Add(regexp); } txtCustomUploaderFullImage.Text = imageUploader.URL; txtCustomUploaderThumbnail.Text = imageUploader.ThumbnailURL; }
public CustomUploader(CustomUploaderInfo imageHosting) { this.imageHosting = imageHosting; }