diff --git a/SCrawler/Content/Pictures/Pause_Blue_16.png b/SCrawler/Content/Pictures/Pause_Blue_16.png new file mode 100644 index 0000000..080871d Binary files /dev/null and b/SCrawler/Content/Pictures/Pause_Blue_16.png differ diff --git a/SCrawler/Download/AutoDownloader.vb b/SCrawler/Download/AutoDownloader.vb index 292db78..a3c0480 100644 --- a/SCrawler/Download/AutoDownloader.vb +++ b/SCrawler/Download/AutoDownloader.vb @@ -142,12 +142,27 @@ Namespace DownloadObjects Private Const Name_ShowNotifications As String = "Notify" #End Region #Region "Declarations" - Friend Property Mode As Modes = Modes.None + Private _Mode As Modes = Modes.None + Friend Property Mode As Modes + Get + Return _Mode + End Get + Set(ByVal m As Modes) + _Mode = m + If _Mode = Modes.None Then [Stop]() + End Set + End Property Friend ReadOnly Property Groups As List(Of String) Friend Property Timer As Integer = DefaultTimer Friend Property ShowNotifications As Boolean = True Friend Property LastDownloadDate As Date = Now.AddYears(-1) Private ReadOnly DateProvider As New ADateTime(ADateTime.Formats.BaseDateTime) + Friend ReadOnly Property Information As String + Get + Return $"Last download date: {LastDownloadDate.ToStringDate(ADateTime.Formats.BaseDateTime)} " & + $"({IIf(Working, "working", "stopped")}{IIf(Working And Pause, ", paused", String.Empty)})" + End Get + End Property Private File As SFile = $"Settings\AutoDownload.xml" Private AThread As Thread #End Region @@ -207,6 +222,11 @@ Namespace DownloadObjects End Sub #End Region #Region "Execution" + Private ReadOnly Property Working As Boolean + Get + Return If(AThread?.IsAlive, False) + End Get + End Property Friend Sub Start() If Not If(AThread?.IsAlive, False) And Not Mode = Modes.None Then AThread = New Thread(New ThreadStart(AddressOf Checker)) @@ -215,13 +235,14 @@ Namespace DownloadObjects End If End Sub Private _StopRequested As Boolean = False + Friend Property Pause As Boolean = False Friend Sub [Stop]() - If If(AThread?.IsAlive, False) Then _StopRequested = True + If Working Then _StopRequested = True End Sub Private Sub Checker() Try - While Not _StopRequested - If LastDownloadDate.AddMinutes(Timer) < Now And Not Downloader.Working Then Download() + While Not _StopRequested Or Downloader.Working + If LastDownloadDate.AddMinutes(Timer) < Now And Not Downloader.Working And Not Pause And Not _StopRequested Then Download() Thread.Sleep(500) End While Catch ex As Exception diff --git a/SCrawler/Download/AutoDownloaderEditorForm.Designer.vb b/SCrawler/Download/AutoDownloaderEditorForm.Designer.vb index 24abdef..de7e4c7 100644 --- a/SCrawler/Download/AutoDownloaderEditorForm.Designer.vb +++ b/SCrawler/Download/AutoDownloaderEditorForm.Designer.vb @@ -57,7 +57,7 @@ Namespace DownloadObjects 'CONTAINER_MAIN.ContentPanel ' CONTAINER_MAIN.ContentPanel.Controls.Add(Me.DEF_GROUP) - CONTAINER_MAIN.ContentPanel.Size = New System.Drawing.Size(476, 217) + CONTAINER_MAIN.ContentPanel.Size = New System.Drawing.Size(476, 242) CONTAINER_MAIN.Dock = System.Windows.Forms.DockStyle.Fill CONTAINER_MAIN.LeftToolStripPanelVisible = False CONTAINER_MAIN.Location = New System.Drawing.Point(0, 0) @@ -90,7 +90,7 @@ Namespace DownloadObjects Me.DEF_GROUP.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 28.0!)) Me.DEF_GROUP.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) Me.DEF_GROUP.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!)) - Me.DEF_GROUP.Size = New System.Drawing.Size(476, 217) + Me.DEF_GROUP.Size = New System.Drawing.Size(476, 242) Me.DEF_GROUP.TabIndex = 0 ' 'TXT_GROUPS @@ -244,6 +244,7 @@ Namespace DownloadObjects Me.Controls.Add(CONTAINER_MAIN) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) + Me.KeyPreview = True Me.MaximizeBox = False Me.MaximumSize = New System.Drawing.Size(492, 281) Me.MinimizeBox = False diff --git a/SCrawler/Download/AutoDownloaderEditorForm.vb b/SCrawler/Download/AutoDownloaderEditorForm.vb index 7404430..02ee24c 100644 --- a/SCrawler/Download/AutoDownloaderEditorForm.vb +++ b/SCrawler/Download/AutoDownloaderEditorForm.vb @@ -61,7 +61,7 @@ Namespace DownloadObjects If Settings.Groups.Count = 0 Then TXT_GROUPS.Clear() : TXT_GROUPS.Enabled = False CH_NOTIFY.Checked = .ShowNotifications TXT_TIMER.Text = .Timer - LBL_LAST_TIME_UP.Text &= .LastDownloadDate.ToStringDate(ADateTime.Formats.BaseDateTime) + LBL_LAST_TIME_UP.Text = .Information End With If Not IsControlForm Then .MyFieldsChecker = New FieldsChecker diff --git a/SCrawler/MainFrame.Designer.vb b/SCrawler/MainFrame.Designer.vb index abaca85..b8db9c4 100644 --- a/SCrawler/MainFrame.Designer.vb +++ b/SCrawler/MainFrame.Designer.vb @@ -104,6 +104,7 @@ Partial Public Class MainFrame : Inherits System.Windows.Forms.Form Me.BTT_TRAY_SHOW_HIDE = New System.Windows.Forms.ToolStripMenuItem() Me.BTT_TRAY_CLOSE = New System.Windows.Forms.ToolStripMenuItem() Me.BTT_TRAY_CLOSE_NO_SCRIPT = New System.Windows.Forms.ToolStripMenuItem() + Me.BTT_DOWN_AUTOMATION_PAUSE = New System.Windows.Forms.ToolStripMenuItem() SEP_1 = New System.Windows.Forms.ToolStripSeparator() SEP_2 = New System.Windows.Forms.ToolStripSeparator() CONTEXT_SEP_1 = New System.Windows.Forms.ToolStripSeparator() @@ -312,7 +313,7 @@ Partial Public Class MainFrame : Inherits System.Windows.Forms.Form 'MENU_DOWN_ALL ' Me.MENU_DOWN_ALL.AutoToolTip = False - Me.MENU_DOWN_ALL.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BTT_DOWN_ALL, Me.BTT_DOWN_SITE, MENU_DOWN_ALL_SEP_1, Me.BTT_DOWN_ALL_FULL, Me.BTT_DOWN_SITE_FULL, MENU_DOWN_ALL_SEP_2, Me.BTT_ADD_NEW_GROUP, MENU_DOWN_ALL_SEP_3, Me.BTT_DOWN_AUTOMATION}) + Me.MENU_DOWN_ALL.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BTT_DOWN_ALL, Me.BTT_DOWN_SITE, MENU_DOWN_ALL_SEP_1, Me.BTT_DOWN_ALL_FULL, Me.BTT_DOWN_SITE_FULL, MENU_DOWN_ALL_SEP_2, Me.BTT_ADD_NEW_GROUP, MENU_DOWN_ALL_SEP_3, Me.BTT_DOWN_AUTOMATION, Me.BTT_DOWN_AUTOMATION_PAUSE}) Me.MENU_DOWN_ALL.Image = Global.SCrawler.My.Resources.Resources.StartPic_01_Green_16 Me.MENU_DOWN_ALL.ImageTransparentColor = System.Drawing.Color.Magenta Me.MENU_DOWN_ALL.Name = "MENU_DOWN_ALL" @@ -765,6 +766,13 @@ Partial Public Class MainFrame : Inherits System.Windows.Forms.Form Me.BTT_TRAY_CLOSE_NO_SCRIPT.ToolTipText = "Close the program without executing the script" Me.BTT_TRAY_CLOSE_NO_SCRIPT.Visible = False ' + 'BTT_DOWN_AUTOMATION_PAUSE + ' + Me.BTT_DOWN_AUTOMATION_PAUSE.Image = Global.SCrawler.My.Resources.Resources.Pause_Blue_16 + Me.BTT_DOWN_AUTOMATION_PAUSE.Name = "BTT_DOWN_AUTOMATION_PAUSE" + Me.BTT_DOWN_AUTOMATION_PAUSE.Size = New System.Drawing.Size(231, 22) + Me.BTT_DOWN_AUTOMATION_PAUSE.Text = "Pause automation" + ' 'MainFrame ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -860,4 +868,5 @@ Partial Public Class MainFrame : Inherits System.Windows.Forms.Form Friend WithEvents BTT_TRAY_CLOSE_NO_SCRIPT As ToolStripMenuItem Friend WithEvents TRAY_CONTEXT As ContextMenuStrip Private WithEvents BTT_DOWN_AUTOMATION As ToolStripMenuItem + Private WithEvents BTT_DOWN_AUTOMATION_PAUSE As ToolStripMenuItem End Class \ No newline at end of file diff --git a/SCrawler/MainFrame.vb b/SCrawler/MainFrame.vb index 1544e69..7d6a164 100644 --- a/SCrawler/MainFrame.vb +++ b/SCrawler/MainFrame.vb @@ -430,6 +430,10 @@ CloseResume: If f.DialogResult = DialogResult.OK AndAlso Not Settings.Automation.Mode = AutoDownloader.Modes.None Then Settings.Automation.Start() End Using End Sub + Private Sub BTT_DOWN_AUTOMATION_PAUSE_Click(sender As Object, e As EventArgs) Handles BTT_DOWN_AUTOMATION_PAUSE.Click + Settings.Automation.Pause = Not Settings.Automation.Pause + BTT_DOWN_AUTOMATION_PAUSE.Checked = Settings.Automation.Pause + End Sub Private Sub BTT_DOWN_VIDEO_Click(sender As Object, e As EventArgs) Handles BTT_DOWN_VIDEO.Click DownloadVideoByURL() End Sub diff --git a/SCrawler/My Project/AssemblyInfo.vb b/SCrawler/My Project/AssemblyInfo.vb index 80df32c..6caed7e 100644 --- a/SCrawler/My Project/AssemblyInfo.vb +++ b/SCrawler/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/SCrawler/My Project/Resources.Designer.vb b/SCrawler/My Project/Resources.Designer.vb index c130c2b..bc5c4ce 100644 --- a/SCrawler/My Project/Resources.Designer.vb +++ b/SCrawler/My Project/Resources.Designer.vb @@ -170,6 +170,16 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized resource of type System.Drawing.Bitmap. + ''' + Friend ReadOnly Property Pause_Blue_16() As System.Drawing.Bitmap + Get + Dim obj As Object = ResourceManager.GetObject("Pause_Blue_16", resourceCulture) + Return CType(obj,System.Drawing.Bitmap) + End Get + End Property + ''' ''' Looks up a localized resource of type System.Drawing.Bitmap. ''' diff --git a/SCrawler/My Project/Resources.resx b/SCrawler/My Project/Resources.resx index ba1a7ba..c749120 100644 --- a/SCrawler/My Project/Resources.resx +++ b/SCrawler/My Project/Resources.resx @@ -196,4 +196,7 @@ ..\Content\Icons\GroupBy_284.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Content\Pictures\Pause_Blue_16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/SCrawler/SCrawler.vbproj b/SCrawler/SCrawler.vbproj index 652e263..45ceeb7 100644 --- a/SCrawler/SCrawler.vbproj +++ b/SCrawler/SCrawler.vbproj @@ -410,6 +410,7 @@ + PreserveNewest