2023.11.12.0

Add special feeds
This commit is contained in:
Andy
2023-11-12 20:34:53 +03:00
parent 12c02580f6
commit f5789862ba
10 changed files with 959 additions and 58 deletions

View File

@@ -26,12 +26,23 @@ Namespace DownloadObjects
Dim SEP_2 As System.Windows.Forms.ToolStripSeparator Dim SEP_2 As System.Windows.Forms.ToolStripSeparator
Dim MENU_VIEW As System.Windows.Forms.ToolStripDropDownButton Dim MENU_VIEW As System.Windows.Forms.ToolStripDropDownButton
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(DownloadFeedForm)) Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(DownloadFeedForm))
Dim MENU_LOAD_SEP_1 As System.Windows.Forms.ToolStripSeparator
Dim MENU_LOAD_SEP_2 As System.Windows.Forms.ToolStripSeparator
Dim MENU_LOAD_SEP_3 As System.Windows.Forms.ToolStripSeparator
Dim MENU_LOAD_SEP_4 As System.Windows.Forms.ToolStripSeparator
Me.OPT_DEFAULT = New System.Windows.Forms.ToolStripMenuItem() Me.OPT_DEFAULT = New System.Windows.Forms.ToolStripMenuItem()
Me.OPT_SUBSCRIPTIONS = New System.Windows.Forms.ToolStripMenuItem() Me.OPT_SUBSCRIPTIONS = New System.Windows.Forms.ToolStripMenuItem()
Me.ToolbarTOP = New System.Windows.Forms.ToolStrip() Me.ToolbarTOP = New System.Windows.Forms.ToolStrip()
Me.MENU_LOAD_SESSION = New System.Windows.Forms.ToolStripDropDownButton() Me.MENU_LOAD_SESSION = New System.Windows.Forms.ToolStripDropDownButton()
Me.BTT_LOAD_SESSION_CURRENT = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_LOAD_SESSION_LAST = New System.Windows.Forms.ToolStripMenuItem() Me.BTT_LOAD_SESSION_LAST = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_LOAD_SESSION_CHOOSE = New System.Windows.Forms.ToolStripMenuItem() Me.BTT_LOAD_SESSION_CHOOSE = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_LOAD_FAV = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_LOAD_SPEC = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_ADD_FAV = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_REMOVE_FAV = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_ADD_SPEC = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_REMOVE_SPEC = New System.Windows.Forms.ToolStripMenuItem()
Me.SEP_0 = New System.Windows.Forms.ToolStripSeparator() Me.SEP_0 = New System.Windows.Forms.ToolStripSeparator()
Me.MENU_DOWN = New System.Windows.Forms.ToolStripDropDownButton() Me.MENU_DOWN = New System.Windows.Forms.ToolStripDropDownButton()
Me.BTT_DOWN_ALL = New System.Windows.Forms.ToolStripMenuItem() Me.BTT_DOWN_ALL = New System.Windows.Forms.ToolStripMenuItem()
@@ -39,10 +50,18 @@ Namespace DownloadObjects
Me.BTT_REFRESH = New System.Windows.Forms.ToolStripButton() Me.BTT_REFRESH = New System.Windows.Forms.ToolStripButton()
Me.BTT_CLEAR = New System.Windows.Forms.ToolStripButton() Me.BTT_CLEAR = New System.Windows.Forms.ToolStripButton()
Me.TP_DATA = New System.Windows.Forms.TableLayoutPanel() Me.TP_DATA = New System.Windows.Forms.TableLayoutPanel()
Me.BTT_LOAD_SESSION_CURRENT = New System.Windows.Forms.ToolStripMenuItem() Me.BTT_FEED_CLEAR_FAV = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_CLEAR_SPEC = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_DELETE_SPEC = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_DELETE_DAILY_LIST = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_DELETE_DAILY_DATE = New System.Windows.Forms.ToolStripMenuItem()
SEP_1 = New System.Windows.Forms.ToolStripSeparator() SEP_1 = New System.Windows.Forms.ToolStripSeparator()
SEP_2 = New System.Windows.Forms.ToolStripSeparator() SEP_2 = New System.Windows.Forms.ToolStripSeparator()
MENU_VIEW = New System.Windows.Forms.ToolStripDropDownButton() MENU_VIEW = New System.Windows.Forms.ToolStripDropDownButton()
MENU_LOAD_SEP_1 = New System.Windows.Forms.ToolStripSeparator()
MENU_LOAD_SEP_2 = New System.Windows.Forms.ToolStripSeparator()
MENU_LOAD_SEP_3 = New System.Windows.Forms.ToolStripSeparator()
MENU_LOAD_SEP_4 = New System.Windows.Forms.ToolStripSeparator()
Me.ToolbarTOP.SuspendLayout() Me.ToolbarTOP.SuspendLayout()
Me.SuspendLayout() Me.SuspendLayout()
' '
@@ -78,6 +97,21 @@ Namespace DownloadObjects
Me.OPT_SUBSCRIPTIONS.Size = New System.Drawing.Size(145, 22) Me.OPT_SUBSCRIPTIONS.Size = New System.Drawing.Size(145, 22)
Me.OPT_SUBSCRIPTIONS.Text = "Subscriptions" Me.OPT_SUBSCRIPTIONS.Text = "Subscriptions"
' '
'MENU_LOAD_SEP_1
'
MENU_LOAD_SEP_1.Name = "MENU_LOAD_SEP_1"
MENU_LOAD_SEP_1.Size = New System.Drawing.Size(264, 6)
'
'MENU_LOAD_SEP_2
'
MENU_LOAD_SEP_2.Name = "MENU_LOAD_SEP_2"
MENU_LOAD_SEP_2.Size = New System.Drawing.Size(264, 6)
'
'MENU_LOAD_SEP_3
'
MENU_LOAD_SEP_3.Name = "MENU_LOAD_SEP_3"
MENU_LOAD_SEP_3.Size = New System.Drawing.Size(264, 6)
'
'ToolbarTOP 'ToolbarTOP
' '
Me.ToolbarTOP.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden Me.ToolbarTOP.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden
@@ -90,27 +124,76 @@ Namespace DownloadObjects
'MENU_LOAD_SESSION 'MENU_LOAD_SESSION
' '
Me.MENU_LOAD_SESSION.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image Me.MENU_LOAD_SESSION.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.MENU_LOAD_SESSION.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BTT_LOAD_SESSION_CURRENT, Me.BTT_LOAD_SESSION_LAST, Me.BTT_LOAD_SESSION_CHOOSE}) Me.MENU_LOAD_SESSION.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BTT_LOAD_SESSION_CURRENT, Me.BTT_LOAD_SESSION_LAST, Me.BTT_LOAD_SESSION_CHOOSE, MENU_LOAD_SEP_1, Me.BTT_LOAD_FAV, Me.BTT_LOAD_SPEC, MENU_LOAD_SEP_2, Me.BTT_FEED_ADD_FAV, Me.BTT_FEED_REMOVE_FAV, MENU_LOAD_SEP_3, Me.BTT_FEED_ADD_SPEC, Me.BTT_FEED_REMOVE_SPEC, MENU_LOAD_SEP_4, Me.BTT_FEED_CLEAR_FAV, Me.BTT_FEED_CLEAR_SPEC, Me.BTT_FEED_DELETE_SPEC, Me.BTT_FEED_DELETE_DAILY_LIST, Me.BTT_FEED_DELETE_DAILY_DATE})
Me.MENU_LOAD_SESSION.Image = Global.SCrawler.My.Resources.Resources.ArrowDownPic_Blue_24 Me.MENU_LOAD_SESSION.Image = Global.SCrawler.My.Resources.Resources.ArrowDownPic_Blue_24
Me.MENU_LOAD_SESSION.ImageTransparentColor = System.Drawing.Color.Magenta Me.MENU_LOAD_SESSION.ImageTransparentColor = System.Drawing.Color.Magenta
Me.MENU_LOAD_SESSION.Name = "MENU_LOAD_SESSION" Me.MENU_LOAD_SESSION.Name = "MENU_LOAD_SESSION"
Me.MENU_LOAD_SESSION.Size = New System.Drawing.Size(29, 22) Me.MENU_LOAD_SESSION.Size = New System.Drawing.Size(29, 22)
Me.MENU_LOAD_SESSION.Text = "Load session" Me.MENU_LOAD_SESSION.Text = "Load session"
' '
'BTT_LOAD_SESSION_CURRENT
'
Me.BTT_LOAD_SESSION_CURRENT.Image = Global.SCrawler.My.Resources.Resources.ArrowDownPic_Blue_24
Me.BTT_LOAD_SESSION_CURRENT.Name = "BTT_LOAD_SESSION_CURRENT"
Me.BTT_LOAD_SESSION_CURRENT.Size = New System.Drawing.Size(267, 22)
Me.BTT_LOAD_SESSION_CURRENT.Text = "Load current session"
'
'BTT_LOAD_SESSION_LAST 'BTT_LOAD_SESSION_LAST
' '
Me.BTT_LOAD_SESSION_LAST.Image = Global.SCrawler.My.Resources.Resources.ArrowDownPic_Blue_24 Me.BTT_LOAD_SESSION_LAST.Image = Global.SCrawler.My.Resources.Resources.ArrowDownPic_Blue_24
Me.BTT_LOAD_SESSION_LAST.Name = "BTT_LOAD_SESSION_LAST" Me.BTT_LOAD_SESSION_LAST.Name = "BTT_LOAD_SESSION_LAST"
Me.BTT_LOAD_SESSION_LAST.Size = New System.Drawing.Size(189, 22) Me.BTT_LOAD_SESSION_LAST.Size = New System.Drawing.Size(267, 22)
Me.BTT_LOAD_SESSION_LAST.Text = "Load last session" Me.BTT_LOAD_SESSION_LAST.Text = "Load last session"
' '
'BTT_LOAD_SESSION_CHOOSE 'BTT_LOAD_SESSION_CHOOSE
' '
Me.BTT_LOAD_SESSION_CHOOSE.Image = Global.SCrawler.My.Resources.Resources.ArrowDownPic_Blue_24 Me.BTT_LOAD_SESSION_CHOOSE.Image = Global.SCrawler.My.Resources.Resources.ArrowDownPic_Blue_24
Me.BTT_LOAD_SESSION_CHOOSE.Name = "BTT_LOAD_SESSION_CHOOSE" Me.BTT_LOAD_SESSION_CHOOSE.Name = "BTT_LOAD_SESSION_CHOOSE"
Me.BTT_LOAD_SESSION_CHOOSE.Size = New System.Drawing.Size(189, 22) Me.BTT_LOAD_SESSION_CHOOSE.Size = New System.Drawing.Size(267, 22)
Me.BTT_LOAD_SESSION_CHOOSE.Text = "Select loading session" Me.BTT_LOAD_SESSION_CHOOSE.Text = "Select loading session"
' '
'BTT_LOAD_FAV
'
Me.BTT_LOAD_FAV.Image = Global.SCrawler.My.Resources.Resources.HeartPic_32
Me.BTT_LOAD_FAV.Name = "BTT_LOAD_FAV"
Me.BTT_LOAD_FAV.Size = New System.Drawing.Size(267, 22)
Me.BTT_LOAD_FAV.Text = "Load Favorite"
'
'BTT_LOAD_SPEC
'
Me.BTT_LOAD_SPEC.Image = Global.SCrawler.My.Resources.Resources.RSSPic_512
Me.BTT_LOAD_SPEC.Name = "BTT_LOAD_SPEC"
Me.BTT_LOAD_SPEC.Size = New System.Drawing.Size(267, 22)
Me.BTT_LOAD_SPEC.Text = "Load special feed"
'
'BTT_FEED_ADD_FAV
'
Me.BTT_FEED_ADD_FAV.Image = Global.SCrawler.My.Resources.Resources.HeartPic_32
Me.BTT_FEED_ADD_FAV.Name = "BTT_FEED_ADD_FAV"
Me.BTT_FEED_ADD_FAV.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_ADD_FAV.Text = "Add checked to Favorite"
'
'BTT_FEED_REMOVE_FAV
'
Me.BTT_FEED_REMOVE_FAV.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24
Me.BTT_FEED_REMOVE_FAV.Name = "BTT_FEED_REMOVE_FAV"
Me.BTT_FEED_REMOVE_FAV.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_REMOVE_FAV.Text = "Remove checked from Favorite"
'
'BTT_FEED_ADD_SPEC
'
Me.BTT_FEED_ADD_SPEC.Image = Global.SCrawler.My.Resources.Resources.RSSPic_512
Me.BTT_FEED_ADD_SPEC.Name = "BTT_FEED_ADD_SPEC"
Me.BTT_FEED_ADD_SPEC.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_ADD_SPEC.Text = "Add checked to special feed..."
'
'BTT_FEED_REMOVE_SPEC
'
Me.BTT_FEED_REMOVE_SPEC.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24
Me.BTT_FEED_REMOVE_SPEC.Name = "BTT_FEED_REMOVE_SPEC"
Me.BTT_FEED_REMOVE_SPEC.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_REMOVE_SPEC.Text = "Remove checked from special feed..."
'
'SEP_0 'SEP_0
' '
Me.SEP_0.Name = "SEP_0" Me.SEP_0.Name = "SEP_0"
@@ -186,12 +269,45 @@ Namespace DownloadObjects
Me.TP_DATA.Size = New System.Drawing.Size(484, 436) Me.TP_DATA.Size = New System.Drawing.Size(484, 436)
Me.TP_DATA.TabIndex = 1 Me.TP_DATA.TabIndex = 1
' '
'BTT_LOAD_SESSION_CURRENT 'MENU_LOAD_SEP_4
' '
Me.BTT_LOAD_SESSION_CURRENT.Image = Global.SCrawler.My.Resources.Resources.ArrowDownPic_Blue_24 MENU_LOAD_SEP_4.Name = "MENU_LOAD_SEP_4"
Me.BTT_LOAD_SESSION_CURRENT.Name = "BTT_LOAD_SESSION_CURRENT" MENU_LOAD_SEP_4.Size = New System.Drawing.Size(264, 6)
Me.BTT_LOAD_SESSION_CURRENT.Size = New System.Drawing.Size(189, 22) '
Me.BTT_LOAD_SESSION_CURRENT.Text = "Load current session" 'BTT_FEED_CLEAR_FAV
'
Me.BTT_FEED_CLEAR_FAV.Image = Global.SCrawler.My.Resources.Resources.BrushToolPic_16
Me.BTT_FEED_CLEAR_FAV.Name = "BTT_FEED_CLEAR_FAV"
Me.BTT_FEED_CLEAR_FAV.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_CLEAR_FAV.Text = "Clear Favorite"
'
'BTT_FEED_CLEAR_SPEC
'
Me.BTT_FEED_CLEAR_SPEC.Image = Global.SCrawler.My.Resources.Resources.BrushToolPic_16
Me.BTT_FEED_CLEAR_SPEC.Name = "BTT_FEED_CLEAR_SPEC"
Me.BTT_FEED_CLEAR_SPEC.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_CLEAR_SPEC.Text = "Clear special feed..."
'
'BTT_FEED_DELETE_SPEC
'
Me.BTT_FEED_DELETE_SPEC.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24
Me.BTT_FEED_DELETE_SPEC.Name = "BTT_FEED_DELETE_SPEC"
Me.BTT_FEED_DELETE_SPEC.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_DELETE_SPEC.Text = "Delete special feed..."
'
'BTT_FEED_DELETE_DAILY_LIST
'
Me.BTT_FEED_DELETE_DAILY_LIST.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24
Me.BTT_FEED_DELETE_DAILY_LIST.Name = "BTT_FEED_DELETE_DAILY_LIST"
Me.BTT_FEED_DELETE_DAILY_LIST.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_DELETE_DAILY_LIST.Text = "Delete daily feed (by list)"
'
'BTT_FEED_DELETE_DAILY_DATE
'
Me.BTT_FEED_DELETE_DAILY_DATE.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24
Me.BTT_FEED_DELETE_DAILY_DATE.Name = "BTT_FEED_DELETE_DAILY_DATE"
Me.BTT_FEED_DELETE_DAILY_DATE.Size = New System.Drawing.Size(267, 22)
Me.BTT_FEED_DELETE_DAILY_DATE.Text = "Delete daily feed (by date)"
' '
'DownloadFeedForm 'DownloadFeedForm
' '
@@ -227,5 +343,16 @@ Namespace DownloadObjects
Private WithEvents BTT_DOWN_ALL As ToolStripMenuItem Private WithEvents BTT_DOWN_ALL As ToolStripMenuItem
Private WithEvents BTT_DOWN_SELECTED As ToolStripMenuItem Private WithEvents BTT_DOWN_SELECTED As ToolStripMenuItem
Private WithEvents BTT_LOAD_SESSION_CURRENT As ToolStripMenuItem Private WithEvents BTT_LOAD_SESSION_CURRENT As ToolStripMenuItem
Private WithEvents BTT_FEED_ADD_FAV As ToolStripMenuItem
Private WithEvents BTT_FEED_REMOVE_FAV As ToolStripMenuItem
Private WithEvents BTT_FEED_ADD_SPEC As ToolStripMenuItem
Private WithEvents BTT_FEED_REMOVE_SPEC As ToolStripMenuItem
Private WithEvents BTT_LOAD_FAV As ToolStripMenuItem
Private WithEvents BTT_LOAD_SPEC As ToolStripMenuItem
Private WithEvents BTT_FEED_CLEAR_FAV As ToolStripMenuItem
Private WithEvents BTT_FEED_CLEAR_SPEC As ToolStripMenuItem
Private WithEvents BTT_FEED_DELETE_SPEC As ToolStripMenuItem
Private WithEvents BTT_FEED_DELETE_DAILY_LIST As ToolStripMenuItem
Private WithEvents BTT_FEED_DELETE_DAILY_DATE As ToolStripMenuItem
End Class End Class
End Namespace End Namespace

View File

@@ -135,7 +135,19 @@
MeQCkYEBAD3tUdo+/cEPAAAAAElFTkSuQmCC MeQCkYEBAD3tUdo+/cEPAAAAAElFTkSuQmCC
</value> </value>
</data> </data>
<metadata name="MENU_LOAD_SEP_1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="MENU_LOAD_SEP_2.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="MENU_LOAD_SEP_3.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="ToolbarTOP.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="ToolbarTOP.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="MENU_LOAD_SEP_4.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root> </root>

View File

@@ -13,6 +13,7 @@ Imports PersonalUtilities.Forms.Toolbars
Imports PersonalUtilities.Tools Imports PersonalUtilities.Tools
Imports RCI = PersonalUtilities.Forms.Toolbars.RangeSwitcherToolbar.ControlItem Imports RCI = PersonalUtilities.Forms.Toolbars.RangeSwitcherToolbar.ControlItem
Imports UserMediaD = SCrawler.DownloadObjects.TDownloader.UserMediaD Imports UserMediaD = SCrawler.DownloadObjects.TDownloader.UserMediaD
Imports DTSModes = PersonalUtilities.Forms.DateTimeSelectionForm.Modes
Namespace DownloadObjects Namespace DownloadObjects
Friend Class DownloadFeedForm Friend Class DownloadFeedForm
#Region "Declarations" #Region "Declarations"
@@ -26,6 +27,8 @@ Namespace DownloadObjects
Private ReadOnly FilterSubscriptions As New FPredicate(Of UserMediaD)(Function(d) If(d.User?.IsSubscription, False)) Private ReadOnly FilterSubscriptions As New FPredicate(Of UserMediaD)(Function(d) If(d.User?.IsSubscription, False))
Private ReadOnly FilterUsers As New FPredicate(Of UserMediaD)(Function(d) Not FilterSubscriptions.Invoke(d)) Private ReadOnly FilterUsers As New FPredicate(Of UserMediaD)(Function(d) Not FilterSubscriptions.Invoke(d))
Private ReadOnly FileNotExist As New FPredicate(Of UserMediaD)(Function(d) Not d.Data.File.Exists And Not FilterSubscriptions.Invoke(d)) Private ReadOnly FileNotExist As New FPredicate(Of UserMediaD)(Function(d) Not d.Data.File.Exists And Not FilterSubscriptions.Invoke(d))
Private ReadOnly SessionDateStringProvider As New CustomProvider(Function(v As SFile) AConvert(Of String)(AConvert(Of Date)(v.Name, SessionDateTimeProvider, v.Name),
DateTimeDefaultProvider, v.Name))
Private BttRefreshToolTipText As String = "Refresh data list" Private BttRefreshToolTipText As String = "Refresh data list"
Private CenterImage As Boolean = False Private CenterImage As Boolean = False
Private NumberOfVisibleImages As Integer = 1 Private NumberOfVisibleImages As Integer = 1
@@ -66,6 +69,22 @@ Namespace DownloadObjects
End With End With
ToolbarTOP.Items.AddRange({New ToolStripSeparator, BTT_DELETE_SELECTED}) ToolbarTOP.Items.AddRange({New ToolStripSeparator, BTT_DELETE_SELECTED})
With Settings With Settings
With .Feeds
.Load()
AddHandler .FeedAdded, AddressOf Feed_FeedAdded
AddHandler .FeedRemoved, AddressOf Feed_FeedRemoved
If .Count > 0 Then
For Each feed As FeedSpecial In .Self
If Not feed.IsFavorite Then
AddNewFeedItem(BTT_LOAD_SPEC, feed, My.Resources.RSSPic_512, AddressOf Feed_SPEC_LOAD)
AddNewFeedItem(BTT_FEED_ADD_SPEC, feed, My.Resources.RSSPic_512, AddressOf Feed_SPEC_ADD)
AddNewFeedItem(BTT_FEED_REMOVE_SPEC, feed, My.Resources.RSSPic_512, AddressOf Feed_SPEC_REMOVE)
AddNewFeedItem(BTT_FEED_DELETE_SPEC, feed, My.Resources.DeletePic_24, AddressOf Feed_SPEC_DELETE)
AddNewFeedItem(BTT_FEED_CLEAR_SPEC, feed, My.Resources.BrushToolPic_16, AddressOf Feed_SPEC_CLEAR)
End If
Next
End If
End With
If .FeedOpenLastMode Then If .FeedOpenLastMode Then
If .FeedLastModeSubscriptions Then OPT_SUBSCRIPTIONS.Checked = True Else OPT_DEFAULT.Checked = True If .FeedLastModeSubscriptions Then OPT_SUBSCRIPTIONS.Checked = True Else OPT_DEFAULT.Checked = True
Else Else
@@ -93,6 +112,85 @@ Namespace DownloadObjects
If e.KeyCode = Keys.F5 Then RefillList() : e.Handled = True If e.KeyCode = Keys.F5 Then RefillList() : e.Handled = True
End Sub End Sub
#End Region #End Region
#Region "Feeds handlers"
Private Sub AddNewFeedItem(ByVal Destination As ToolStripMenuItem, ByVal Feed As FeedSpecial, ByVal Image As Image, ByVal Handler As EventHandler,
Optional ByVal Insert As Boolean = False)
Dim item As New ToolStripMenuItem(Feed.Name, Image) With {.Tag = Feed}
AddHandler item.Click, Handler
ControlInvokeFast(ToolbarTOP, Destination, Sub()
If Destination.DropDownItems.Count > 0 And Insert Then
Destination.DropDownItems.Insert(0, item)
Else
Destination.DropDownItems.Add(item)
End If
End Sub, EDP.None)
End Sub
Private Sub Feed_FeedAdded(ByVal Source As FeedSpecialCollection, ByVal Feed As FeedSpecial)
AddNewFeedItem(BTT_LOAD_SPEC, Feed, My.Resources.RSSPic_512, AddressOf Feed_SPEC_LOAD, True)
AddNewFeedItem(BTT_FEED_ADD_SPEC, Feed, My.Resources.RSSPic_512, AddressOf Feed_SPEC_ADD, True)
AddNewFeedItem(BTT_FEED_REMOVE_SPEC, Feed, My.Resources.RSSPic_512, AddressOf Feed_SPEC_REMOVE, True)
AddNewFeedItem(BTT_FEED_DELETE_SPEC, Feed, My.Resources.DeletePic_24, AddressOf Feed_SPEC_DELETE, True)
AddNewFeedItem(BTT_FEED_CLEAR_SPEC, Feed, My.Resources.BrushToolPic_16, AddressOf Feed_SPEC_CLEAR, True)
End Sub
Private Overloads Sub Feed_FeedRemoved(ByVal Source As FeedSpecialCollection, ByVal Feed As FeedSpecial)
Feed_FeedRemoved(BTT_LOAD_SPEC, Feed)
Feed_FeedRemoved(BTT_FEED_ADD_SPEC, Feed)
Feed_FeedRemoved(BTT_FEED_REMOVE_SPEC, Feed)
Feed_FeedRemoved(BTT_FEED_DELETE_SPEC, Feed)
Feed_FeedRemoved(BTT_FEED_CLEAR_SPEC, Feed)
End Sub
Private Overloads Sub Feed_FeedRemoved(ByVal Destination As ToolStripMenuItem, ByVal Feed As FeedSpecial)
Try
With Destination
ControlInvokeFast(ToolbarTOP, .Self,
Sub()
If .DropDownItems.Count > 0 Then
Dim item As Object
For i% = .DropDownItems.Count - 1 To 0 Step -1
item = .DropDownItems(i)
If TypeOf item Is ToolStripMenuItem AndAlso Feed.Equals(DirectCast(item, ToolStripMenuItem).Tag) Then
With DirectCast(item, ToolStripMenuItem) : .Tag = Nothing : .Dispose() : End With
'.DropDownItems.RemoveAt(i)
End If
Next
End If
End Sub, EDP.None)
End With
Catch ex As Exception
ErrorsDescriber.Execute(EDP.SendToLog, ex, "Feed removed")
MainFrameObj.UpdateLogButton()
End Try
End Sub
Private Sub Feed_SPEC_LOAD(ByVal Source As ToolStripMenuItem, ByVal e As EventArgs)
Dim f As FeedSpecial = Source.Tag
If Not f Is Nothing AndAlso Not f.Disposed Then
DataList.Clear()
If f.Count > 0 Then DataList.ListAddList(f) : CleanDataList()
RefillList(False)
End If
End Sub
Private Sub Feed_SPEC_ADD(ByVal Source As ToolStripMenuItem, ByVal e As EventArgs)
Dim f As FeedSpecial = Source.Tag
If Not f Is Nothing AndAlso Not f.Disposed Then f.Add(GetCheckedMedia())
End Sub
Private Sub Feed_SPEC_CLEAR(ByVal Source As ToolStripMenuItem, ByVal e As EventArgs)
Dim f As FeedSpecial = Source.Tag
If Not f Is Nothing AndAlso Not f.Disposed Then
If MsgBoxE({$"Are you sure you want to clear the '{f.Name}' feed?", "Clear feed"}, vbExclamation,,, {"Process", "Cancel"}) = 0 Then f.Clear()
End If
End Sub
Private Sub Feed_SPEC_REMOVE(ByVal Source As ToolStripMenuItem, ByVal e As EventArgs)
Dim f As FeedSpecial = Source.Tag
If Not f Is Nothing AndAlso Not f.Disposed Then f.Remove(GetCheckedMedia())
End Sub
Private Sub Feed_SPEC_DELETE(ByVal Source As ToolStripMenuItem, ByVal e As EventArgs)
Dim f As FeedSpecial = Source.Tag
If Not f Is Nothing AndAlso Not f.Disposed Then
If MsgBoxE({$"Are you sure you want to delete the '{f.Name}' feed?", "Delete feed"}, vbExclamation,,, {"Process", "Cancel"}) = 0 AndAlso
f.Delete() Then Feed_FeedRemoved(Settings.Feeds, f)
End If
End Sub
#End Region
#Region "Settings" #Region "Settings"
Friend Sub UpdateSettings() Friend Sub UpdateSettings()
With Settings With Settings
@@ -151,13 +249,6 @@ Namespace DownloadObjects
End Sub End Sub
#End Region #End Region
#Region "Refill" #Region "Refill"
Friend Sub Downloader_FilesChanged(ByVal Added As Boolean)
ControlInvokeFast(ToolbarTOP, BTT_REFRESH, Sub() BTT_REFRESH.ToolTipText = If(Added, "New files found", "Some files have been removed"))
BTT_REFRESH.ControlChangeColor(ToolbarTOP, Added, False)
End Sub
Private Sub BTT_REFRESH_Click(sender As Object, e As EventArgs) Handles BTT_REFRESH.Click
RefillList()
End Sub
Private Sub RefillList(Optional ByVal RefillDataList As Boolean = True) Private Sub RefillList(Optional ByVal RefillDataList As Boolean = True)
DataPopulated = False DataPopulated = False
If RefillDataList Then If RefillDataList Then
@@ -176,11 +267,20 @@ Namespace DownloadObjects
MyRange_IndexChanged(MyRange, Nothing) MyRange_IndexChanged(MyRange, Nothing)
End If End If
End Sub End Sub
Private Sub BTT_CLEAR_Click(sender As Object, e As EventArgs) Handles BTT_CLEAR.Click Private Sub CleanDataList()
Downloader.Files.Clear() If DataList.Count > 0 Then
ClearTable() If IsSubscription Then
RefillList() DataList.RemoveAll(FilterUsers)
Else
DataList.RemoveAll(FilterSubscriptions)
DataList.RemoveAll(FileNotExist)
End If
End If
End Sub End Sub
#End Region
#Region "Toolbar controls"
#Region "Feed"
#Region "Load"
Private Sub BTT_LOAD_SESSION_CURRENT_Click(sender As Object, e As EventArgs) Handles BTT_LOAD_SESSION_CURRENT.Click Private Sub BTT_LOAD_SESSION_CURRENT_Click(sender As Object, e As EventArgs) Handles BTT_LOAD_SESSION_CURRENT.Click
RefillList() RefillList()
End Sub End Sub
@@ -190,7 +290,8 @@ Namespace DownloadObjects
Private Sub BTT_LOAD_SESSION_CHOOSE_Click(sender As Object, e As EventArgs) Handles BTT_LOAD_SESSION_CHOOSE.Click Private Sub BTT_LOAD_SESSION_CHOOSE_Click(sender As Object, e As EventArgs) Handles BTT_LOAD_SESSION_CHOOSE.Click
SessionChooser(False) SessionChooser(False)
End Sub End Sub
Private Sub SessionChooser(ByVal GetLast As Boolean) Private Sub SessionChooser(ByVal GetLast As Boolean, Optional ByVal GetFilesOnly As Boolean = False,
Optional ByRef ResultFilesList As List(Of SFile) = Nothing)
Try Try
Downloader.ClearSessions() Downloader.ClearSessions()
Dim f As SFile = TDownloader.SessionsPath.CSFileP Dim f As SFile = TDownloader.SessionsPath.CSFileP
@@ -198,16 +299,9 @@ Namespace DownloadObjects
Dim m As New MMessage("Saved sessions not selected", "Sessions",, vbExclamation) Dim m As New MMessage("Saved sessions not selected", "Sessions",, vbExclamation)
Dim x As XmlFile Dim x As XmlFile
Dim lcr As New ListAddParams(LAP.NotContainsOnly + LAP.IgnoreICopier) Dim lcr As New ListAddParams(LAP.NotContainsOnly + LAP.IgnoreICopier)
Dim __clearList As Action = Sub()
If IsSubscription Then
DataList.RemoveAll(FilterUsers)
Else
DataList.RemoveAll(FilterSubscriptions)
DataList.RemoveAll(FileNotExist)
End If
End Sub
Dim __getFiles As Func(Of Boolean) = Function() As Boolean Dim __getFiles As Func(Of Boolean) = Function() As Boolean
If f.Exists(SFO.Path, False) Then fList = SFile.GetFiles(f, "*.xml",, EDP.ReturnValue) If f.Exists(SFO.Path, False) Then fList = SFile.GetFiles(f, "*.xml",, EDP.ReturnValue)
If fList.ListExists Then fList.RemoveAll(Settings.Feeds.FeedSpecialRemover)
If fList.ListExists Then If fList.ListExists Then
fList.Reverse() fList.Reverse()
Return True Return True
@@ -216,27 +310,32 @@ Namespace DownloadObjects
End If End If
End Function End Function
If Not GetLast Then __getFiles.Invoke If Not GetLast Then __getFiles.Invoke
If Not GetLast AndAlso fList.ListExists Then If Not GetLast And GetFilesOnly And Not fList.ListExists Then
MsgBoxE({"No session files found", "Get session files"}, vbExclamation)
ElseIf Not GetLast AndAlso fList.ListExists Then
Using chooser As New SimpleListForm(Of SFile)(fList, Settings.Design) With { Using chooser As New SimpleListForm(Of SFile)(fList, Settings.Design) With {
.FormText = "Sessions", .FormText = "Sessions",
.Icon = My.Resources.ArrowDownIcon_Blue_24, .Icon = My.Resources.ArrowDownIcon_Blue_24,
.Mode = SimpleListFormModes.CheckedItems, .Mode = SimpleListFormModes.CheckedItems,
.Provider = New CustomProvider(Function(v As SFile) AConvert(Of String)(AConvert(Of Date)(v.Name, SessionDateTimeProvider, v.Name), .Provider = SessionDateStringProvider
DateTimeDefaultProvider, v.Name))
} }
chooser.ClearButtons() chooser.ClearButtons()
If chooser.ShowDialog = DialogResult.OK Then If chooser.ShowDialog = DialogResult.OK Then
fList = chooser.DataResult fList = chooser.DataResult
If fList.ListExists Then If fList.ListExists Then
DataList.Clear() If GetFilesOnly Then
For Each f In fList ResultFilesList.AddRange(fList)
x = New XmlFile(f,, False) With {.AllowSameNames = True, .XmlReadOnly = True} Else
x.LoadData() DataList.Clear()
If x.Count > 0 Then DataList.ListAddList(x, lcr) For Each f In fList
x.Dispose() x = New XmlFile(f,, False) With {.AllowSameNames = True, .XmlReadOnly = True}
Next x.LoadData()
__clearList.Invoke If x.Count > 0 Then DataList.ListAddList(x, lcr)
RefillList(False) x.Dispose()
Next
CleanDataList()
RefillList(False)
End If
Else Else
MsgBoxE(m) MsgBoxE(m)
End If End If
@@ -254,7 +353,7 @@ Namespace DownloadObjects
x.LoadData() x.LoadData()
If x.Count > 0 Then DataList.Clear() : DataList.ListAddList(x, lcr) If x.Count > 0 Then DataList.Clear() : DataList.ListAddList(x, lcr)
x.Dispose() x.Dispose()
__clearList.Invoke CleanDataList()
RefillList(False) RefillList(False)
Else Else
m.Text = "Saved sessions not found" m.Text = "Saved sessions not found"
@@ -265,6 +364,147 @@ Namespace DownloadObjects
ErrorsDescriber.Execute(EDP.SendToLog, ex, $"[DownloadObjects.DownloadFeedForm.SessionChooser({GetLast})]") ErrorsDescriber.Execute(EDP.SendToLog, ex, $"[DownloadObjects.DownloadFeedForm.SessionChooser({GetLast})]")
End Try End Try
End Sub End Sub
#End Region
#Region "Load fav, spec"
Private Sub BTT_LOAD_FAV_Click(sender As Object, e As EventArgs) Handles BTT_LOAD_FAV.Click
DataList.Clear()
With Settings.Feeds.Favorite
.RemoveNotExist(FileNotExist)
If .Count > 0 Then DataList.AddRange(.Self) : CleanDataList() : RefillList(False)
End With
End Sub
Private Sub BTT_LOAD_SPEC_Click(sender As Object, e As EventArgs) Handles BTT_LOAD_SPEC.Click
With FeedSpecialCollection.ChooseFeeds(False)
If .ListExists Then
DataList.Clear()
Dim d As New List(Of UserMediaD)
.ForEach(Sub(ByVal f As FeedSpecial)
f.RemoveNotExist(FileNotExist)
If f.Count > 0 Then d.AddRange(f)
End Sub)
If d.Count > 0 Then DataList.ListAddList(d.Distinct)
CleanDataList()
RefillList(False)
End If
End With
End Sub
#End Region
#Region "Add remove fav spec"
Private Sub BTT_FEED_ADD_FAV_Click(sender As Object, e As EventArgs) Handles BTT_FEED_ADD_FAV.Click
Settings.Feeds.Favorite.Add(GetCheckedMedia())
End Sub
Private Sub BTT_FEED_REMOVE_FAV_Click(sender As Object, e As EventArgs) Handles BTT_FEED_REMOVE_FAV.Click
Settings.Feeds.Favorite.Remove(GetCheckedMedia())
End Sub
Private Sub BTT_FEED_ADD_SPEC_Click(sender As Object, e As EventArgs) Handles BTT_FEED_ADD_SPEC.Click
Dim c As IEnumerable(Of UserMediaD) = GetCheckedMedia()
If c.ListExists Then
With FeedSpecialCollection.ChooseFeeds(False)
If .ListExists Then .ForEach(Sub(f) f.Add(c))
End With
Else
MsgBoxE({"You haven't selected media to add to your feed(s)", "Add to feed(s)"}, vbExclamation)
End If
End Sub
Private Sub BTT_FEED_REMOVE_SPEC_Click(sender As Object, e As EventArgs) Handles BTT_FEED_REMOVE_SPEC.Click
Dim c As IEnumerable(Of UserMediaD) = GetCheckedMedia()
If c.ListExists Then
With FeedSpecialCollection.ChooseFeeds(False)
If .ListExists Then .ForEach(Sub(f) f.Remove(c))
End With
Else
MsgBoxE({"You haven't selected media to remove from your feed(s)", "Remove from feed(s)"}, vbExclamation)
End If
End Sub
Private Function GetCheckedMedia() As IEnumerable(Of UserMediaD)
Return ControlInvoke(Of IEnumerable(Of UserMediaD))(TP_DATA,
Function() As IEnumerable(Of UserMediaD)
If TP_DATA.Controls.Count > 0 Then
Return (From cnt As FeedMedia In TP_DATA.Controls Where cnt.Checked Select cnt.Media)
Else
Return New UserMediaD() {}
End If
End Function, New UserMediaD() {}, EDP.ReturnValue)
End Function
#End Region
#Region "Clear delete"
Private Sub BTT_FEED_CLEAR_FAV_Click(sender As Object, e As EventArgs) Handles BTT_FEED_CLEAR_FAV.Click
If MsgBoxE({"Are you sure you want to clear your Favorite feed?", "Clear feed"}, vbExclamation,,, {"Process", "Cancel"}) = 0 Then _
Settings.Feeds.Favorite.Delete()
End Sub
Private Sub BTT_FEED_CLEAR_SPEC_Click(sender As Object, e As EventArgs) Handles BTT_FEED_CLEAR_SPEC.Click
With FeedSpecialCollection.ChooseFeeds(False)
If .ListExists Then
If MsgBoxE({$"Are you sure you want to clear the following feeds?{vbCr}{vbCr}{ .ListToString(vbCr)}", "Clear feed"}, vbExclamation,,,
{"Process", "Cancel"}) = 0 Then .ForEach(Sub(f) f.Clear())
End If
End With
End Sub
Private Sub BTT_FEED_DELETE_SPEC_Click(sender As Object, e As EventArgs) Handles BTT_FEED_DELETE_SPEC.Click
With FeedSpecialCollection.ChooseFeeds(False)
If .ListExists Then
If MsgBoxE({$"Are you sure you want to delete the following feeds?{vbCr}{vbCr}{ .ListToString(vbCr)}", "Delete feed"}, vbExclamation,,,
{"Process", "Cancel"}) = 0 Then .ForEach(Sub(f) f.Delete())
End If
End With
End Sub
Private Sub BTT_FEED_DELETE_DAILY_LIST_Click(sender As Object, e As EventArgs) Handles BTT_FEED_DELETE_DAILY_LIST.Click
Try
Dim l As New List(Of SFile)
SessionChooser(False, True, l)
If l.Count > 0 Then
If MsgBoxE({$"Are you sure you want to delete the following sessions?{vbCr}{vbCr}{l.ListToStringE(vbCr, SessionDateStringProvider)}", "Delete session"}, vbExclamation,,,
{"Process", "Cancel"}) = 0 Then
l.ForEach(Sub(f) f.Delete(SFO.File, SFODelete.DeleteToRecycleBin, EDP.None))
MsgBoxE({"Sessions have been deleted", "Delete session"})
End If
End If
Catch ex As Exception
ErrorsDescriber.Execute(EDP.SendToLog, ex, "Delete daily sessions (by list)")
MainFrameObj.UpdateLogButton()
End Try
End Sub
Private Sub BTT_FEED_DELETE_DAILY_DATE_Click(sender As Object, e As EventArgs) Handles BTT_FEED_DELETE_DAILY_DATE.Click
Try
Using f As New DateTimeSelectionForm(DTSModes.CheckBoxes + DTSModes.Date + DTSModes.Start + DTSModes.End, Settings.Design) With {
.DesignXMLNodeName = "SessionRemoverDateTimeForm"
}
f.ShowDialog()
If f.DialogResult = DialogResult.OK Then
Dim _dStart As Date? = f.MyDateStart
Dim _dEnd As Date? = f.MyDateEnd
If _dStart.HasValue Or _dEnd.HasValue Then
Dim dStart As Date = If(_dStart, Date.MinValue)
dStart = dStart.Date
Dim dEnd As Date = If(_dEnd, Date.MaxValue)
dEnd = dEnd.Date
Dim filesDir As SFile = TDownloader.SessionsPath.CSFileP
If filesDir.Exists(SFO.Path, False) Then
Dim files As List(Of SFile) = SFile.GetFiles(filesDir, "*.xml",, EDP.ReturnValue)
If files.ListExists Then files.RemoveAll(Settings.Feeds.FeedSpecialRemover)
If files.ListExists Then
Dim fd As IEnumerable(Of KeyValuePair(Of SFile, Date?)) =
files.Select(Function(ff) New KeyValuePair(Of SFile, Date?)(
ff, AConvert(Of Date)(ff.Name, SessionDateTimeProvider, AModes.Var, Nothing)))
If fd.ListExists Then
For Each optFile As KeyValuePair(Of SFile, Date?) In fd
If optFile.Value.HasValue AndAlso optFile.Value.Value.ValueBetween(dStart, dEnd) Then _
optFile.Key.Delete(SFO.File, SFODelete.DeleteToRecycleBin, EDP.None)
Next
End If
End If
End If
End If
End If
End Using
Catch ex As Exception
ErrorsDescriber.Execute(EDP.SendToLog, ex, "Delete daily sessions (by date)")
MainFrameObj.UpdateLogButton()
End Try
End Sub
#End Region
#End Region
#Region "View modes"
Private Sub OPT_Click(ByVal Sender As ToolStripMenuItem, ByVal e As EventArgs) Handles OPT_DEFAULT.Click, OPT_SUBSCRIPTIONS.Click Private Sub OPT_Click(ByVal Sender As ToolStripMenuItem, ByVal e As EventArgs) Handles OPT_DEFAULT.Click, OPT_SUBSCRIPTIONS.Click
Dim __refill As Boolean = False Dim __refill As Boolean = False
ControlInvokeFast(ToolbarTOP, Sender, ControlInvokeFast(ToolbarTOP, Sender,
@@ -283,6 +523,19 @@ Namespace DownloadObjects
End Sub, EDP.None) End Sub, EDP.None)
If __refill Then RefillList() If __refill Then RefillList()
End Sub End Sub
#End Region
Friend Sub Downloader_FilesChanged(ByVal Added As Boolean)
ControlInvokeFast(ToolbarTOP, BTT_REFRESH, Sub() BTT_REFRESH.ToolTipText = If(Added, "New files found", "Some files have been removed"))
BTT_REFRESH.ControlChangeColor(ToolbarTOP, Added, False)
End Sub
Private Sub BTT_REFRESH_Click(sender As Object, e As EventArgs) Handles BTT_REFRESH.Click
RefillList()
End Sub
Private Sub BTT_CLEAR_Click(sender As Object, e As EventArgs) Handles BTT_CLEAR.Click
Downloader.Files.Clear()
ClearTable()
RefillList()
End Sub
#End Region #End Region
#Region "Download" #Region "Download"
Private Sub FeedMedia_Download(ByVal Sender As Object, ByVal e As EventArgs) Handles BTT_DOWN_ALL.Click, BTT_DOWN_SELECTED.Click Private Sub FeedMedia_Download(ByVal Sender As Object, ByVal e As EventArgs) Handles BTT_DOWN_ALL.Click, BTT_DOWN_SELECTED.Click

View File

@@ -42,6 +42,11 @@ Namespace DownloadObjects
Me.ICON_SITE = New System.Windows.Forms.PictureBox() Me.ICON_SITE = New System.Windows.Forms.PictureBox()
Me.TP_MAIN = New System.Windows.Forms.TableLayoutPanel() Me.TP_MAIN = New System.Windows.Forms.TableLayoutPanel()
Me.LBL_TITLE = New System.Windows.Forms.Label() Me.LBL_TITLE = New System.Windows.Forms.Label()
Me.CONTEXT_SEP_4 = New System.Windows.Forms.ToolStripSeparator()
Me.BTT_FEED_ADD_FAV = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_ADD_SPEC = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_REMOVE_FAV = New System.Windows.Forms.ToolStripMenuItem()
Me.BTT_FEED_REMOVE_SPEC = New System.Windows.Forms.ToolStripMenuItem()
CONTEXT_SEP_1 = New System.Windows.Forms.ToolStripSeparator() CONTEXT_SEP_1 = New System.Windows.Forms.ToolStripSeparator()
CONTEXT_SEP_2 = New System.Windows.Forms.ToolStripSeparator() CONTEXT_SEP_2 = New System.Windows.Forms.ToolStripSeparator()
TP_LBL = New System.Windows.Forms.TableLayoutPanel() TP_LBL = New System.Windows.Forms.TableLayoutPanel()
@@ -54,12 +59,12 @@ Namespace DownloadObjects
'CONTEXT_SEP_1 'CONTEXT_SEP_1
' '
CONTEXT_SEP_1.Name = "CONTEXT_SEP_1" CONTEXT_SEP_1.Name = "CONTEXT_SEP_1"
CONTEXT_SEP_1.Size = New System.Drawing.Size(134, 6) CONTEXT_SEP_1.Size = New System.Drawing.Size(217, 6)
' '
'CONTEXT_SEP_2 'CONTEXT_SEP_2
' '
CONTEXT_SEP_2.Name = "CONTEXT_SEP_2" CONTEXT_SEP_2.Name = "CONTEXT_SEP_2"
CONTEXT_SEP_2.Size = New System.Drawing.Size(134, 6) CONTEXT_SEP_2.Size = New System.Drawing.Size(217, 6)
' '
'TP_LBL 'TP_LBL
' '
@@ -103,76 +108,76 @@ Namespace DownloadObjects
' '
'CONTEXT_DATA 'CONTEXT_DATA
' '
Me.CONTEXT_DATA.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BTT_CONTEXT_DOWN, Me.CONTEXT_SEP_0, Me.BTT_CONTEXT_OPEN_MEDIA, Me.BTT_CONTEXT_OPEN_USER, CONTEXT_SEP_1, Me.BTT_CONTEXT_OPEN_USER_URL, Me.BTT_CONTEXT_OPEN_USER_POST, CONTEXT_SEP_2, Me.BTT_CONTEXT_FIND_USER, Me.BTT_CONTEXT_INFO, Me.CONTEXT_SEP_3, Me.BTT_CONTEXT_DELETE}) Me.CONTEXT_DATA.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BTT_CONTEXT_DOWN, Me.CONTEXT_SEP_0, Me.BTT_CONTEXT_OPEN_MEDIA, Me.BTT_CONTEXT_OPEN_USER, CONTEXT_SEP_1, Me.BTT_CONTEXT_OPEN_USER_URL, Me.BTT_CONTEXT_OPEN_USER_POST, CONTEXT_SEP_2, Me.BTT_FEED_ADD_FAV, Me.BTT_FEED_ADD_SPEC, Me.BTT_FEED_REMOVE_FAV, Me.BTT_FEED_REMOVE_SPEC, Me.CONTEXT_SEP_3, Me.BTT_CONTEXT_FIND_USER, Me.BTT_CONTEXT_INFO, Me.CONTEXT_SEP_4, Me.BTT_CONTEXT_DELETE})
Me.CONTEXT_DATA.Name = "CONTEXT_PIC" Me.CONTEXT_DATA.Name = "CONTEXT_PIC"
Me.CONTEXT_DATA.Size = New System.Drawing.Size(138, 204) Me.CONTEXT_DATA.Size = New System.Drawing.Size(221, 320)
' '
'BTT_CONTEXT_DOWN 'BTT_CONTEXT_DOWN
' '
Me.BTT_CONTEXT_DOWN.Image = Global.SCrawler.My.Resources.Resources.StartPic_Green_16 Me.BTT_CONTEXT_DOWN.Image = Global.SCrawler.My.Resources.Resources.StartPic_Green_16
Me.BTT_CONTEXT_DOWN.Name = "BTT_CONTEXT_DOWN" Me.BTT_CONTEXT_DOWN.Name = "BTT_CONTEXT_DOWN"
Me.BTT_CONTEXT_DOWN.Size = New System.Drawing.Size(137, 22) Me.BTT_CONTEXT_DOWN.Size = New System.Drawing.Size(220, 22)
Me.BTT_CONTEXT_DOWN.Text = "Download" Me.BTT_CONTEXT_DOWN.Text = "Download"
Me.BTT_CONTEXT_DOWN.Visible = False Me.BTT_CONTEXT_DOWN.Visible = False
' '
'CONTEXT_SEP_0 'CONTEXT_SEP_0
' '
Me.CONTEXT_SEP_0.Name = "CONTEXT_SEP_0" Me.CONTEXT_SEP_0.Name = "CONTEXT_SEP_0"
Me.CONTEXT_SEP_0.Size = New System.Drawing.Size(134, 6) Me.CONTEXT_SEP_0.Size = New System.Drawing.Size(217, 6)
Me.CONTEXT_SEP_0.Visible = False Me.CONTEXT_SEP_0.Visible = False
' '
'BTT_CONTEXT_OPEN_MEDIA 'BTT_CONTEXT_OPEN_MEDIA
' '
Me.BTT_CONTEXT_OPEN_MEDIA.Image = Global.SCrawler.My.Resources.Resources.FolderPic_32 Me.BTT_CONTEXT_OPEN_MEDIA.Image = Global.SCrawler.My.Resources.Resources.FolderPic_32
Me.BTT_CONTEXT_OPEN_MEDIA.Name = "BTT_CONTEXT_OPEN_MEDIA" Me.BTT_CONTEXT_OPEN_MEDIA.Name = "BTT_CONTEXT_OPEN_MEDIA"
Me.BTT_CONTEXT_OPEN_MEDIA.Size = New System.Drawing.Size(137, 22) Me.BTT_CONTEXT_OPEN_MEDIA.Size = New System.Drawing.Size(220, 22)
Me.BTT_CONTEXT_OPEN_MEDIA.Text = "Open" Me.BTT_CONTEXT_OPEN_MEDIA.Text = "Open"
' '
'BTT_CONTEXT_OPEN_USER 'BTT_CONTEXT_OPEN_USER
' '
Me.BTT_CONTEXT_OPEN_USER.Image = Global.SCrawler.My.Resources.Resources.FolderPic_32 Me.BTT_CONTEXT_OPEN_USER.Image = Global.SCrawler.My.Resources.Resources.FolderPic_32
Me.BTT_CONTEXT_OPEN_USER.Name = "BTT_CONTEXT_OPEN_USER" Me.BTT_CONTEXT_OPEN_USER.Name = "BTT_CONTEXT_OPEN_USER"
Me.BTT_CONTEXT_OPEN_USER.Size = New System.Drawing.Size(137, 22) Me.BTT_CONTEXT_OPEN_USER.Size = New System.Drawing.Size(220, 22)
Me.BTT_CONTEXT_OPEN_USER.Text = "Open user" Me.BTT_CONTEXT_OPEN_USER.Text = "Open user"
' '
'BTT_CONTEXT_OPEN_USER_URL 'BTT_CONTEXT_OPEN_USER_URL
' '
Me.BTT_CONTEXT_OPEN_USER_URL.Image = Global.SCrawler.My.Resources.Resources.GlobePic_32 Me.BTT_CONTEXT_OPEN_USER_URL.Image = Global.SCrawler.My.Resources.Resources.GlobePic_32
Me.BTT_CONTEXT_OPEN_USER_URL.Name = "BTT_CONTEXT_OPEN_USER_URL" Me.BTT_CONTEXT_OPEN_USER_URL.Name = "BTT_CONTEXT_OPEN_USER_URL"
Me.BTT_CONTEXT_OPEN_USER_URL.Size = New System.Drawing.Size(137, 22) Me.BTT_CONTEXT_OPEN_USER_URL.Size = New System.Drawing.Size(220, 22)
Me.BTT_CONTEXT_OPEN_USER_URL.Text = "Open user" Me.BTT_CONTEXT_OPEN_USER_URL.Text = "Open user"
' '
'BTT_CONTEXT_OPEN_USER_POST 'BTT_CONTEXT_OPEN_USER_POST
' '
Me.BTT_CONTEXT_OPEN_USER_POST.Image = Global.SCrawler.My.Resources.Resources.GlobePic_32 Me.BTT_CONTEXT_OPEN_USER_POST.Image = Global.SCrawler.My.Resources.Resources.GlobePic_32
Me.BTT_CONTEXT_OPEN_USER_POST.Name = "BTT_CONTEXT_OPEN_USER_POST" Me.BTT_CONTEXT_OPEN_USER_POST.Name = "BTT_CONTEXT_OPEN_USER_POST"
Me.BTT_CONTEXT_OPEN_USER_POST.Size = New System.Drawing.Size(137, 22) Me.BTT_CONTEXT_OPEN_USER_POST.Size = New System.Drawing.Size(220, 22)
Me.BTT_CONTEXT_OPEN_USER_POST.Text = "Open post" Me.BTT_CONTEXT_OPEN_USER_POST.Text = "Open post"
' '
'BTT_CONTEXT_FIND_USER 'BTT_CONTEXT_FIND_USER
' '
Me.BTT_CONTEXT_FIND_USER.Image = Global.SCrawler.My.Resources.Resources.InfoPic_32 Me.BTT_CONTEXT_FIND_USER.Image = Global.SCrawler.My.Resources.Resources.InfoPic_32
Me.BTT_CONTEXT_FIND_USER.Name = "BTT_CONTEXT_FIND_USER" Me.BTT_CONTEXT_FIND_USER.Name = "BTT_CONTEXT_FIND_USER"
Me.BTT_CONTEXT_FIND_USER.Size = New System.Drawing.Size(137, 22) Me.BTT_CONTEXT_FIND_USER.Size = New System.Drawing.Size(220, 22)
Me.BTT_CONTEXT_FIND_USER.Text = "Find user" Me.BTT_CONTEXT_FIND_USER.Text = "Find user"
' '
'BTT_CONTEXT_INFO 'BTT_CONTEXT_INFO
' '
Me.BTT_CONTEXT_INFO.Image = Global.SCrawler.My.Resources.Resources.InfoPic_32 Me.BTT_CONTEXT_INFO.Image = Global.SCrawler.My.Resources.Resources.InfoPic_32
Me.BTT_CONTEXT_INFO.Name = "BTT_CONTEXT_INFO" Me.BTT_CONTEXT_INFO.Name = "BTT_CONTEXT_INFO"
Me.BTT_CONTEXT_INFO.Size = New System.Drawing.Size(137, 22) Me.BTT_CONTEXT_INFO.Size = New System.Drawing.Size(220, 22)
Me.BTT_CONTEXT_INFO.Text = "Information" Me.BTT_CONTEXT_INFO.Text = "Information"
' '
'CONTEXT_SEP_3 'CONTEXT_SEP_3
' '
Me.CONTEXT_SEP_3.Name = "CONTEXT_SEP_3" Me.CONTEXT_SEP_3.Name = "CONTEXT_SEP_3"
Me.CONTEXT_SEP_3.Size = New System.Drawing.Size(134, 6) Me.CONTEXT_SEP_3.Size = New System.Drawing.Size(217, 6)
' '
'BTT_CONTEXT_DELETE 'BTT_CONTEXT_DELETE
' '
Me.BTT_CONTEXT_DELETE.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24 Me.BTT_CONTEXT_DELETE.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24
Me.BTT_CONTEXT_DELETE.Name = "BTT_CONTEXT_DELETE" Me.BTT_CONTEXT_DELETE.Name = "BTT_CONTEXT_DELETE"
Me.BTT_CONTEXT_DELETE.Size = New System.Drawing.Size(137, 22) Me.BTT_CONTEXT_DELETE.Size = New System.Drawing.Size(220, 22)
Me.BTT_CONTEXT_DELETE.Text = "Delete" Me.BTT_CONTEXT_DELETE.Text = "Delete"
' '
'ICON_SITE 'ICON_SITE
@@ -212,6 +217,39 @@ Namespace DownloadObjects
Me.LBL_TITLE.Size = New System.Drawing.Size(140, 25) Me.LBL_TITLE.Size = New System.Drawing.Size(140, 25)
Me.LBL_TITLE.TabIndex = 1 Me.LBL_TITLE.TabIndex = 1
' '
'CONTEXT_SEP_4
'
Me.CONTEXT_SEP_4.Name = "CONTEXT_SEP_4"
Me.CONTEXT_SEP_4.Size = New System.Drawing.Size(217, 6)
'
'BTT_FEED_ADD_FAV
'
Me.BTT_FEED_ADD_FAV.Image = Global.SCrawler.My.Resources.Resources.HeartPic_32
Me.BTT_FEED_ADD_FAV.Name = "BTT_FEED_ADD_FAV"
Me.BTT_FEED_ADD_FAV.Size = New System.Drawing.Size(220, 22)
Me.BTT_FEED_ADD_FAV.Text = "Add to Favorite"
'
'BTT_FEED_ADD_SPEC
'
Me.BTT_FEED_ADD_SPEC.Image = Global.SCrawler.My.Resources.Resources.RSSPic_512
Me.BTT_FEED_ADD_SPEC.Name = "BTT_FEED_ADD_SPEC"
Me.BTT_FEED_ADD_SPEC.Size = New System.Drawing.Size(220, 22)
Me.BTT_FEED_ADD_SPEC.Text = "Add to special feed..."
'
'BTT_FEED_REMOVE_FAV
'
Me.BTT_FEED_REMOVE_FAV.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24
Me.BTT_FEED_REMOVE_FAV.Name = "BTT_FEED_REMOVE_FAV"
Me.BTT_FEED_REMOVE_FAV.Size = New System.Drawing.Size(220, 22)
Me.BTT_FEED_REMOVE_FAV.Text = "Remove from Favorite"
'
'BTT_FEED_REMOVE_SPEC
'
Me.BTT_FEED_REMOVE_SPEC.Image = Global.SCrawler.My.Resources.Resources.DeletePic_24
Me.BTT_FEED_REMOVE_SPEC.Name = "BTT_FEED_REMOVE_SPEC"
Me.BTT_FEED_REMOVE_SPEC.Size = New System.Drawing.Size(220, 22)
Me.BTT_FEED_REMOVE_SPEC.Text = "Remove from special feed..."
'
'FeedMedia 'FeedMedia
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -249,5 +287,10 @@ Namespace DownloadObjects
Private WithEvents BTT_CONTEXT_DOWN As ToolStripMenuItem Private WithEvents BTT_CONTEXT_DOWN As ToolStripMenuItem
Private WithEvents CONTEXT_SEP_0 As ToolStripSeparator Private WithEvents CONTEXT_SEP_0 As ToolStripSeparator
Private WithEvents LBL_TITLE As Label Private WithEvents LBL_TITLE As Label
Private WithEvents BTT_FEED_ADD_FAV As ToolStripMenuItem
Private WithEvents BTT_FEED_ADD_SPEC As ToolStripMenuItem
Private WithEvents BTT_FEED_REMOVE_FAV As ToolStripMenuItem
Private WithEvents BTT_FEED_REMOVE_SPEC As ToolStripMenuItem
Private WithEvents CONTEXT_SEP_4 As ToolStripSeparator
End Class End Class
End Namespace End Namespace

View File

@@ -61,6 +61,7 @@ Namespace DownloadObjects
End Property End Property
Private ReadOnly UserKey As String Private ReadOnly UserKey As String
Friend ReadOnly Post As UserMedia Friend ReadOnly Post As UserMedia
Friend ReadOnly Media As UserMediaD
Friend Property Checked As Boolean Friend Property Checked As Boolean
Get Get
Return CH_CHECKED.Checked Return CH_CHECKED.Checked
@@ -161,6 +162,7 @@ Namespace DownloadObjects
Friend Sub New(ByVal Media As UserMediaD, ByVal Width As Integer, ByVal Height As Integer) Friend Sub New(ByVal Media As UserMediaD, ByVal Width As Integer, ByVal Height As Integer)
Try Try
InitializeComponent() InitializeComponent()
Me.Media = Media
IsSubscription = If(Media.User?.IsSubscription, False) IsSubscription = If(Media.User?.IsSubscription, False)
If IsSubscription Then If IsSubscription Then
@@ -174,7 +176,7 @@ Namespace DownloadObjects
BTT_CONTEXT_DOWN.Visible = True BTT_CONTEXT_DOWN.Visible = True
CONTEXT_SEP_0.Visible = True CONTEXT_SEP_0.Visible = True
BTT_CONTEXT_OPEN_USER.Visible = False BTT_CONTEXT_OPEN_USER.Visible = False
CONTEXT_SEP_3.Visible = False CONTEXT_SEP_4.Visible = False
BTT_CONTEXT_DELETE.Visible = False BTT_CONTEXT_DELETE.Visible = False
If Not Media.Data.URL.IsEmptyString Then If Not Media.Data.URL.IsEmptyString Then
@@ -297,6 +299,7 @@ Namespace DownloadObjects
Else Else
Throw New ArgumentNullException With {.HelpLink = 1} Throw New ArgumentNullException With {.HelpLink = 1}
End If End If
If Settings.Feeds.Favorite.Contains(Media) Then BTT_FEED_ADD_FAV.ControlChangeColor(True, False)
Catch aex As ArgumentNullException When aex.HelpLink = 1 Catch aex As ArgumentNullException When aex.HelpLink = 1
HasError = True HasError = True
Catch tex As Threading.ThreadStateException Catch tex As Threading.ThreadStateException
@@ -336,9 +339,12 @@ Namespace DownloadObjects
End Sub End Sub
#End Region #End Region
#Region "Context" #Region "Context"
#Region "Down"
Private Sub BTT_CONTEXT_DOWN_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_DOWN.Click Private Sub BTT_CONTEXT_DOWN_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_DOWN.Click
RaiseEvent MediaDownload(Me, EventArgs.Empty) RaiseEvent MediaDownload(Me, EventArgs.Empty)
End Sub End Sub
#End Region
#Region "Open media, folder"
Private Sub BTT_CONTEXT_OPEN_MEDIA_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_OPEN_MEDIA.Click Private Sub BTT_CONTEXT_OPEN_MEDIA_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_OPEN_MEDIA.Click
File.Open() File.Open()
End Sub End Sub
@@ -348,6 +354,8 @@ Namespace DownloadObjects
If Not u Is Nothing Then u.OpenFolder() If Not u Is Nothing Then u.OpenFolder()
End If End If
End Sub End Sub
#End Region
#Region "Open URL"
Private Sub BTT_CONTEXT_OPEN_USER_URL_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_OPEN_USER_URL.Click Private Sub BTT_CONTEXT_OPEN_USER_URL_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_OPEN_USER_URL.Click
If Not UserKey.IsEmptyString Then If Not UserKey.IsEmptyString Then
Dim u As IUserData = Settings.GetUser(UserKey) Dim u As IUserData = Settings.GetUser(UserKey)
@@ -372,15 +380,44 @@ Namespace DownloadObjects
ErrorsDescriber.Execute(EDP.LogMessageValue, ex, $"[FeedMedia.OpenPost({UserKey}, {Post.Post.ID})]") ErrorsDescriber.Execute(EDP.LogMessageValue, ex, $"[FeedMedia.OpenPost({UserKey}, {Post.Post.ID})]")
End Try End Try
End Sub End Sub
#End Region
#Region "Feed"
Private Sub BTT_FEED_ADD_FAV_Click(sender As Object, e As EventArgs) Handles BTT_FEED_ADD_FAV.Click
With Settings.Feeds.Favorite
If Not .Contains(Media) Then .Add(Media)
BTT_FEED_ADD_FAV.ControlChangeColor(True, False)
End With
End Sub
Private Sub BTT_FEED_ADD_SPEC_Click(sender As Object, e As EventArgs) Handles BTT_FEED_ADD_SPEC.Click
With FeedSpecialCollection.ChooseFeeds(True)
If .ListExists Then .ForEach(Sub(f) f.Add(Media))
End With
End Sub
Private Sub BTT_FEED_REMOVE_FAV_Click(sender As Object, e As EventArgs) Handles BTT_FEED_REMOVE_FAV.Click
With Settings.Feeds.Favorite
If .Contains(Media) Then .Remove(Media)
BTT_FEED_ADD_FAV.ControlChangeColor(True)
End With
End Sub
Private Sub BTT_FEED_REMOVE_SPEC_Click(sender As Object, e As EventArgs) Handles BTT_FEED_REMOVE_SPEC.Click
With FeedSpecialCollection.ChooseFeeds(False)
If .ListExists Then .ForEach(Sub(f) f.Remove(Media))
End With
End Sub
#End Region
#Region "Info"
Private Sub BTT_CONTEXT_FIND_USER_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_FIND_USER.Click Private Sub BTT_CONTEXT_FIND_USER_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_FIND_USER.Click
If Not UserKey.IsEmptyString Then MainFrameObj.FocusUser(UserKey, True) If Not UserKey.IsEmptyString Then MainFrameObj.FocusUser(UserKey, True)
End Sub End Sub
Private Sub BTT_CONTEXT_INFO_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_INFO.Click Private Sub BTT_CONTEXT_INFO_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_INFO.Click
MsgBoxE({Information, "Post information"}) MsgBoxE({Information, "Post information"})
End Sub End Sub
#End Region
#Region "Delete"
Private Sub BTT_CONTEXT_DELETE_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_DELETE.Click Private Sub BTT_CONTEXT_DELETE_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_DELETE.Click
DeleteFile(False) DeleteFile(False)
End Sub End Sub
#End Region
Friend Function DeleteFile(ByVal Silent As Boolean) As Boolean Friend Function DeleteFile(ByVal Silent As Boolean) As Boolean
Const msgTitle$ = "Deleting a file" Const msgTitle$ = "Deleting a file"
Try Try

View File

@@ -0,0 +1,252 @@
' Copyright (C) 2023 Andy https://github.com/AAndyProgram
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY
Imports PersonalUtilities.Tools
Imports PersonalUtilities.Functions.XML
Imports UserMediaD = SCrawler.DownloadObjects.TDownloader.UserMediaD
Namespace DownloadObjects
Friend Class FeedSpecial : Implements IEnumerable(Of UserMediaD), IMyEnumerator(Of UserMediaD), IDisposableSuspend
#Region "SEComparer"
Friend Class SEComparer : Implements IComparer(Of UserMediaD)
Friend Function Compare(ByVal x As UserMediaD, ByVal y As UserMediaD) As Integer Implements IComparer(Of UserMediaD).Compare
Dim v% = x.Date.Ticks.CompareTo(y.Date.Ticks) * -1
If v <> 0 Then Return v
v = If(x.User?.GetHashCode, 0).CompareTo(If(y.User?.GetHashCode, 0))
If v <> 0 Then Return v
Return 0
End Function
End Class
#End Region
#Region "Events"
Friend Event FeedDeleted As FeedSpecialCollection.FeedActionEventHandler
#End Region
#Region "Declarations"
Friend Const FavoriteName As String = "Favorite"
Friend Const SpecialName As String = "Special"
Private ReadOnly Items As List(Of UserMediaD)
Private _File As SFile
Friend ReadOnly Property File As SFile
Get
If _File.IsEmptyString AndAlso Not Name.IsEmptyString Then
If _IsFavorite Then
_File = $"{TDownloader.SessionsPath}{FavoriteName}.xml"
Else
_File = $"{TDownloader.SessionsPath}{SpecialName}_{Name}.xml"
End If
End If
Return _File
End Get
End Property
Private _IsFavorite As Boolean
Friend ReadOnly Property IsFavorite As Boolean
Get
Return _IsFavorite
End Get
End Property
Private _Name As String
Friend ReadOnly Property Name As String
Get
If _Name.IsEmptyString And IsFavorite Then
Return FavoriteName
Else
Return _Name
End If
End Get
End Property
#End Region
#Region "Initializers"
Private Sub New()
Items = New List(Of UserMediaD)
End Sub
Friend Sub New(ByVal f As SFile)
Me.New
_File = f
If Not File.Name.IsEmptyString Then
_IsFavorite = File.Name.StartsWith(FavoriteName)
If Not _IsFavorite Then _Name = File.Name.Split("_").ListTake(0, 100, EDP.ReturnValue).ListToString("").StringTrim.StringTrimStart("_")
End If
Load()
End Sub
Friend Shared Function CreateFavorite() As FeedSpecial
Return New FeedSpecial With {._IsFavorite = True}
End Function
Friend Shared Function CreateSpecial(ByVal Name As String) As FeedSpecial
Return New FeedSpecial With {._Name = Name}
End Function
Friend Sub Load()
If File.Exists Then
Using x As New XmlFile(File, Protector.Modes.All, False) With {.AllowSameNames = True}
x.LoadData()
If x.Count > 0 Then Items.ListAddList(x, LAP.IgnoreICopier)
End Using
End If
End Sub
#End Region
#Region "Data functions"
#Region "Item, Count"
Default Friend ReadOnly Property Item(ByVal Index As Integer) As UserMediaD Implements IMyEnumerator(Of UserMediaD).MyEnumeratorObject
Get
Return Items(Index)
End Get
End Property
Friend ReadOnly Property Count As Integer Implements IMyEnumerator(Of UserMediaD).MyEnumeratorCount
Get
Return Items.Count
End Get
End Property
#End Region
#Region "Clear, Sort, Save"
Friend Function Clear()
Dim result As Boolean = Count > 0
Items.Clear()
If result Then Save()
Return result
End Function
Friend Sub Sort()
If Count > 0 Then Items.Sort(Settings.Feeds.Comparer)
End Sub
Friend Sub Save()
If Not File.IsEmptyString Then
Sort()
Using x As New XmlFile With {.Name = "Feed", .AllowSameNames = True}
x.AddRange(Items)
x.Save(File, EDP.SendToLog)
End Using
End If
End Sub
#End Region
#Region "Add"
Friend Overloads Function Add(ByVal Item As UserMediaD, Optional ByVal AutoSave As Boolean = True) As Boolean
If Not Items.Contains(Item) Then
Items.Add(Item)
If AutoSave Then Save()
Return True
Else
Return False
End If
End Function
Friend Overloads Function Add(ByVal Items As IEnumerable(Of UserMediaD), Optional ByVal AutoSave As Boolean = True) As Integer
Dim ri% = 0
If Items.ListExists Then
For Each item As UserMediaD In Items : ri += Add(item, False).BoolToInteger : Next
If ri > 0 And AutoSave Then Save()
End If
Return ri
End Function
#End Region
#Region "Remove"
Friend Overloads Function Remove(ByVal Item As UserMediaD, Optional ByVal AutoSave As Boolean = True) As Boolean
If Count > 0 Then
Dim i% = Items.IndexOf(Item)
If i >= 0 Then
Items.RemoveAt(i)
If AutoSave Then Save()
Return True
End If
End If
Return False
End Function
Friend Overloads Function Remove(ByVal Items As IEnumerable(Of UserMediaD), Optional ByVal AutoSave As Boolean = True) As Integer
Dim ri% = 0
If Items.ListExists Then
For Each item As UserMediaD In Items : ri += Me.Items.Remove(item).BoolToInteger : Next
If ri > 0 And AutoSave Then Save()
End If
Return ri
End Function
Private _NotExistRemoved As Boolean = False
Friend Function RemoveNotExist(ByVal p As Predicate(Of UserMediaD)) As Integer
If Count > 0 And Not _NotExistRemoved Then
_NotExistRemoved = True
Dim ri% = Items.RemoveAll(p)
If ri > 0 Then Save()
Return ri
Else
Return 0
End If
End Function
#End Region
#Region "Delete"
Friend Overloads Function Delete() As Boolean
If File.Delete(SFO.File, SFODelete.DeleteToRecycleBin, EDP.ReturnValue) Then
Items.Clear()
RaiseEvent FeedDeleted(Settings.Feeds, Me)
Return True
Else
Return False
End If
End Function
Friend Overloads Function Delete(ByVal Item As UserMediaD, Optional ByVal AutoSave As Boolean = True) As Boolean
Dim result As Boolean = False
If Item.Data.File.Exists Then result = Item.Data.File.Delete(SFO.File, SFODelete.DeleteToRecycleBin, EDP.ReturnValue)
If result And AutoSave Then Save()
Return result
End Function
#End Region
#Region "Contains"
Friend Function Contains(ByVal Item As UserMediaD) As Boolean
Return Items.Contains(Item)
End Function
#End Region
#End Region
#Region "Base Overrides"
Public Overrides Function ToString() As String
Return Name
End Function
Public Overrides Function GetHashCode() As Integer
Return Name.GetHashCode
End Function
Public Overrides Function Equals(ByVal Obj As Object) As Boolean
If Not IsNothing(Obj) Then
If TypeOf Obj Is FeedSpecial Then
Return Name = DirectCast(Obj, FeedSpecial).Name
ElseIf TypeOf Obj Is String Then
Return Name = CStr(Obj)
End If
End If
Return False
End Function
#End Region
#Region "IEnumerable Support"
Private Function GetEnumerator() As IEnumerator(Of UserMediaD) Implements IEnumerable(Of UserMediaD).GetEnumerator
Return New MyEnumerator(Of UserMediaD)(Me)
End Function
Private Function IEnumerable_GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
Return GetEnumerator()
End Function
#End Region
#Region "IDisposable Support"
Friend Property DisposeSuspended As Boolean Implements IDisposableSuspend.DisposeSuspended
Get
Return IsFavorite
End Get
Private Set : End Set
End Property
Friend ReadOnly Property Disposed As Boolean Implements IDisposableSuspend.Disposed
Get
Return disposedValue
End Get
End Property
Private disposedValue As Boolean = False
Protected Overridable Overloads Sub Dispose(ByVal disposing As Boolean)
If Not disposedValue Then
If disposing Then Items.Clear()
disposedValue = True
End If
End Sub
Protected Overrides Sub Finalize()
Dispose(False)
MyBase.Finalize()
End Sub
Friend Overloads Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
#End Region
End Class
End Namespace

View File

@@ -0,0 +1,169 @@
' Copyright (C) 2023 Andy https://github.com/AAndyProgram
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY
Imports PersonalUtilities.Tools
Imports PersonalUtilities.Forms
Namespace DownloadObjects
Friend Class FeedSpecialCollection : Implements IEnumerable(Of FeedSpecial), IMyEnumerator(Of FeedSpecial)
#Region "Events"
Friend Delegate Sub FeedActionEventHandler(ByVal Source As FeedSpecialCollection, ByVal Feed As FeedSpecial)
Friend Event FeedAdded As FeedActionEventHandler
Friend Event FeedRemoved As FeedActionEventHandler
#End Region
#Region "FeedsComparer"
Private Class FeedsComparer : Implements IComparer(Of FeedSpecial)
Friend Function Compare(ByVal x As FeedSpecial, ByVal y As FeedSpecial) As Integer Implements IComparer(Of FeedSpecial).Compare
If x.IsFavorite Then
Return -1
Else
Return x.Name.CompareTo(y.Name)
End If
End Function
End Class
#End Region
#Region "Declarations"
Private ReadOnly Feeds As List(Of FeedSpecial)
Private _Favorite As FeedSpecial = Nothing
Friend ReadOnly Property Favorite As FeedSpecial
Get
If _Favorite Is Nothing Then _Favorite = FeedSpecial.CreateFavorite : _Favorite.Load()
Return _Favorite
End Get
End Property
Private _Loaded As Boolean = False
Friend ReadOnly Property Comparer As New FeedSpecial.SEComparer
Private ReadOnly Property ComparerFeeds As New FeedsComparer
Friend ReadOnly Property FeedSpecialRemover As Predicate(Of SFile) = Function(f) f.Name.StartsWith(FeedSpecial.FavoriteName) Or f.Name.StartsWith(FeedSpecial.SpecialName)
#End Region
#Region "Initializer, loader, feeds handlers"
Friend Sub New()
Feeds = New List(Of FeedSpecial)
End Sub
Friend Sub Load()
Try
If Not _Loaded Then
_Loaded = True
Dim files As List(Of SFile) = SFile.GetFiles(TDownloader.SessionsPath, $"{FeedSpecial.FavoriteName}.xml|{FeedSpecial.SpecialName}_*.xml",, EDP.ReturnValue)
If files.ListExists Then files.ForEach(Sub(f)
Feeds.Add(New FeedSpecial(f))
With Feeds.Last
If .IsFavorite Then _Favorite = .Self
AddHandler .FeedDeleted, AddressOf Feeds_FeedDeleted
End With
End Sub) : files.Clear()
End If
Catch ex As Exception
ErrorsDescriber.Execute(EDP.SendToLog, ex, "[FeedSpecialCollection.Load]")
MainFrameObj.UpdateLogButton()
End Try
End Sub
Private Sub Feeds_FeedDeleted(ByVal Source As FeedSpecialCollection, ByVal Feed As FeedSpecial)
RaiseEvent FeedRemoved(Me, Feed)
If Count > 0 Then Feeds.Remove(Feed)
End Sub
#End Region
#Region "ChooseFeeds"
Friend Shared Function ChooseFeeds(ByVal AllowAdd As Boolean) As List(Of FeedSpecial)
Try
Dim newFeed$ = String.Empty
Using f As New SimpleListForm(Of String)(Settings.Feeds.Select(Function(ff) ff.Name), Settings.Design) With {
.DesignXMLNodeName = "FeedsChooserForm",
.Icon = My.Resources.RSSIcon_32,
.FormText = "Feeds"
}
If AllowAdd Then f.AddFunction = Sub(ByVal sender As Object, ByVal e As SimpleListFormEventArgs)
If newFeed.IsEmptyString Then
Dim nf$ = InputBoxE("Enter a new feed name:", "New feed")
If Not nf.IsEmptyString Then
If Settings.Feeds.ListExists(Function(ff) ff.Name.StringToLower = nf.ToLower) Then
MsgBoxE({$"A feed named '{nf}' already exists", "New feed"}, vbCritical)
Else
newFeed = nf
e.Item = nf
End If
Else
MsgBoxE({"You can only create one feed at a time", "New feed"}, vbCritical)
End If
End If
End Sub
If f.ShowDialog = DialogResult.OK AndAlso f.DataResult.Count > 0 Then
If Not newFeed.IsEmptyString AndAlso f.DataResult.Contains(newFeed) Then Settings.Feeds.Add(newFeed)
Return Settings.Feeds.Where(Function(ff) f.DataResult.Contains(ff.Name)).ToList
End If
End Using
Return Nothing
Catch ex As Exception
Return ErrorsDescriber.Execute(EDP.SendToLog, ex, "[FeedSpecialCollection.ChooseFeeds]")
End Try
End Function
#End Region
#Region "Item, Count"
Default Friend ReadOnly Property Item(ByVal Index As Integer) As FeedSpecial Implements IMyEnumerator(Of FeedSpecial).MyEnumeratorObject
Get
Return Feeds(Index)
End Get
End Property
Friend ReadOnly Property Count As Integer Implements IMyEnumerator(Of FeedSpecial).MyEnumeratorCount
Get
Return Feeds.Count
End Get
End Property
#End Region
#Region "Add, Delete"
Friend Function Add(ByVal Name As String) As Integer
Dim i% = -1
If Not Name.IsEmptyString Then
If Count = 0 Then
Feeds.Add(FeedSpecial.CreateSpecial(Name))
Feeds.Last.Save()
i = Count - 1
Else
i = Feeds.FindIndex(Function(f) f.Name = Name)
If i = -1 Then
Feeds.Add(FeedSpecial.CreateSpecial(Name))
Feeds.Last.Save()
i = Count - 1
End If
End If
End If
If i >= 0 Then
Feeds.Sort(ComparerFeeds)
i = Feeds.FindIndex(Function(f) f.Name = Name)
If i >= 0 Then RaiseEvent FeedAdded(Me, Feeds(i))
End If
Return i
End Function
Friend Function Delete(ByVal Item As FeedSpecial) As Boolean
Dim result As Boolean = False
Dim i% = Feeds.IndexOf(Item)
If i >= 0 Then
With Feeds(i)
If .IsFavorite Then
result = .Clear
Else
result = .Delete
If result Then
.Dispose()
Feeds.RemoveAt(i)
End If
End If
End With
End If
Return result
End Function
#End Region
#Region "IEnumerable Support"
Private Function GetEnumerator() As IEnumerator(Of FeedSpecial) Implements IEnumerable(Of FeedSpecial).GetEnumerator
Return New MyEnumerator(Of FeedSpecial)(Me)
End Function
Private Function IEnumerable_GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
Return GetEnumerator()
End Function
#End Region
End Class
End Namespace

View File

@@ -116,7 +116,11 @@ Namespace DownloadObjects
If Not _FilesSessionCleared Then If Not _FilesSessionCleared Then
_FilesSessionCleared = True _FilesSessionCleared = True
Dim files As List(Of SFile) = SFile.GetFiles(SessionsPath.CSFileP, "*.xml",, EDP.ReturnValue) Dim files As List(Of SFile) = SFile.GetFiles(SessionsPath.CSFileP, "*.xml",, EDP.ReturnValue)
If RenameOldFileNames(files) Then files = SFile.GetFiles(SessionsPath.CSFileP, "*.xml",, EDP.ReturnValue) If files.ListExists Then files.RemoveAll(Settings.Feeds.FeedSpecialRemover)
If RenameOldFileNames(files) Then
files = SFile.GetFiles(SessionsPath.CSFileP, "*.xml",, EDP.ReturnValue)
If files.ListExists Then files.RemoveAll(Settings.Feeds.FeedSpecialRemover)
End If
Dim filesCount% = Settings.FeedStoredSessionsNumber Dim filesCount% = Settings.FeedStoredSessionsNumber
If files.ListExists And filesCount > 0 Then If files.ListExists And filesCount > 0 Then
Dim fe As New ErrorsDescriber(EDP.None) Dim fe As New ErrorsDescriber(EDP.None)

View File

@@ -264,6 +264,8 @@
<Compile Include="Download\Feed\FeedMedia.vb"> <Compile Include="Download\Feed\FeedMedia.vb">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Download\Feed\FeedSpecial.vb" />
<Compile Include="Download\Feed\FeedSpecialCollection.vb" />
<Compile Include="Download\Feed\FeedVideo.Designer.vb"> <Compile Include="Download\Feed\FeedVideo.Designer.vb">
<DependentUpon>FeedVideo.vb</DependentUpon> <DependentUpon>FeedVideo.vb</DependentUpon>
</Compile> </Compile>

View File

@@ -131,6 +131,7 @@ Friend Class SettingsCLS : Implements IDownloaderSettings, IDisposable
Friend ReadOnly Property GlobalLocations As STDownloader.DownloadLocationsCollection Friend ReadOnly Property GlobalLocations As STDownloader.DownloadLocationsCollection
Friend Property Automation As Scheduler Friend Property Automation As Scheduler
Friend ReadOnly Property AutomationFile As XMLValue(Of SFile) Friend ReadOnly Property AutomationFile As XMLValue(Of SFile)
Friend ReadOnly Property Feeds As FeedSpecialCollection
Friend ReadOnly Property BlackList As List(Of UserBan) Friend ReadOnly Property BlackList As List(Of UserBan)
Private ReadOnly BlackListFile As SFile = $"{SettingsFolderName}\BlackList.txt" Private ReadOnly BlackListFile As SFile = $"{SettingsFolderName}\BlackList.txt"
Private ReadOnly UsersSettingsFile As SFile = $"{SettingsFolderName}\Users.xml" Private ReadOnly UsersSettingsFile As SFile = $"{SettingsFolderName}\Users.xml"
@@ -148,6 +149,7 @@ Friend Class SettingsCLS : Implements IDownloaderSettings, IDisposable
LastCollections = New List(Of String) LastCollections = New List(Of String)
GlobalLocations = New STDownloader.DownloadLocationsCollection GlobalLocations = New STDownloader.DownloadLocationsCollection
GlobalLocations.Load(True,, $"{SettingsFolderName}\GlobalLocations.xml") GlobalLocations.Load(True,, $"{SettingsFolderName}\GlobalLocations.xml")
Feeds = New FeedSpecialCollection
Dim n() As String = {"MediaEnvironment"} Dim n() As String = {"MediaEnvironment"}