diff --git a/Application/Data/LegacyDatabase.cs b/Application/Data/LegacyDatabase.cs index 55dd41b..250bbdf 100644 --- a/Application/Data/LegacyDatabase.cs +++ b/Application/Data/LegacyDatabase.cs @@ -185,10 +185,7 @@ public static class LegacyDatabase { foreach (var category in categories) { - if (category.Name == Category.DefaultName) - category.IsDefault = true; - - category.Feeds = feeds.Where(f => f.CategoryId == category.Id).ToList(); + category.IsDefault = category.Name == Category.DefaultName; } foreach (var feed in feeds) diff --git a/Application/FeedCenter.csproj b/Application/FeedCenter.csproj index 7dd9f99..9f8910f 100644 --- a/Application/FeedCenter.csproj +++ b/Application/FeedCenter.csproj @@ -101,5 +101,6 @@ xcopy /s /y /i "$(PkgMicrosoft_SqlServer_Compact)\NativeBinaries\amd64\*.*" "$(TargetDir)amd64" Resources\Application.ico + true \ No newline at end of file diff --git a/Application/FeedParsers/FeedParserBase.cs b/Application/FeedParsers/FeedParserBase.cs index 8a18d37..5139c74 100644 --- a/Application/FeedParsers/FeedParserBase.cs +++ b/Application/FeedParsers/FeedParserBase.cs @@ -5,34 +5,15 @@ using System.Xml; namespace FeedCenter.FeedParsers; -[Serializable] -internal class InvalidFeedFormatException : ApplicationException -{ - internal InvalidFeedFormatException(Exception exception) - : base(string.Empty, exception) - { - } -} - internal abstract class FeedParserBase { - #region Member variables - protected readonly Feed Feed; - #endregion - - #region Constructor - protected FeedParserBase(Feed feed) { Feed = feed; } - #endregion - - #region Methods - public abstract FeedReadResult ParseFeed(string feedText); protected abstract FeedItem ParseFeedItem(XmlNode node); @@ -57,9 +38,6 @@ internal abstract class FeedParserBase { Log.Logger.Information("New link: " + newFeedItem.Link); - // Associate the new item with the right feed - newFeedItem.Feed = Feed; - // Set the item as new newFeedItem.New = true; @@ -96,10 +74,6 @@ internal abstract class FeedParserBase sequence++; } - #endregion - - #region Parser creation and detection - public static FeedParserBase CreateFeedParser(Feed feed, string feedText) { var feedType = DetectFeedType(feedText); @@ -155,6 +129,4 @@ internal abstract class FeedParserBase throw new FeedParseException(FeedParseError.InvalidXml); } } - - #endregion } \ No newline at end of file diff --git a/Application/FeedParsers/InvalidFeedFormatException.cs b/Application/FeedParsers/InvalidFeedFormatException.cs new file mode 100644 index 0000000..7be0825 --- /dev/null +++ b/Application/FeedParsers/InvalidFeedFormatException.cs @@ -0,0 +1,12 @@ +using System; + +namespace FeedCenter.FeedParsers; + +[Serializable] +internal class InvalidFeedFormatException : ApplicationException +{ + internal InvalidFeedFormatException(Exception exception) + : base(string.Empty, exception) + { + } +} \ No newline at end of file diff --git a/Application/Feeds/Category.cs b/Application/Feeds/Category.cs index f82cf0f..0f756ad 100644 --- a/Application/Feeds/Category.cs +++ b/Application/Feeds/Category.cs @@ -1,10 +1,9 @@ -using System; +using JetBrains.Annotations; +using Realms; +using System; using System.Collections; -using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using JetBrains.Annotations; -using Realms; namespace FeedCenter; @@ -20,9 +19,6 @@ public class Category : RealmObject, INotifyDataErrorInfo _dataErrorDictionary.ErrorsChanged += DataErrorDictionaryErrorsChanged; } - [Ignored] - public ICollection Feeds { get; set; } - [PrimaryKey] public Guid Id { get; set; } = Guid.NewGuid(); diff --git a/Application/Feeds/Feed.cs b/Application/Feeds/Feed.cs index 07a29b9..f55563b 100644 --- a/Application/Feeds/Feed.cs +++ b/Application/Feeds/Feed.cs @@ -22,42 +22,6 @@ using System.Text.RegularExpressions; namespace FeedCenter; -#region Enumerations - -public enum MultipleOpenAction -{ - IndividualPages, - SinglePage -} - -public enum FeedType -{ - Unknown, - Rss, - Rdf, - Atom -} - -public enum FeedReadResult -{ - Success, - NotModified, - NotDue, - UnknownError, - InvalidXml, - NotEnabled, - Unauthorized, - NoResponse, - NotFound, - Timeout, - ConnectionFailed, - ServerError, - Moved, - TemporarilyUnavailable -} - -#endregion - public partial class Feed : RealmObject, INotifyDataErrorInfo { private static HttpClient _httpClient; @@ -71,9 +35,7 @@ public partial class Feed : RealmObject, INotifyDataErrorInfo } public bool Authenticate { get; set; } - public Guid CategoryId { get; set; } - public int CheckInterval { get; set; } = 60; public string Description { get; set; } public bool Enabled { get; set; } = true; @@ -225,8 +187,6 @@ public partial class Feed : RealmObject, INotifyDataErrorInfo _dataErrorDictionary.AddError(propertyName, $"{propertyName} cannot be empty"); } - #region Reading - public FeedReadResult Read(bool forceRead = false) { Log.Logger.Information("Reading feed: {0}", Source); @@ -494,6 +454,4 @@ public partial class Feed : RealmObject, INotifyDataErrorInfo [GeneratedRegex("&(?!(?:[a-z]+|#[0-9]+|#x[0-9a-f]+);)")] private static partial Regex UnescapedAmpersandRegex(); - - #endregion } \ No newline at end of file diff --git a/Application/Feeds/FeedItem.cs b/Application/Feeds/FeedItem.cs index a592c04..6203d98 100644 --- a/Application/Feeds/FeedItem.cs +++ b/Application/Feeds/FeedItem.cs @@ -9,9 +9,6 @@ public partial class FeedItem : RealmObject { public bool BeenRead { get; set; } public string Description { get; set; } - - public Feed Feed { get; set; } - public Guid FeedId { get; set; } public string Guid { get; set; } @@ -22,7 +19,6 @@ public partial class FeedItem : RealmObject public string Link { get; set; } public bool New { get; set; } public int Sequence { get; set; } - public string Title { get; set; } public static FeedItem Create() diff --git a/Application/Feeds/FeedReadResult.cs b/Application/Feeds/FeedReadResult.cs new file mode 100644 index 0000000..68f79ae --- /dev/null +++ b/Application/Feeds/FeedReadResult.cs @@ -0,0 +1,19 @@ +namespace FeedCenter; + +public enum FeedReadResult +{ + Success, + NotModified, + NotDue, + UnknownError, + InvalidXml, + NotEnabled, + Unauthorized, + NoResponse, + NotFound, + Timeout, + ConnectionFailed, + ServerError, + Moved, + TemporarilyUnavailable +} \ No newline at end of file diff --git a/Application/Feeds/FeedType.cs b/Application/Feeds/FeedType.cs new file mode 100644 index 0000000..953594d --- /dev/null +++ b/Application/Feeds/FeedType.cs @@ -0,0 +1,9 @@ +namespace FeedCenter; + +public enum FeedType +{ + Unknown, + Rss, + Rdf, + Atom +} \ No newline at end of file diff --git a/Application/Feeds/MultipleOpenAction.cs b/Application/Feeds/MultipleOpenAction.cs new file mode 100644 index 0000000..fea3868 --- /dev/null +++ b/Application/Feeds/MultipleOpenAction.cs @@ -0,0 +1,7 @@ +namespace FeedCenter; + +public enum MultipleOpenAction +{ + IndividualPages, + SinglePage +} \ No newline at end of file diff --git a/Application/MainWindow/CategoryList.cs b/Application/MainWindow/CategoryList.cs index 529cd04..f62cb49 100644 --- a/Application/MainWindow/CategoryList.cs +++ b/Application/MainWindow/CategoryList.cs @@ -72,7 +72,7 @@ public partial class MainWindow // If the category changed then reset the current feed to the first in the category if (_currentCategory?.Id != category?.Id) { - _currentFeed = category == null ? _database.Feeds.FirstOrDefault() : category.Feeds.FirstOrDefault(); + _currentFeed = category == null ? _database.Feeds.FirstOrDefault() : _database.Feeds.FirstOrDefault(f => f.CategoryId == category.Id); } // Set the current category diff --git a/Application/MainWindow/MainWindow.xaml.cs b/Application/MainWindow/MainWindow.xaml.cs index 00508f3..0ec56d0 100644 --- a/Application/MainWindow/MainWindow.xaml.cs +++ b/Application/MainWindow/MainWindow.xaml.cs @@ -104,8 +104,6 @@ public partial class MainWindow : IDisposable HandleCommandLine(commandLine); } - #region Setting events - private void HandlePropertyChanged(object sender, PropertyChangedEventArgs e) { // Make sure we're on the right thread @@ -147,10 +145,6 @@ public partial class MainWindow : IDisposable } } - #endregion - - #region Database helpers - private void ResetDatabase() { // Get the ID of the current feed @@ -191,10 +185,6 @@ public partial class MainWindow : IDisposable : _feedList.OrderBy(feed => feed.Name).AsEnumerable().ElementAt(_feedIndex); } - #endregion - - #region Feed display - private void UpdateToolbarButtonState() { // Cache the feed count to save (a little) time @@ -429,6 +419,4 @@ public partial class MainWindow : IDisposable // Clear the list LinkTextList.Items.Clear(); } - - #endregion } \ No newline at end of file diff --git a/Application/Options/BulkFeedWindow.xaml b/Application/Options/BulkFeedWindow.xaml index d26aae1..2817872 100644 --- a/Application/Options/BulkFeedWindow.xaml +++ b/Application/Options/BulkFeedWindow.xaml @@ -7,34 +7,41 @@ xmlns:my="clr-namespace:FeedCenter.Properties" xmlns:feedCenter="clr-namespace:FeedCenter" xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link" + xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:options="clr-namespace:FeedCenter.Options" WindowStartupLocation="CenterOwner" Icon="/FeedCenter;component/Resources/Application.ico" FocusManager.FocusedElement="{Binding ElementName=FeedLinkFilterText}"> - - - - - + + + + + + + + + + + - - - - + + + + + + + HorizontalContentAlignment="Stretch" + mah:TextBoxHelper.UseFloatingWatermark="True" + mah:TextBoxHelper.Watermark="{x:Static my:Resources.openLabel}" + IsEnabled="{Binding ElementName=OpenCheckBox, Path=IsChecked}"> -