public static void ShowInstance(UploadResult result) { lock (singletonLock) { if (instance == null || instance.IsDisposed) { instance = new ResponseForm(result); } else { instance.UpdateResult(result); } instance.ForceActivate(); } }
private void btnCustomUploaderShowLastResponse_Click(object sender, EventArgs e) { string response = btnCustomUploaderShowLastResponse.Tag as string; if (!string.IsNullOrEmpty(response)) { using (ResponseForm form = new ResponseForm(response)) { form.ShowDialog(); } } }
private async Task TestCustomUploader(CustomUploaderDestinationType type, int index) { if (!Config.CustomUploadersList.IsValidIndex(index)) { return; } btnImageUploaderTest.Enabled = btnTextUploaderTest.Enabled = btnFileUploaderTest.Enabled = btnURLShortenerTest.Enabled = btnURLSharingServiceTest.Enabled = false; lbCustomUploaderList.SelectedIndex = index; CustomUploaderItem item = Config.CustomUploadersList[index]; UploadResult result = null; await Task.Run(() => { try { switch (type) { case CustomUploaderDestinationType.ImageUploader: using (Stream stream = ShareXResources.Logo.GetStream()) { CustomImageUploader imageUploader = new CustomImageUploader(item); result = imageUploader.Upload(stream, "Test.png"); result.Errors.AddRange(imageUploader.Errors); } break; case CustomUploaderDestinationType.TextUploader: CustomTextUploader textUploader = new CustomTextUploader(item); result = textUploader.UploadText("ShareX text upload test", "Test.txt"); result.Errors.AddRange(textUploader.Errors); break; case CustomUploaderDestinationType.FileUploader: using (Stream stream = ShareXResources.Logo.GetStream()) { CustomFileUploader fileUploader = new CustomFileUploader(item); result = fileUploader.Upload(stream, "Test.png"); result.Errors.AddRange(fileUploader.Errors); } break; case CustomUploaderDestinationType.URLShortener: CustomURLShortener urlShortener = new CustomURLShortener(item); result = urlShortener.ShortenURL(Links.URL_WEBSITE); result.Errors.AddRange(urlShortener.Errors); break; case CustomUploaderDestinationType.URLSharingService: CustomURLSharer urlSharer = new CustomURLSharer(item); result = urlSharer.ShareURL(Links.URL_WEBSITE); result.Errors.AddRange(urlSharer.Errors); break; } } catch (Exception e) { result = new UploadResult(); result.Errors.Add(e.Message); } }); if (!IsDisposed) { if (result != null) { ResponseForm.ShowInstance(result); } btnImageUploaderTest.Enabled = btnTextUploaderTest.Enabled = btnFileUploaderTest.Enabled = btnURLShortenerTest.Enabled = btnURLSharingServiceTest.Enabled = true; } }
public void ShowResponse() { if (IsItemSelected && SelectedItem.Info.Result != null && !string.IsNullOrEmpty(SelectedItem.Info.Result.Response)) { using (ResponseForm form = new ResponseForm(SelectedItem.Info.Result.Response)) { form.ShowDialog(); } } }