/// <summary> /// Raises the <see cref="Uploading"/> event. /// </summary> protected virtual void OnUploading(UploadingEventArgs arg) { var handler = Uploading; if (handler != null) { handler(this, arg); } }
/// <summary> /// Uploads the screenshot to the currently configured server. /// </summary> /// <returns> /// A value indicating whether the upload succeeded without errors. /// </returns> public bool Upload() { var args = new UploadingEventArgs(GetFileName()); OnUploading(args); if (args.Cancel) { return(true); } var target = PathUtility.UriCombine(Program.Config.FtpServerPath, args.FileName); var uploader = Uploader.Create(Program.Config); uploader.DuplicateFileFound += (sender, e) => { OnDuplicateFileFound(e); }; if (IsFile && Program.Config.CheckForDuplicateFiles) { var name = Path.GetFileNameWithoutExtension(OriginalFileName); if (!uploader.CheckDuplicates(name, ref target)) { return(false); } } using (var stream = new MemoryStream()) { Save(stream); if (uploader.Upload(stream, ref target)) { ServerPath = target; return(true); } } return(false); }
private void Screenshot_Uploading(object sender, UploadingEventArgs e) { if (Program.Config.ShowPreviewDialog) { var screenshot = (Screenshot)sender; Debug.Assert(uiContext != null, "Main thread context should not be null"); uiContext.Send(_ => { using (var dialog = new PreviewDialog(screenshot)) { if (dialog.ShowDialog() != DialogResult.OK) { e.Cancel = true; } e.FileName = dialog.FileName; } }, null); } Program.Tray.SetStatus(TrayIcon.Status.Uploading); }
/// <summary> /// Raises the <see cref="Uploading"/> event. /// </summary> protected virtual void OnUploading(UploadingEventArgs arg) { var handler = Uploading; if (handler != null) handler(this, arg); }
/// <summary> /// Uploads the screenshot to the currently configured server. /// </summary> /// <returns> /// A value indicating whether the upload succeeded without errors. /// </returns> public bool Upload() { var args = new UploadingEventArgs(GetFileName()); OnUploading(args); if (args.Cancel) return true; var target = PathUtility.UriCombine(Program.Config.FtpServerPath, args.FileName); var uploader = Uploader.Create(Program.Config); uploader.DuplicateFileFound += (sender, e) => { OnDuplicateFileFound(e); }; if (IsFile && Program.Config.CheckForDuplicateFiles) { var name = Path.GetFileNameWithoutExtension(OriginalFileName); if (!uploader.CheckDuplicates(name, ref target)) return false; } using (var stream = new MemoryStream()) { Save(stream); if (uploader.Upload(stream, ref target)) { ServerPath = target; return true; } } return false; }