mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-01-13 17:22:48 -05:00
Add feed chooser window when dragging in an HTML link with multiple feeds
This commit is contained in:
@@ -187,6 +187,9 @@
|
|||||||
<Reference Include="PresentationFramework" />
|
<Reference Include="PresentationFramework" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="FeedChooserWindow.xaml.cs">
|
||||||
|
<DependentUpon>FeedChooserWindow.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="SystemConfiguration.cs" />
|
<Compile Include="SystemConfiguration.cs" />
|
||||||
<Page Include="App.xaml">
|
<Page Include="App.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
@@ -266,6 +269,10 @@
|
|||||||
<Compile Include="SplashWindow.xaml.cs">
|
<Compile Include="SplashWindow.xaml.cs">
|
||||||
<DependentUpon>SplashWindow.xaml</DependentUpon>
|
<DependentUpon>SplashWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Page Include="FeedChooserWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="FeedErrorWindow.xaml">
|
<Page Include="FeedErrorWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
65
Application/FeedChooserWindow.xaml
Normal file
65
Application/FeedChooserWindow.xaml
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<Window x:Class="FeedCenter.FeedChooserWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
|
||||||
|
xmlns:my="clr-namespace:FeedCenter.Properties"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="{x:Static my:Resources.FeedChooserWindow}"
|
||||||
|
Height="247.297"
|
||||||
|
Width="419.594"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
Icon="/FeedCenter;component/Resources/Application.ico"
|
||||||
|
FocusManager.FocusedElement="{Binding ElementName=FeedDataGrid}"
|
||||||
|
windows:ControlBox.HasMaximizeButton="False"
|
||||||
|
windows:ControlBox.HasMinimizeButton="False">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<DataGrid AutoGenerateColumns="False"
|
||||||
|
x:Name="FeedDataGrid"
|
||||||
|
CanUserReorderColumns="False"
|
||||||
|
GridLinesVisibility="None"
|
||||||
|
SelectionMode="Single"
|
||||||
|
IsReadOnly="True"
|
||||||
|
CanUserResizeRows="False"
|
||||||
|
HeadersVisibility="Column"
|
||||||
|
Margin="6"
|
||||||
|
Background="{x:Null}"
|
||||||
|
CanUserSortColumns="True"
|
||||||
|
MouseDoubleClick="HandleMouseDoubleClick">
|
||||||
|
<DataGrid.CellStyle>
|
||||||
|
<Style TargetType="{x:Type DataGridCell}">
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="0" />
|
||||||
|
</Style>
|
||||||
|
</DataGrid.CellStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="{x:Static my:Resources.FeedNameColumnHeader}"
|
||||||
|
Binding="{Binding Item2}"
|
||||||
|
Width="*"
|
||||||
|
SortDirection="Ascending" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
<Button Content="{x:Static my:Resources.OkayButton}"
|
||||||
|
Height="23"
|
||||||
|
IsDefault="True"
|
||||||
|
Width="75"
|
||||||
|
Click="HandleOkayButtonClick"
|
||||||
|
Margin="0,0,90,10"
|
||||||
|
Grid.Row="1"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
HorizontalAlignment="Right" />
|
||||||
|
<Button Content="{x:Static my:Resources.CancelButton}"
|
||||||
|
Height="23"
|
||||||
|
IsCancel="True"
|
||||||
|
Width="75"
|
||||||
|
Margin="0,0,10,10"
|
||||||
|
Grid.Row="1"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
HorizontalAlignment="Right" />
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
52
Application/FeedChooserWindow.xaml.cs
Normal file
52
Application/FeedChooserWindow.xaml.cs
Normal file
@@ -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<Tuple<string, string>> 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<string, string>) 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -808,17 +808,23 @@ namespace FeedCenter
|
|||||||
// Look for all RSS or atom links in the document
|
// Look for all RSS or atom links in the document
|
||||||
var rssLinks = htmlDocument.DocumentNode.Descendants("link")
|
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"))
|
.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))
|
.Select(n => new Tuple<string, string>(UrlHelper.GetAbsoluteUrlString(feed.Source, n.Attributes["href"].Value), WebUtility.HtmlDecode(n.Attributes["title"]?.Value ?? string.Empty)))
|
||||||
.ToArray();
|
.ToList();
|
||||||
|
|
||||||
// If there was only one link found then switch to feed to it
|
// 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
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
Application/Properties/Resources.Designer.cs
generated
11
Application/Properties/Resources.Designer.cs
generated
@@ -1,7 +1,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// 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
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
@@ -613,6 +613,15 @@ namespace FeedCenter.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Choose Feed to Add.
|
||||||
|
/// </summary>
|
||||||
|
public static string FeedChooserWindow {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("FeedChooserWindow", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Error.
|
/// Looks up a localized string similar to Error.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -514,4 +514,7 @@
|
|||||||
<data name="DatabaseUpdate_6" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="DatabaseUpdate_6" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Scripts\DatabaseUpdate_6.sqlce;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
<value>..\Scripts\DatabaseUpdate_6.sqlce;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="FeedChooserWindow" xml:space="preserve">
|
||||||
|
<value>Choose Feed to Add</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user