106 Protected Sub Button_DeleteFeeds_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_DeleteFeeds.Click
107 'Remove selected feeds from the RSS feed list
108 Dim node As TreeNode
109 Dim nodes As TreeNodeCollection = TreeView_PersonalFeeds.CheckedNodes
110 Dim promptText As StringBuilder
111
112 promptText = New StringBuilder("Delete the following feeds?")
113
114 If nodes.Count > 0 Then
115 For Each node In nodes
116 promptText.AppendLine()
117 promptText.Append(node.Text)
118 Next
119 Dim result As Integer = MsgBox(promptText.ToString, MsgBoxStyle.OkCancel, "Delete Action")
120 If result = MsgBoxResult.Ok Then
121 For Each node In nodes
122 DeleteNode(node)
123 Next
124 End If
125
126
127 End If
128
129 End Sub
130
131 Protected Sub DeleteNode(ByVal node As TreeNode)
132 If node.ChildNodes.Count = 0 AndAlso node.Text <> "" Then
133 'node is a leaf node (feed item)
134 personalFeedItemsAdapter.Delete(New System.Guid(node.Value))
135
136 Else
137 'node is a folder or feed node
138 If Not String.IsNullOrEmpty(node.Text) Then
139 'node must reference a feed (guid string has been stored in text field)
140 'remove the feed from the db
141 personalFeedsAdapter.Delete(New System.Guid(node.Value))
142 End If
143 For Each child As TreeNode In node.ChildNodes
144 'recursively remove child nodes
145 DeleteNode(child)
146 Next
147 End If
148 'remove the node from the tree
149 TreeView_PersonalFeeds.Nodes.Remove(node)
150 End Sub