Switch to NuGet packages

This commit is contained in:
2023-04-07 18:41:18 -04:00
parent 6514f23329
commit eac0313f23
26 changed files with 156 additions and 516 deletions

View File

@@ -1,4 +1,4 @@
using CKaczor.InstalledBrowsers;
using ChrisKaczor.InstalledBrowsers;
using FeedCenter.Properties;
using System;
using System.Linq;

View File

@@ -1,4 +1,4 @@
using CKaczor.ApplicationUpdate;
using ChrisKaczor.ApplicationUpdate;
using FeedCenter.Properties;
using System;
using System.Collections.Generic;

View File

@@ -1,4 +1,4 @@
using CKaczor.InstalledBrowsers;
using ChrisKaczor.InstalledBrowsers;
using FeedCenter.Properties;
using System.Windows;
using System.Windows.Input;

View File

@@ -2,13 +2,13 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:properties="clr-namespace:FeedCenter.Properties"
xmlns:windows="clr-namespace:CKaczor.Wpf.Windows;assembly=Wpf.Windows.SnappingWindow"
xmlns:toolbar="clr-namespace:CKaczor.Wpf.Controls.Toolbar;assembly=Wpf.Controls.Toolbar"
xmlns:splitButton="clr-namespace:CKaczor.Wpf.Controls.Toolbar;assembly=Wpf.Controls.Toolbar"
xmlns:htmlTextBlock="clr-namespace:CKaczor.Wpf.Controls;assembly=Wpf.Controls.HtmlTextBlock"
xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=Wpf.Windows.SnappingWindow"
xmlns:toolbar="clr-namespace:ChrisKaczor.Wpf.Controls.Toolbar;assembly=Wpf.Controls.Toolbar"
xmlns:splitButton="clr-namespace:ChrisKaczor.Wpf.Controls.Toolbar;assembly=Wpf.Controls.Toolbar"
xmlns:htmlTextBlock="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=Wpf.Controls.HtmlTextBlock"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:nameBasedGrid="clr-namespace:NameBasedGrid;assembly=NameBasedGrid"
xmlns:controls="clr-namespace:CKaczor.Wpf.Controls;assembly=Wpf.Controls.Link"
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=Wpf.Controls.Link"
Title="MainWindow"
Height="360"
Width="252"

View File

@@ -1,39 +1,31 @@
using CKaczor.ApplicationUpdate;
using CKaczor.Wpf.Application;
using FeedCenter.Data;
using FeedCenter.Properties;
using Serilog;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ChrisKaczor.Wpf.Application;
using ChrisKaczor.ApplicationUpdate;
using FeedCenter.Data;
using FeedCenter.Properties;
using Serilog;
namespace FeedCenter
{
public partial class MainWindow : IDisposable
{
private Category _currentCategory;
private Feed _currentFeed;
private FeedCenterEntities _database;
private int _feedIndex;
private Category _currentCategory;
private IEnumerable<Feed> _feedList;
private Feed _currentFeed;
public MainWindow()
{
InitializeComponent();
}
protected override async void OnClosed(EventArgs e)
{
base.OnClosed(e);
await SingleInstance.Stop();
}
public void Dispose()
{
_mainTimer?.Dispose();
@@ -42,6 +34,13 @@ namespace FeedCenter
GC.SuppressFinalize(this);
}
protected override async void OnClosed(EventArgs e)
{
base.OnClosed(e);
await SingleInstance.Stop();
}
public async void Initialize()
{
// Setup the update handler
@@ -54,7 +53,9 @@ namespace FeedCenter
LoadWindowSettings();
// Set the foreground color to something that can be seen
LinkTextList.Foreground = (System.Drawing.SystemColors.Desktop.GetBrightness() < 0.5) ? Brushes.White : Brushes.Black;
LinkTextList.Foreground = (System.Drawing.SystemColors.Desktop.GetBrightness() < 0.5)
? Brushes.White
: Brushes.Black;
HeaderLabel.Foreground = LinkTextList.Foreground;
// Create the background worker that does the actual reading
@@ -141,6 +142,50 @@ namespace FeedCenter
#endregion
#region Database helpers
private void ResetDatabase()
{
// Get the ID of the current feed
var currentId = _currentFeed?.Id ?? Guid.Empty;
// Create a new database object
_database.Refresh();
_feedList = _currentCategory == null
? _database.Feeds
: _database.Feeds.Where(feed => feed.Category.Id == _currentCategory.Id);
UpdateToolbarButtonState();
// Get a list of feeds ordered by name
var feedList = _feedList.OrderBy(f => f.Name).ToList();
// First try to find the current feed by ID to see if it is still there
var newIndex = feedList.FindIndex(f => f.Id == currentId);
if (newIndex == -1)
{
// The current feed isn't there anymore so see if we can find a feed at the old index
if (feedList.ElementAtOrDefault(_feedIndex) != null)
newIndex = _feedIndex;
// If there is no feed at the old location then give up and go back to the start
if (newIndex == -1 && feedList.Count > 0)
newIndex = 0;
}
// Set the current index to the new index
_feedIndex = newIndex;
// Re-get the current feed
_currentFeed = (_feedIndex == -1
? null
: _feedList.OrderBy(feed => feed.Name).AsEnumerable().ElementAt(_feedIndex));
}
#endregion
#region Feed display
private void UpdateToolbarButtonState()
@@ -163,11 +208,15 @@ namespace FeedCenter
private void InitializeDisplay()
{
// Get the last category (defaulting to none)
_currentCategory = _database.Categories.FirstOrDefault(category => category.Id.ToString() == Settings.Default.LastCategoryID);
_currentCategory =
_database.Categories.FirstOrDefault(category =>
category.Id.ToString() == Settings.Default.LastCategoryID);
DisplayCategory();
// Get the current feed list to match the category
_feedList = _currentCategory == null ? _database.Feeds : _database.Feeds.Where(feed => feed.Category.Id == _currentCategory.Id);
_feedList = _currentCategory == null
? _database.Feeds
: _database.Feeds.Where(feed => feed.Category.Id == _currentCategory.Id);
UpdateToolbarButtonState();
@@ -377,45 +426,5 @@ namespace FeedCenter
}
#endregion
#region Database helpers
private void ResetDatabase()
{
// Get the ID of the current feed
var currentId = _currentFeed?.Id ?? Guid.Empty;
// Create a new database object
_database.Refresh();
_feedList = _currentCategory == null ? _database.Feeds : _database.Feeds.Where(feed => feed.Category.Id == _currentCategory.Id);
UpdateToolbarButtonState();
// Get a list of feeds ordered by name
var feedList = _feedList.OrderBy(f => f.Name).ToList();
// First try to find the current feed by ID to see if it is still there
var newIndex = feedList.FindIndex(f => f.Id == currentId);
if (newIndex == -1)
{
// The current feed isn't there anymore so see if we can find a feed at the old index
if (feedList.ElementAtOrDefault(_feedIndex) != null)
newIndex = _feedIndex;
// If there is no feed at the old location then give up and go back to the start
if (newIndex == -1 && feedList.Count > 0)
newIndex = 0;
}
// Set the current index to the new index
_feedIndex = newIndex;
// Re-get the current feed
_currentFeed = (_feedIndex == -1 ? null : _feedList.OrderBy(feed => feed.Name).AsEnumerable().ElementAt(_feedIndex));
}
#endregion
}
}

View File

@@ -1,4 +1,4 @@
using CKaczor.InstalledBrowsers;
using ChrisKaczor.InstalledBrowsers;
using FeedCenter.Options;
using FeedCenter.Properties;
using System.IO;

View File

@@ -1,4 +1,4 @@
using CKaczor.ApplicationUpdate;
using ChrisKaczor.ApplicationUpdate;
using FeedCenter.Properties;
using System.Windows;