示例#1
0
        /// <summary>
        /// Raises the <see cref="Uploading"/> event.
        /// </summary>
        protected virtual void OnUploading(UploadingEventArgs arg)
        {
            var handler = Uploading;

            if (handler != null)
            {
                handler(this, arg);
            }
        }
示例#2
0
        /// <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);
        }
示例#3
0
        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);
        }
示例#4
0
 /// <summary>
 /// Raises the <see cref="Uploading"/> event.
 /// </summary>
 protected virtual void OnUploading(UploadingEventArgs arg)
 {
     var handler = Uploading;
     if (handler != null)
         handler(this, arg);
 }
示例#5
0
        /// <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;
        }