Ejemplo n.º 1
0
        public static void ClipboardUploadWithContentViewer(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            using (ClipboardContentViewer ccv = new ClipboardContentViewer())
            {
                if (ccv.ShowDialog() == DialogResult.OK && ccv.IsClipboardContentValid)
                {
                    ClipboardUpload(taskSettings);
                }
            }
        }
        public static void UploadFile(string[] files, TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            if (files != null && files.Length > 0)
            {
                if (files.Length <= 10 || IsUploadConfirmed(files.Length))
                {
                    foreach (string file in files)
                    {
                        UploadFile(file, taskSettings);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void OpenImageEditor(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            using (EditorStartupForm editorStartupForm = new EditorStartupForm(taskSettings.CaptureSettingsReference.SurfaceOptions))
            {
                if (editorStartupForm.ShowDialog() == DialogResult.OK)
                {
                    AnnotateImageAsync(editorStartupForm.Image, editorStartupForm.ImageFilePath, taskSettings);
                }
            }
        }
Ejemplo n.º 4
0
        public static void StartAutoCapture(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            //if (!AutoCaptureForm.IsRunning)
            //{
            //    AutoCaptureForm form = AutoCaptureForm.Instance;
            //    form.TaskSettings = taskSettings;
            //    form.Show();
            //    form.Execute();
            //}
        }
Ejemplo n.º 5
0
        public static void IndexFolder(string folderPath, TaskSettings taskSettings = null)
        {
            if (!string.IsNullOrEmpty(folderPath) && Directory.Exists(folderPath))
            {
                if (taskSettings == null)
                {
                    taskSettings = TaskSettings.GetDefaultTaskSettings();
                }

                taskSettings.IndexerSettings.BinaryUnits = Program.Settings.BinaryUnits;
                string     text = Indexer.Index(folderPath, taskSettings.IndexerSettings);
                UploadTask task = UploadTask.CreateTextUploaderTask(text, taskSettings);
                task.Info.FileName = Path.ChangeExtension(task.Info.FileName, taskSettings.IndexerSettings.Output.ToString().ToLower());
                TaskManager.Start(task);
            }
        }
Ejemplo n.º 6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            HotkeySettings hotkeySetting = new HotkeySettings();

            hotkeySetting.TaskSettings = TaskSettings.GetDefaultTaskSettings();
            manager.Hotkeys.Add(hotkeySetting);
            HotkeySelectionControl control = AddHotkeySelectionControl(hotkeySetting);

            control.Selected = true;
            Selected         = control;
            UpdateButtons();
            UpdateCheckStates();
            control.Focus();
            Update();
            EditSelected();
        }
Ejemplo n.º 7
0
        public static void PlayErrorSound(TaskSettings taskSettings)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            if (taskSettings.AdvancedSettings.UseCustomErrorSound && !string.IsNullOrEmpty(taskSettings.AdvancedSettings.CustomErrorSoundPath))
            {
                Helpers.PlaySoundAsync(taskSettings.AdvancedSettings.CustomErrorSoundPath);
            }
            else
            {
                Helpers.PlaySoundAsync(Resources.ErrorSound);
            }
        }
Ejemplo n.º 8
0
        public static void DownloadAndUploadFile(string url, TaskSettings taskSettings = null)
        {
            if (!string.IsNullOrEmpty(url))
            {
                if (taskSettings == null)
                {
                    taskSettings = TaskSettings.GetDefaultTaskSettings();
                }

                WorkerTask task = WorkerTask.CreateDownloadUploadTask(url, taskSettings);

                if (task != null)
                {
                    TaskManager.Start(task);
                }
            }
        }
        public static void ShowTextUploadDialog(TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            using (TextUploadForm form = new TextUploadForm())
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    string text = form.Content;

                    if (!string.IsNullOrEmpty(text))
                    {
                        UploadText(text, taskSettings);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public static void AnnotateImageFromFile(string filePath, TaskSettings taskSettings = null)
        {
            if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
            {
                if (taskSettings == null)
                {
                    taskSettings = TaskSettings.GetDefaultTaskSettings();
                }

                Bitmap bmp = ImageHelpers.LoadImage(filePath);

                AnnotateImageAsync(bmp, filePath, taskSettings);
            }
            else
            {
                MessageBox.Show("File does not exist:" + Environment.NewLine + filePath, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 11
0
        private void TakeScreenshot()
        {
            if (!CaptureRectangle.IsEmpty)
            {
                Image img = Screenshot.CaptureRectangle(CaptureRectangle);

                if (img != null)
                {
                    TaskSettings taskSettings = TaskSettings.GetDefaultTaskSettings();
                    taskSettings.UseDefaultAfterCaptureJob             = false;
                    taskSettings.AfterCaptureJob                       = taskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AnnotateImage);
                    taskSettings.UseDefaultAdvancedSettings            = false;
                    taskSettings.AdvancedSettings.DisableNotifications = true;

                    UploadManager.RunImageTask(img, taskSettings);
                }
            }
        }
Ejemplo n.º 12
0
        public static void StartScreenRecording(TaskSettings taskSettings = null, bool skipRegionSelection = false)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            ScreenRecordForm form = ScreenRecordForm.Instance;

            if (form.IsRecording)
            {
                form.StartStopRecording();
            }
            else
            {
                form.StartRecording(taskSettings, skipRegionSelection);
            }
        }
Ejemplo n.º 13
0
        public static void UploadImage(Bitmap bmp, TaskSettings taskSettings = null)
        {
            if (bmp != null)
            {
                if (taskSettings == null)
                {
                    taskSettings = TaskSettings.GetDefaultTaskSettings();
                }

                if (taskSettings.IsSafeTaskSettings)
                {
                    taskSettings.UseDefaultAfterCaptureJob = false;
                    taskSettings.AfterCaptureJob           = AfterCaptureTasks.UploadImageToHost;
                }

                RunImageTask(bmp, taskSettings);
            }
        }
Ejemplo n.º 14
0
        public static void StartScreenRecording(ScreenRecordOutput outputType, ScreenRecordStartMethod startMethod, TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            ScreenRecordForm form = ScreenRecordForm.Instance;

            if (form.IsRecording)
            {
                form.StartStopRecording();
            }
            else
            {
                form.StartRecording(outputType, taskSettings, startMethod);
            }
        }
        public static void ClipboardUploadMainWindow(TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            if (Program.Settings.ShowClipboardContentViewer)
            {
                using (ClipboardContentViewer ccv = new ClipboardContentViewer(true))
                {
                    ProcessClipboardContentViewerDialog(ccv, taskSettings);

                    Program.Settings.ShowClipboardContentViewer = !ccv.DontShowThisWindow;
                }
            }
            else
            {
                ClipboardUpload(taskSettings);
            }
        }
Ejemplo n.º 16
0
        public static void DoScreenRecording(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            ScreenRecordForm form = ScreenRecordForm.Instance;

            if (form.IsRecording)
            {
                form.StopRecording();
            }
            else
            {
                form.StartRecording(taskSettings);
            }
        }
        public static void UploadFile(string filePath, TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            if (!string.IsNullOrEmpty(filePath))
            {
                if (File.Exists(filePath))
                {
                    WorkerTask task = WorkerTask.CreateFileUploaderTask(filePath, taskSettings);
                    TaskManager.Start(task);
                }
                else if (Directory.Exists(filePath))
                {
                    string[] files = Directory.GetFiles(filePath, "*.*", SearchOption.AllDirectories);
                    UploadFile(files, taskSettings);
                }
            }
        }
Ejemplo n.º 18
0
        public static void DownloadAndUploadFile(string url, string filename, TaskSettings taskSettings = null)
        {
            if (!string.IsNullOrEmpty(url))
            {
                if (taskSettings == null)
                {
                    taskSettings = TaskSettings.GetDefaultTaskSettings();
                }

                string downloadPath = null;
                bool   isDownloaded = false;

                TaskEx.Run(() =>
                {
                    downloadPath = TaskHelpers.CheckFilePath(taskSettings.CaptureFolder, filename, taskSettings);

                    if (!string.IsNullOrEmpty(downloadPath))
                    {
                        try
                        {
                            using (WebClient wc = new WebClient())
                            {
                                wc.Proxy = ProxyInfo.Current.GetWebProxy();
                                wc.DownloadFile(url, downloadPath);
                            }

                            isDownloaded = true;
                        }
                        catch (Exception e)
                        {
                            DebugHelper.WriteException(e);
                            MessageBox.Show("Download failed:\r\n" + e.ToString(), "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                },
                           () =>
                {
                    if (isDownloaded)
                    {
                        UploadFile(downloadPath, taskSettings);
                    }
                });
            }
        }
Ejemplo n.º 19
0
        public static Screenshot GetScreenshot(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            Screenshot screenshot = new Screenshot()
            {
                CaptureCursor           = taskSettings.CaptureSettings.ShowCursor,
                CaptureClientArea       = taskSettings.CaptureSettings.CaptureClientArea,
                RemoveOutsideScreenArea = true,
                CaptureShadow           = taskSettings.CaptureSettings.CaptureShadow,
                ShadowOffset            = taskSettings.CaptureSettings.CaptureShadowOffset,
                AutoHideTaskbar         = taskSettings.CaptureSettings.CaptureAutoHideTaskbar
            };

            return(screenshot);
        }
Ejemplo n.º 20
0
        public static void AnnotateImage(string filePath, TaskSettings taskSettings = null)
        {
            if (!string.IsNullOrEmpty(filePath))
            {
                if (taskSettings == null)
                {
                    taskSettings = TaskSettings.GetDefaultTaskSettings();
                }

                if (taskSettings.AdvancedSettings.UseShareXForAnnotation)
                {
                    AnnotateImageUsingShareX(filePath, taskSettings);
                }
                else
                {
                    AnnotateImageUsingGreenshot(null, filePath);
                }
            }
        }
Ejemplo n.º 21
0
        public static void UploadURL(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            string url = InputBox.GetInputText("ShareX - URL to download from and upload");

            if (!string.IsNullOrEmpty(url))
            {
                string filename = URLHelpers.GetFileName(url, true);

                if (!string.IsNullOrEmpty(filename))
                {
                    DownloadAndUploadFile(url, filename, taskSettings);
                }
            }
        }
Ejemplo n.º 22
0
        public static void UploadURL(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            string url = InputBox.GetInputText("ShareX - " + Resources.UploadManager_UploadURL_URL_to_download_from_and_upload);

            if (!string.IsNullOrEmpty(url))
            {
                string filename = URLHelpers.GetFileName(url, true);

                if (!string.IsNullOrEmpty(filename))
                {
                    DownloadAndUploadFile(url, filename, taskSettings);
                }
            }
        }
Ejemplo n.º 23
0
        public static void RunImageTask(ImageInfo imageInfo, TaskSettings taskSettings, bool skipQuickTaskMenu = false, bool skipAfterCaptureWindow = false)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            if (imageInfo != null && imageInfo.Image != null && taskSettings != null)
            {
                if (!skipQuickTaskMenu && taskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.ShowQuickTaskMenu))
                {
                    QuickTaskMenu quickTaskMenu = new QuickTaskMenu();

                    quickTaskMenu.TaskInfoSelected += taskInfo =>
                    {
                        if (taskInfo == null)
                        {
                            RunImageTask(imageInfo, taskSettings, true);
                        }
                        else if (taskInfo.IsValid)
                        {
                            taskSettings.AfterCaptureJob = taskInfo.AfterCaptureTasks;
                            taskSettings.AfterUploadJob  = taskInfo.AfterUploadTasks;
                            RunImageTask(imageInfo, taskSettings, true);
                        }
                    };

                    quickTaskMenu.ShowMenu();

                    return;
                }

                string customFileName = null;

                if (!skipAfterCaptureWindow && !TaskHelpers.ShowAfterCaptureForm(taskSettings, out customFileName, imageInfo))
                {
                    return;
                }

                WorkerTask task = WorkerTask.CreateImageUploaderTask(imageInfo, taskSettings, customFileName);
                TaskManager.Start(task);
            }
        }
Ejemplo n.º 24
0
        public static void OpenWebpageCapture(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            WebpageCaptureForm webpageCaptureForm = new WebpageCaptureForm();

            webpageCaptureForm.OnImageUploadRequested += img => UploadManager.RunImageTask(img, taskSettings);
            webpageCaptureForm.OnImageCopyRequested   += img =>
            {
                using (img)
                {
                    ClipboardHelpers.CopyImage(img);
                }
            };
            webpageCaptureForm.Show();
        }
        private static void ProcessClipboardContentViewerDialog(ClipboardContentViewer ccv, TaskSettings taskSettings = null)
        {
            if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();

            if (ccv.ShowDialog() == DialogResult.OK && ccv.IsClipboardContentValid)
            {
                if (ccv.ClipboardContentType != EClipboardContentType.Default)
                {
                    ClipboardUploadCached(ccv, taskSettings);
                }
                else
                {
                    ClipboardUpload(taskSettings);
                }
            }
            else if (ccv.ClipboardContentType == EClipboardContentType.Image)
            {
                ((Image)ccv.ClipboardContent).Dispose();
            }
        }
Ejemplo n.º 26
0
        public static void ClipboardUploadMainWindow(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            if (Program.Settings.ShowClipboardContentViewer)
            {
                using (ClipboardUploadForm clipboardUploadForm = new ClipboardUploadForm(taskSettings, true))
                {
                    clipboardUploadForm.ShowDialog();
                    Program.Settings.ShowClipboardContentViewer = !clipboardUploadForm.DontShowThisWindow;
                }
            }
            else
            {
                ClipboardUpload(taskSettings);
            }
        }
Ejemplo n.º 27
0
        private void DoCapture(ScreenCaptureDelegate capture, CaptureType captureType, TaskSettings taskSettings = null, bool autoHideForm = true)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            if (taskSettings.CaptureSettings.IsDelayScreenshot && taskSettings.CaptureSettings.DelayScreenshot > 0)
            {
                int sleep           = (int)(taskSettings.CaptureSettings.DelayScreenshot * 1000);
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork             += (sender, e) => Thread.Sleep(sleep);
                bw.RunWorkerCompleted += (sender, e) => DoCaptureWork(capture, captureType, taskSettings, autoHideForm);
                bw.RunWorkerAsync();
            }
            else
            {
                DoCaptureWork(capture, captureType, taskSettings, autoHideForm);
            }
        }
Ejemplo n.º 28
0
        public static void PlayTaskCompleteSound(TaskSettings taskSettings)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            if (!string.IsNullOrEmpty(taskSettings.AdvancedSettings.SpeechTaskCompleted))
            {
                TextToSpeechAsync(taskSettings.AdvancedSettings.SpeechTaskCompleted);
            }
            else if (taskSettings.AdvancedSettings.UseCustomTaskCompletedSound && !string.IsNullOrEmpty(taskSettings.AdvancedSettings.CustomTaskCompletedSoundPath))
            {
                Helpers.PlaySoundAsync(taskSettings.AdvancedSettings.CustomTaskCompletedSoundPath);
            }
            else
            {
                Helpers.PlaySoundAsync(Resources.TaskCompletedSound);
            }
        }
Ejemplo n.º 29
0
        public static void OpenDirectoryIndexer(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            IndexerSettings indexerSettings = taskSettings.ToolsSettingsReference.IndexerSettings;

            indexerSettings.BinaryUnits = Program.Settings.BinaryUnits;
            DirectoryIndexerForm form = new DirectoryIndexerForm(indexerSettings);

            form.UploadRequested += source =>
            {
                WorkerTask task = WorkerTask.CreateTextUploaderTask(source, taskSettings);
                task.Info.FileName = Path.ChangeExtension(task.Info.FileName, indexerSettings.Output.ToString().ToLowerInvariant());
                TaskManager.Start(task);
            };
            form.Show();
        }
Ejemplo n.º 30
0
        private void btnDecodeFromScreen_Click(object sender, EventArgs e)
        {
            try
            {
                Hide();
                Thread.Sleep(250);

                using (Image img = RegionCaptureTasks.GetRegionImage(TaskSettings.GetDefaultTaskSettings().CaptureSettings.SurfaceOptions))
                {
                    if (img != null)
                    {
                        DecodeImage((Bitmap)img);
                    }
                }
            }
            finally
            {
                this.ForceActivate();
            }
        }