diff --git a/Application/FeedCenter.csproj b/Application/FeedCenter.csproj
index e31cf55..13d466b 100644
--- a/Application/FeedCenter.csproj
+++ b/Application/FeedCenter.csproj
@@ -187,6 +187,9 @@
+
+ FeedChooserWindow.xaml
+
MSBuild:Compile
@@ -266,6 +269,10 @@
SplashWindow.xaml
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/Application/FeedChooserWindow.xaml b/Application/FeedChooserWindow.xaml
new file mode 100644
index 0000000..a3d7e45
--- /dev/null
+++ b/Application/FeedChooserWindow.xaml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Application/FeedChooserWindow.xaml.cs b/Application/FeedChooserWindow.xaml.cs
new file mode 100644
index 0000000..aae4c3b
--- /dev/null
+++ b/Application/FeedChooserWindow.xaml.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Windows;
+
+namespace FeedCenter
+{
+ public partial class FeedChooserWindow
+ {
+ private string _returnLink;
+
+ public FeedChooserWindow()
+ {
+ InitializeComponent();
+ }
+
+ public string Display(Window owner, List> rssLinks)
+ {
+ // Bind to the list
+ FeedDataGrid.ItemsSource = rssLinks;
+ FeedDataGrid.SelectedIndex = 0;
+
+ // Set the window owner
+ Owner = owner;
+
+ ShowDialog();
+
+ return _returnLink;
+ }
+
+ private void Save()
+ {
+ var selectedItem = (Tuple) FeedDataGrid.SelectedItem;
+
+ _returnLink = selectedItem.Item1;
+
+ Close();
+ }
+
+ private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
+ {
+ Save();
+ }
+
+ private void HandleMouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (FeedDataGrid.SelectedItem != null)
+ {
+ Save();
+ }
+ }
+ }
+}
diff --git a/Application/MainWindow.xaml.cs b/Application/MainWindow.xaml.cs
index ab54f9d..ef21f2c 100644
--- a/Application/MainWindow.xaml.cs
+++ b/Application/MainWindow.xaml.cs
@@ -808,17 +808,23 @@ namespace FeedCenter
// Look for all RSS or atom links in the document
var rssLinks = htmlDocument.DocumentNode.Descendants("link")
.Where(n => n.Attributes["type"] != null && (n.Attributes["type"].Value == "application/rss+xml" || n.Attributes["type"].Value == "application/atom+xml"))
- .Select(n => UrlHelper.GetAbsoluteUrlString(feed.Source, n.Attributes["href"].Value))
- .ToArray();
+ .Select(n => new Tuple(UrlHelper.GetAbsoluteUrlString(feed.Source, n.Attributes["href"].Value), WebUtility.HtmlDecode(n.Attributes["title"]?.Value ?? string.Empty)))
+ .ToList();
// If there was only one link found then switch to feed to it
- if (rssLinks.Length == 1)
+ if (rssLinks.Count == 1)
{
- feed.Source = rssLinks[0];
+ feed.Source = rssLinks[0].Item1;
}
else
{
- // TODO - show dialog to choose feed
+ var feedChooserWindow = new FeedChooserWindow();
+ var feedLink = feedChooserWindow.Display(this, rssLinks);
+
+ if (string.IsNullOrEmpty(feedLink))
+ return;
+
+ feed.Source = feedLink;
}
}
}
diff --git a/Application/Properties/Resources.Designer.cs b/Application/Properties/Resources.Designer.cs
index da8eb84..8d53d04 100644
--- a/Application/Properties/Resources.Designer.cs
+++ b/Application/Properties/Resources.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.34014
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -613,6 +613,15 @@ namespace FeedCenter.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Choose Feed to Add.
+ ///
+ public static string FeedChooserWindow {
+ get {
+ return ResourceManager.GetString("FeedChooserWindow", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Error.
///
diff --git a/Application/Properties/Resources.resx b/Application/Properties/Resources.resx
index 10c340b..4b7f4b4 100644
--- a/Application/Properties/Resources.resx
+++ b/Application/Properties/Resources.resx
@@ -514,4 +514,7 @@
..\Scripts\DatabaseUpdate_6.sqlce;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
+
+ Choose Feed to Add
+
\ No newline at end of file