/// <summary> /// This will be called when the menu item in the Editor is clicked /// </summary> private async Task <string> UploadAsync(ICaptureDetails captureDetails, ISurface surfaceToUpload) { try { string url; using (var pleaseWaitForm = new PleaseWaitForm("Box", _boxLanguage.CommunicationWait)) { pleaseWaitForm.Show(); try { url = await UploadToBoxAsync(captureDetails, surfaceToUpload).ConfigureAwait(true); } finally { pleaseWaitForm.Close(); } } if (url != null && _boxConfiguration.AfterUploadLinkToClipBoard) { ClipboardHelper.SetClipboardData(url); } return(url); } catch (Exception ex) { Log.Error().WriteLine(ex, "Error uploading."); MessageBox.Show(_boxLanguage.UploadFailure + " " + ex.Message); return(null); } }
public async Task <string> Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload) { try { string url; using (var pleaseWaitForm = new PleaseWaitForm("GooglePhotos", _googlePhotosLanguage.CommunicationWait)) { pleaseWaitForm.Show(); try { url = await UploadToPicasa(surfaceToUpload); } finally { pleaseWaitForm.Close(); } } if (url != null && _googlePhotosConfiguration.AfterUploadLinkToClipBoard) { ClipboardHelper.SetClipboardData(url); } return(url); } catch (Exception e) { Log.Error().WriteLine(e, "Error uploading."); MessageBox.Show(_googlePhotosLanguage.UploadFailure + " " + e.Message); } return(null); }
// SP - Please Wait Form will start in upper-right quadrant of screen // Constructor with no params will start form wherever Windows starts it public void StartForm() { Thread plsWaitThread = new Thread((ThreadStart)(() => Application.Run((Form)PleaseWaitForm))); plsWaitThread.SetApartmentState(ApartmentState.STA); plsWaitThread.Start(); PleaseWaitForm.Focus(); }
public PleaseWaitDialog() { var pleaseWaitForm = new PleaseWaitForm(); var progress = new Progress <string>(s => pleaseWaitForm.StatusLabel.Text = s); PleaseWaitForm = pleaseWaitForm; Progress = progress; StartForm(); }
/// <summary> /// Upload the capture to OneDrive /// </summary> /// <param name="captureDetails">ICaptureDetails</param> /// <param name="surfaceToUpload">ISurface</param> /// <returns>Uri</returns> private async Task <Uri> Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload) { var outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, _config.UploadReduceColors); try { string filename = Path.GetFileName(FilenameHelper.GetFilenameFromPattern(_config.FilenamePattern, _config.UploadFormat, captureDetails)); Uri response = null; var cancellationTokenSource = new CancellationTokenSource(); using (var pleaseWaitForm = new PleaseWaitForm("OneDrive plug-in", _oneDriveLanguage.CommunicationWait, cancellationTokenSource)) { pleaseWaitForm.Show(); try { var oneDriveResponse = await OneDriveUtils.UploadToOneDriveAsync(_oauth2Settings, surfaceToUpload, outputSettings, captureDetails.Title, filename, null, cancellationTokenSource.Token); response = new Uri(oneDriveResponse.WebUrl); } finally { pleaseWaitForm.Close(); } } if (response != null) { if (_config.AfterUploadLinkToClipBoard) { ClipboardHelper.SetClipboardData(response.ToString()); } return(response); } } catch (Exception e) { Log.Error().WriteLine(e, "Error uploading."); MessageBox.Show(_oneDriveLanguage.UploadFailure + " " + e.Message); } return(null); }
private SPList TryGetSPList() { if (StringUtil.IsNullOrWhitespace(TxtSPListUrl.Text)) { return(null); } PleaseWaitForm pleaseWait = new PleaseWaitForm(); try { #if (!DEBUG) pleaseWait.Show(this.Parent); Application.DoEvents(); #endif using (SPSite site = new SPSite(TxtSPListUrl.Text)) { using (SPWeb web = site.OpenWeb()) { Uri curUri = new Uri(TxtSPListUrl.Text); return(SPListHelper.TryGetListByRelativeUrl(web, curUri.PathAndQuery)); } } } catch (SPException spex) { MessageBox.Show(spex.Message); Log.Error(spex); } catch (Exception ex) { MessageBox.Show(ex.Message); Log.Error(ex); } finally { #if (!DEBUG) pleaseWait.Close(); #endif } return(null); }
// SP - Please Wait Form will start in upper-right quadrant of screen // Constructor with no params will start form wherever Windows starts it public PleaseWaitDialog(Form currentForm) { var pleaseWaitForm = new PleaseWaitForm(); int currentX = currentForm.Location.X; var currentY = currentForm.Location.Y; var currentWidth = currentForm.Width; var currentHeight = currentForm.Height; var startX = (currentWidth / 2) + currentX - (pleaseWaitForm.Width / 2); var startY = (currentHeight / 2) + currentY - (pleaseWaitForm.Height / 2); pleaseWaitForm.StartPosition = FormStartPosition.Manual; pleaseWaitForm.Location = new Point(startX, startY); var progress = new Progress <string>(s => pleaseWaitForm.StatusLabel.Text = s); PleaseWaitForm = pleaseWaitForm; Progress = progress; StartForm(); }
public async Task <string> Upload(ICaptureDetails captureDetails, ISurface surface) { string uploadUrl = null; var outputSettings = new SurfaceOutputSettings(_flickrConfiguration.UploadFormat, _flickrConfiguration.UploadJpegQuality, false); try { var cancellationTokenSource = new CancellationTokenSource(); using (var pleaseWaitForm = new PleaseWaitForm("Flickr", _flickrLanguage.CommunicationWait, cancellationTokenSource)) { pleaseWaitForm.Show(); try { var filename = Path.GetFileName(FilenameHelper.GetFilename(_flickrConfiguration.UploadFormat, captureDetails)); uploadUrl = await FlickrUtils.UploadToFlickrAsync(surface, outputSettings, captureDetails.Title, filename); } finally { pleaseWaitForm.Close(); } } if (uploadUrl == null) { return(null); } if (_flickrConfiguration.AfterUploadLinkToClipBoard) { ClipboardHelper.SetClipboardData(uploadUrl); } } catch (Exception e) { Log.Error().WriteLine(e, "Error uploading."); MessageBox.Show(_flickrLanguage.UploadFailure + " " + e.Message); } return(uploadUrl); }
/// <summary> /// This will be called when the menu item in the Editor is clicked /// </summary> private async Task <string> UploadAsync(ICaptureDetails captureDetails, ISurface surfaceToUpload, CancellationToken cancellationToken = default) { string dropboxUrl = null; var outputSettings = new SurfaceOutputSettings(_dropboxPluginConfiguration.UploadFormat, _dropboxPluginConfiguration.UploadJpegQuality, false); try { var cancellationTokenSource = new CancellationTokenSource(); using (var pleaseWaitForm = new PleaseWaitForm("Dropbox", _dropboxLanguage.CommunicationWait, cancellationTokenSource)) { pleaseWaitForm.Show(); try { var filename = Path.GetFileName(FilenameHelper.GetFilename(_dropboxPluginConfiguration.UploadFormat, captureDetails)); using (var imageStream = new MemoryStream()) { ImageOutput.SaveToStream(surfaceToUpload, imageStream, outputSettings); imageStream.Position = 0; using (var streamContent = new StreamContent(imageStream)) { streamContent.Headers.ContentType = new MediaTypeHeaderValue("image/" + outputSettings.Format); dropboxUrl = await UploadAsync(filename, streamContent, null, cancellationToken); } } } finally { pleaseWaitForm.Close(); } } } catch (Exception e) { Log.Error().WriteLine(e); MessageBox.Show(_dropboxLanguage.UploadFailure + " " + e.Message); } return(dropboxUrl); }
private void QueryList() { PleaseWaitForm pleaseWait = new PleaseWaitForm(); try { #if (!DEBUG) pleaseWait.Show(this.Parent); Application.DoEvents(); #endif if (StringUtil.IsNullOrWhitespace(TxtSPListUrl.Text)) { return; } curList = TryGetSPList(); if (curList == null) { return; } PopulateSchema(curList.SchemaXml); PopulateListData(curList, curList.Items.GetDataTable()); PopulatePropertiesDropDown(curList); ListTabs.SelectedTab = TabData; } catch (Exception ex) { MessageBox.Show(ex.Message); Log.Error(ex); } finally { #if (!DEBUG) pleaseWait.Close(); #endif } }
/// <summary> /// Upload the capture to imgur /// </summary> /// <param name="captureDetails">ICaptureDetails</param> /// <param name="surfaceToUpload">ISurface</param> /// <returns>Uri</returns> private async Task <Uri> Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload) { var outputSettings = new SurfaceOutputSettings(_imgurConfiguration.UploadFormat, _imgurConfiguration.UploadJpegQuality, _imgurConfiguration.UploadReduceColors); try { string filename = Path.GetFileName(FilenameHelper.GetFilenameFromPattern(_imgurConfiguration.FilenamePattern, _imgurConfiguration.UploadFormat, captureDetails)); ImgurImage imgurImage; var cancellationTokenSource = new CancellationTokenSource(); using (var pleaseWaitForm = new PleaseWaitForm("Imgur plug-in", _imgurLanguage.CommunicationWait, cancellationTokenSource)) { pleaseWaitForm.Show(); try { imgurImage = await ImgurUtils.UploadToImgurAsync(_oauth2Settings, surfaceToUpload, outputSettings, captureDetails.Title, filename, null, cancellationTokenSource.Token); if (imgurImage != null) { // Create thumbnail using (var tmpImage = surfaceToUpload.GetBitmapForExport()) using (var thumbnail = tmpImage.CreateThumbnail(90, 90)) { imgurImage.Image = thumbnail.ToBitmapSource(); } if (_imgurConfiguration.AnonymousAccess && _imgurConfiguration.TrackHistory) { Log.Info().WriteLine("Storing imgur upload for hash {0} and delete hash {1}", imgurImage.Data.Id, imgurImage.Data.Deletehash); _imgurConfiguration.ImgurUploadHistory.Add(imgurImage.Data.Id, imgurImage.Data.Deletehash); _imgurConfiguration.RuntimeImgurHistory.Add(imgurImage.Data.Id, imgurImage); // TODO: Update History - ViewModel!!! // UpdateHistoryMenuItem(); } } } finally { pleaseWaitForm.Close(); } } if (imgurImage != null) { var uploadUrl = _imgurConfiguration.UsePageLink ? imgurImage.Data.LinkPage: imgurImage.Data.Link; if (uploadUrl == null || !_imgurConfiguration.CopyLinkToClipboard) { return(uploadUrl); } try { ClipboardHelper.SetClipboardData(uploadUrl.AbsoluteUri); } catch (Exception ex) { Log.Error().WriteLine(ex, "Can't write to clipboard: "); uploadUrl = null; } return(uploadUrl); } } catch (Exception e) { Log.Error().WriteLine(e, "Error uploading."); MessageBox.Show(_imgurLanguage.UploadFailure + " " + e.Message); } return(null); }
/// <summary> /// Upload the capture to lutim /// </summary> /// <param name="captureDetails">ICaptureDetails</param> /// <param name="surfaceToUpload">ISurface</param> /// <param name="uploadUrl">out string for the url</param> /// <returns>true if the upload succeeded</returns> private async Task <string> Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload) { string uploadUrl; SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_lutimConfiguration.UploadFormat, _lutimConfiguration.UploadJpegQuality, _lutimConfiguration.UploadReduceColors); try { string filename = Path.GetFileName(FilenameHelper.GetFilenameFromPattern(_lutimConfiguration.FilenamePattern, _lutimConfiguration.UploadFormat, captureDetails)); LutimInfo lutimInfo; var cancellationTokenSource = new CancellationTokenSource(); using (var pleaseWaitForm = new PleaseWaitForm("Lutim", _lutimLanguage.CommunicationWait, cancellationTokenSource)) { pleaseWaitForm.Show(); try { lutimInfo = await LutimUtils.UploadToLutim(surfaceToUpload, outputSettings, filename); if (lutimInfo != null) { Log.Info().WriteLine("Storing lutim upload for hash {0} and delete hash {1}", lutimInfo.Short, lutimInfo.Token); // TODO: Write somewhere // _lutimConfiguration.LutimUploadHistory.Add(lutimInfo.Short, lutimInfo.ToIniString()); _lutimConfiguration.RuntimeLutimHistory.Add(lutimInfo.Short, lutimInfo); // TODO: Update // UpdateHistoryMenuItem(); } } finally { pleaseWaitForm.Close(); } } if (lutimInfo != null) { uploadUrl = lutimInfo.Short; if (string.IsNullOrEmpty(uploadUrl) || !_lutimConfiguration.CopyLinkToClipboard) { return(uploadUrl); } try { ClipboardHelper.SetClipboardData(uploadUrl); } catch (Exception ex) { Log.Error().WriteLine(ex, "Can't write to clipboard: "); return(null); } return(uploadUrl); } } catch (Exception e) { Log.Error().WriteLine(e, "Error uploading."); MessageBox.Show(_lutimLanguage.UploadFailure + " " + e.Message); } return(null); }
private void btnStop_Click(object sender, EventArgs e) { PleaseWaitWorker pleaseWaitWorker = new PleaseWaitWorker(); PleaseWaitForm pleaseWaitForm = new PleaseWaitForm(); pleaseWaitWorker.pleaseWaitForm.ShowInTaskbar = false; pleaseWaitWorker.pleaseWaitForm.StartPosition = FormStartPosition.Manual; //manual artinya diatur oleh Location int XPoint = this.Location.X + this.Width / 2 - pleaseWaitWorker.pleaseWaitForm.Width / 2; int YPoint = this.Location.Y + this.Height / 2 - pleaseWaitWorker.pleaseWaitForm.Height / 2; pleaseWaitWorker.pleaseWaitForm.Location = new Point(XPoint, YPoint); Thread pleaseWaitThread = new Thread(pleaseWaitWorker.Show); pleaseWaitThread.Start(); Console.WriteLine("Stop recording"); WaitAllThreadStop(); Console.WriteLine("Closing connection"); db.CloseConnection(); pleaseWaitForm.Dispose(); pleaseWaitThread.Abort(); //TODO : Clear all queue in RabbitMQ this.btnStart.Enabled = true; this.ckLisBxSensor.Enabled = true; this.btnStart.FlatStyle = FlatStyle.Standard; this.btnStart.BackColor = SystemColors.ButtonFace; this.btnStop.Enabled = false; }