예제 #1
0
        private static bool IsUploadConfirmed(int length)
        {
            if (Program.Settings.ShowMultiUploadWarning)
            {
                using (MyMessageBox msgbox = new MyMessageBox(string.Format(Resources.UploadManager_IsUploadConfirmed_Are_you_sure_you_want_to_upload__0__files_, length),
                    "ShareX - " + Resources.UploadManager_IsUploadConfirmed_Upload_files,
                    MessageBoxButtons.YesNo, Resources.UploadManager_IsUploadConfirmed_Don_t_show_this_message_again_))
                {
                    msgbox.ShowDialog();
                    Program.Settings.ShowMultiUploadWarning = !msgbox.IsChecked;
                    return msgbox.DialogResult == DialogResult.Yes;
                }
            }

            return true;
        }
예제 #2
0
        private void DoUploadJob()
        {
            if (Info.IsUploadJob)
            {
                if (Program.Settings.ShowUploadWarning && MessageBox.Show(
                    Resources.UploadTask_DoUploadJob_First_time_upload_warning_text,
                    "ShareX - " + Resources.UploadTask_DoUploadJob_First_time_upload_warning,
                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    Program.Settings.ShowUploadWarning = false;
                    Program.DefaultTaskSettings.AfterCaptureJob = Program.DefaultTaskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.UploadImageToHost);
                    RequestSettingUpdate = true;
                    Stop();
                }

                if (Program.Settings.LargeFileSizeWarning > 0)
                {
                    long dataSize = Program.Settings.BinaryUnits ? Program.Settings.LargeFileSizeWarning * 1024 * 1024 : Program.Settings.LargeFileSizeWarning * 1000 * 1000;
                    if (Data != null && Data.Length > dataSize)
                    {
                        using (MyMessageBox msgbox = new MyMessageBox(Resources.UploadTask_DoUploadJob_You_are_attempting_to_upload_a_large_file, "ShareX",
                            MessageBoxButtons.YesNo, Resources.UploadManager_IsUploadConfirmed_Don_t_show_this_message_again_))
                        {
                            msgbox.ShowDialog();
                            if (msgbox.IsChecked) Program.Settings.LargeFileSizeWarning = 0;
                            if (msgbox.DialogResult == DialogResult.No) Stop();
                        }
                    }
                }

                if (!StopRequested)
                {
                    Program.Settings.ShowUploadWarning = false;

                    if (Program.UploadersConfig == null)
                    {
                        Program.UploaderSettingsResetEvent.WaitOne();
                    }

                    Status = TaskStatus.Working;
                    Info.Status = Resources.UploadTask_DoUploadJob_Uploading;

                    TaskbarManager.SetProgressState(Program.MainForm, TaskbarProgressBarStatus.Normal);

                    DialogResult beforeUploadResult = DialogResult.OK;

                    if (Info.TaskSettings.GeneralSettings.ShowBeforeUploadForm)
                    {
                        BeforeUploadForm form = new BeforeUploadForm(Info);
                        beforeUploadResult = form.ShowDialog();
                    }

                    if (beforeUploadResult == DialogResult.OK)
                    {
                        if (threadWorker != null)
                        {
                            threadWorker.InvokeAsync(OnUploadStarted);
                        }
                        else
                        {
                            OnUploadStarted();
                        }

                        bool isError = DoUpload();

                        if (isError && Program.Settings.MaxUploadFailRetry > 0)
                        {
                            DebugHelper.WriteLine("Upload failed. Retrying upload.");

                            for (int retry = 1; isError && retry <= Program.Settings.MaxUploadFailRetry; retry++)
                            {
                                isError = DoUpload(retry);
                            }
                        }
                    }
                    else if (beforeUploadResult == DialogResult.Cancel)
                    {
                        Info.Result.IsURLExpected = false;
                    }
                }
            }
            else
            {
                Info.Result.IsURLExpected = false;
            }
        }
예제 #3
0
 public static DialogResult Show(string text, string caption, MessageBoxButtons buttons = MessageBoxButtons.OK)
 {
     using (MyMessageBox messageBox = new MyMessageBox(text, caption, buttons))
     {
         return messageBox.ShowDialog();
     }
 }