AfterCaptureTasks.DeleteFile for be able to delete file after upload recorded videos, after capture form can be used after screen recording

This commit is contained in:
Jaex 2014-07-18 22:13:32 +03:00
parent f5d4cda4d9
commit e7770cf9d4
9 changed files with 104 additions and 60 deletions

View file

@ -79,7 +79,9 @@ public enum AfterCaptureTasks
[Description("Perform actions")]
PerformActions = 1 << 10,
[Description("Upload image to host")]
UploadImageToHost = 1 << 11
UploadImageToHost = 1 << 11,
[Description("Delete file")]
DeleteFile = 1 << 12
}
[Flags]

View file

@ -55,7 +55,7 @@ private void InitializeComponent()
this.lvAfterCaptureTasks.MultiSelect = false;
this.lvAfterCaptureTasks.Name = "lvAfterCaptureTasks";
this.lvAfterCaptureTasks.Scrollable = false;
this.lvAfterCaptureTasks.Size = new System.Drawing.Size(290, 247);
this.lvAfterCaptureTasks.Size = new System.Drawing.Size(290, 268);
this.lvAfterCaptureTasks.TabIndex = 0;
this.lvAfterCaptureTasks.UseCompatibleStateImageBehavior = false;
this.lvAfterCaptureTasks.View = System.Windows.Forms.View.Details;
@ -70,9 +70,9 @@ private void InitializeComponent()
// btnContinue
//
this.btnContinue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnContinue.Location = new System.Drawing.Point(8, 298);
this.btnContinue.Location = new System.Drawing.Point(8, 312);
this.btnContinue.Name = "btnContinue";
this.btnContinue.Size = new System.Drawing.Size(80, 24);
this.btnContinue.Size = new System.Drawing.Size(80, 32);
this.btnContinue.TabIndex = 1;
this.btnContinue.Text = "Continue";
this.btnContinue.UseVisualStyleBackColor = true;
@ -81,9 +81,9 @@ private void InitializeComponent()
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCancel.Location = new System.Drawing.Point(96, 298);
this.btnCancel.Location = new System.Drawing.Point(96, 312);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(80, 24);
this.btnCancel.Size = new System.Drawing.Size(80, 32);
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
@ -102,15 +102,15 @@ private void InitializeComponent()
this.pbImage.FullscreenOnClick = true;
this.pbImage.Location = new System.Drawing.Point(320, 8);
this.pbImage.Name = "pbImage";
this.pbImage.Size = new System.Drawing.Size(376, 314);
this.pbImage.Size = new System.Drawing.Size(376, 336);
this.pbImage.TabIndex = 4;
//
// btnCopy
//
this.btnCopy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCopy.Location = new System.Drawing.Point(184, 298);
this.btnCopy.Location = new System.Drawing.Point(184, 312);
this.btnCopy.Name = "btnCopy";
this.btnCopy.Size = new System.Drawing.Size(80, 24);
this.btnCopy.Size = new System.Drawing.Size(80, 32);
this.btnCopy.TabIndex = 3;
this.btnCopy.Text = "Copy";
this.btnCopy.UseVisualStyleBackColor = true;
@ -125,7 +125,7 @@ private void InitializeComponent()
this.tcTasks.Location = new System.Drawing.Point(8, 8);
this.tcTasks.Name = "tcTasks";
this.tcTasks.SelectedIndex = 0;
this.tcTasks.Size = new System.Drawing.Size(304, 279);
this.tcTasks.Size = new System.Drawing.Size(304, 300);
this.tcTasks.TabIndex = 0;
//
// tpAfterCapture
@ -134,7 +134,7 @@ private void InitializeComponent()
this.tpAfterCapture.Location = new System.Drawing.Point(4, 22);
this.tpAfterCapture.Name = "tpAfterCapture";
this.tpAfterCapture.Padding = new System.Windows.Forms.Padding(3);
this.tpAfterCapture.Size = new System.Drawing.Size(296, 253);
this.tpAfterCapture.Size = new System.Drawing.Size(296, 274);
this.tpAfterCapture.TabIndex = 0;
this.tpAfterCapture.Text = "After capture";
this.tpAfterCapture.UseVisualStyleBackColor = true;
@ -145,7 +145,7 @@ private void InitializeComponent()
this.tpBeforeUpload.Location = new System.Drawing.Point(4, 22);
this.tpBeforeUpload.Name = "tpBeforeUpload";
this.tpBeforeUpload.Padding = new System.Windows.Forms.Padding(3);
this.tpBeforeUpload.Size = new System.Drawing.Size(296, 253);
this.tpBeforeUpload.Size = new System.Drawing.Size(296, 274);
this.tpBeforeUpload.TabIndex = 1;
this.tpBeforeUpload.Text = "Before upload";
this.tpBeforeUpload.UseVisualStyleBackColor = true;
@ -155,7 +155,7 @@ private void InitializeComponent()
this.ucBeforeUpload.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucBeforeUpload.Location = new System.Drawing.Point(3, 3);
this.ucBeforeUpload.Name = "ucBeforeUpload";
this.ucBeforeUpload.Size = new System.Drawing.Size(290, 247);
this.ucBeforeUpload.Size = new System.Drawing.Size(290, 268);
this.ucBeforeUpload.TabIndex = 0;
//
// AfterCaptureForm
@ -163,7 +163,7 @@ private void InitializeComponent()
this.AcceptButton = this.btnContinue;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(704, 330);
this.ClientSize = new System.Drawing.Size(704, 352);
this.Controls.Add(this.tcTasks);
this.Controls.Add(this.btnCopy);
this.Controls.Add(this.btnCancel);

View file

@ -50,7 +50,13 @@ public AfterCaptureForm(Image img, TaskSettings taskSettings)
AfterCaptureTasks = taskSettings.AfterCaptureJob;
AddAfterCaptureItems(AfterCaptureTasks);
pbImage.LoadImage(img);
btnCopy.Visible = img != null;
if (img != null)
{
pbImage.LoadImage(img);
}
}
private void AddAfterCaptureItems(AfterCaptureTasks afterCaptureTasks)

View file

@ -1468,12 +1468,10 @@ private void AfterCapture(Image img, CaptureType captureType, TaskSettings taskS
taskSettings.AfterCaptureJob = taskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AddImageEffects);
}
if (taskSettings.GeneralSettings.ShowAfterCaptureTasksForm)
if (TaskHelpers.ShowAfterCaptureForm(taskSettings, img))
{
TaskHelpers.ShowAfterCaptureForm(img, taskSettings);
UploadManager.RunImageTask(img, taskSettings);
}
UploadManager.RunImageTask(img, taskSettings);
}
}

View file

@ -286,7 +286,7 @@ public void StartRecording(TaskSettings taskSettings)
IsRecording = false;
if (!string.IsNullOrEmpty(path) && File.Exists(path))
if (!string.IsNullOrEmpty(path) && File.Exists(path) && TaskHelpers.ShowAfterCaptureForm(taskSettings))
{
UploadTask task = UploadTask.CreateFileJobTask(path, taskSettings);
TaskManager.Start(task);

View file

@ -226,6 +226,32 @@ public static void ShowResultNotifications(string notificationText, TaskSettings
}
}
public static bool ShowAfterCaptureForm(TaskSettings taskSettings, Image img = null)
{
if (taskSettings.GeneralSettings.ShowAfterCaptureTasksForm)
{
using (AfterCaptureForm afterCaptureForm = new AfterCaptureForm(img, taskSettings))
{
afterCaptureForm.ShowDialog();
switch (afterCaptureForm.Result)
{
case AfterCaptureFormResult.Continue:
taskSettings.AfterCaptureJob = afterCaptureForm.AfterCaptureTasks;
break;
case AfterCaptureFormResult.Copy:
taskSettings.AfterCaptureJob = AfterCaptureTasks.CopyImageToClipboard;
break;
case AfterCaptureFormResult.Cancel:
if (img != null) img.Dispose();
return false;
}
}
}
return true;
}
public static void AnnotateImage(string filePath)
{
AnnotateImage(null, filePath);
@ -586,26 +612,5 @@ public static void OpenFTPClient()
new FTPClientForm(account).Show();
}
}
public static void ShowAfterCaptureForm(Image img, TaskSettings taskSettings)
{
using (AfterCaptureForm afterCaptureForm = new AfterCaptureForm(img, taskSettings))
{
afterCaptureForm.ShowDialog();
switch (afterCaptureForm.Result)
{
case AfterCaptureFormResult.Continue:
taskSettings.AfterCaptureJob = afterCaptureForm.AfterCaptureTasks;
break;
case AfterCaptureFormResult.Copy:
taskSettings.AfterCaptureJob = AfterCaptureTasks.CopyImageToClipboard;
break;
case AfterCaptureFormResult.Cancel:
if (img != null) img.Dispose();
return;
}
}
}
}
}

View file

@ -60,7 +60,15 @@ public string FilePath
set
{
filePath = value;
FileName = Path.GetFileName(filePath);
if (string.IsNullOrEmpty(filePath))
{
FileName = string.Empty;
}
else
{
FileName = Path.GetFileName(filePath);
}
}
}

View file

@ -252,8 +252,38 @@ private void ThreadDoWork()
{
Info.StartTime = DateTime.UtcNow;
DoThreadJob();
try
{
DoThreadJob();
DoUploadJob();
}
finally
{
Dispose();
if (Info.Job == TaskJob.Job && Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.DeleteFile) && !string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath))
{
File.Delete(Info.FilePath);
}
}
if (!StopRequested && Info.Result != null && Info.Result.IsURLExpected && !Info.Result.IsError)
{
if (string.IsNullOrEmpty(Info.Result.URL))
{
Info.Result.Errors.Add("URL is empty.");
}
else
{
DoAfterUploadJobs();
}
}
Info.UploadTime = DateTime.UtcNow;
}
private void DoUploadJob()
{
if (Info.IsUploadJob)
{
if (Program.Settings.ShowUploadWarning && MessageBox.Show(
@ -321,20 +351,6 @@ private void ThreadDoWork()
{
Info.Result.IsURLExpected = false;
}
if (!StopRequested && Info.Result != null && Info.Result.IsURLExpected && !Info.Result.IsError)
{
if (string.IsNullOrEmpty(Info.Result.URL))
{
Info.Result.Errors.Add("URL is empty.");
}
else
{
DoAfterUploadJobs();
}
}
Info.UploadTime = DateTime.UtcNow;
}
private bool DoUpload(int retry = 0)
@ -1167,8 +1183,17 @@ private void OnUploadCompleted()
public void Dispose()
{
if (Data != null) Data.Dispose();
if (tempImage != null) tempImage.Dispose();
if (Data != null)
{
Data.Dispose();
Data = null;
}
if (tempImage != null)
{
tempImage.Dispose();
tempImage = null;
}
}
}
}

View file

@ -110,7 +110,7 @@ public enum FileDestination
Ge_tt,
[Description("Hostr")]
Localhostr,
[Description("Jira")]
[Description("JIRA")]
Jira,
[Description("Shared folder")]
SharedFolder,