Remove WinForms references and start on installer

This commit is contained in:
2023-04-22 09:05:41 -04:00
parent d6a2fd5a46
commit 586a0497d6
14 changed files with 572 additions and 676 deletions

View File

@@ -86,7 +86,7 @@ public partial class MainWindow
_database.SaveChanges(() => _database.Feeds.Add(feed));
// Show a tip
NotificationIcon.ShowBalloonTip(string.Format(Properties.Resources.FeedAddedNotification, feed.Name), System.Windows.Forms.ToolTipIcon.Info);
NotificationIcon.ShowBalloonTip(string.Format(Properties.Resources.FeedAddedNotification, feed.Name), H.NotifyIcon.Core.NotificationIcon.Info);
_currentFeed = feed;
@@ -104,7 +104,7 @@ public partial class MainWindow
var dialogResult = feedForm.Display(feed, this);
// Display the new feed form
if (!dialogResult.HasValue || !dialogResult.Value)
if (!dialogResult.HasValue || !dialogResult.Value)
return;
// Add the feed to the feed table

View File

@@ -34,6 +34,14 @@ public partial class MainWindow : IDisposable
GC.SuppressFinalize(this);
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
// Initialize the window
Initialize();
}
protected override async void OnClosed(EventArgs e)
{
base.OnClosed(e);
@@ -207,9 +215,7 @@ public partial class MainWindow : IDisposable
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

View File

@@ -1,6 +1,7 @@
using FeedCenter.Properties;
using System;
using System.Windows.Forms;
using System.Timers;
using System.Windows.Threading;
namespace FeedCenter;
@@ -9,11 +10,14 @@ public partial class MainWindow
private Timer _mainTimer;
private DateTime _lastFeedRead;
private DateTime _lastFeedDisplay;
private Dispatcher _dispatcher;
private void InitializeTimer()
{
_dispatcher = Dispatcher.CurrentDispatcher;
_mainTimer = new Timer { Interval = 1000 };
_mainTimer.Tick += HandleMainTimerTick;
_mainTimer.Elapsed += HandleMainTimerElapsed;
}
private void TerminateTimer()
@@ -33,26 +37,29 @@ public partial class MainWindow
_mainTimer.Stop();
}
private void HandleMainTimerTick(object sender, EventArgs e)
private void HandleMainTimerElapsed(object sender, EventArgs e)
{
// If the background worker is busy then don't do anything
if (_feedReadWorker.IsBusy)
return;
_dispatcher.Invoke(() =>
{
// If the background worker is busy then don't do anything
if (_feedReadWorker.IsBusy)
return;
// Stop the timer for now
StopTimer();
// Stop the timer for now
StopTimer();
// Move to the next feed if the scroll interval has expired and the mouse isn't hovering
if (LinkTextList.IsMouseOver)
_lastFeedDisplay = DateTime.Now;
else if (DateTime.Now - _lastFeedDisplay >= Settings.Default.FeedScrollInterval)
NextFeed();
// Move to the next feed if the scroll interval has expired and the mouse isn't hovering
if (LinkTextList.IsMouseOver)
_lastFeedDisplay = DateTime.Now;
else if (DateTime.Now - _lastFeedDisplay >= Settings.Default.FeedScrollInterval)
NextFeed();
// Check to see if we should try to read the feeds
if (DateTime.Now - _lastFeedRead >= Settings.Default.FeedCheckInterval)
ReadFeeds();
// Check to see if we should try to read the feeds
if (DateTime.Now - _lastFeedRead >= Settings.Default.FeedCheckInterval)
ReadFeeds();
// Get the timer going again
StartTimer();
// Get the timer going again
StartTimer();
});
}
}

View File

@@ -112,28 +112,28 @@ public partial class MainWindow
{
var windowInteropHelper = new WindowInteropHelper(this);
var screen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle);
var screen = WpfScreenHelper.Screen.FromHandle(windowInteropHelper.Handle);
var rectangle = new System.Drawing.Rectangle
var rectangle = new Rect
{
X = (int) Left,
Y = (int) Top,
Width = (int) Width,
Height = (int) Height
X = Left,
Y = Top,
Width = Width,
Height = Height
};
var borderThickness = new Thickness();
if (rectangle.Right != screen.WorkingArea.Right)
if (!rectangle.Right.Equals(screen.WorkingArea.Right))
borderThickness.Right = 1;
if (rectangle.Left != screen.WorkingArea.Left)
if (!rectangle.Left.Equals(screen.WorkingArea.Left))
borderThickness.Left = 1;
if (rectangle.Top != screen.WorkingArea.Top)
if (!rectangle.Top.Equals(screen.WorkingArea.Top))
borderThickness.Top = 1;
if (rectangle.Bottom != screen.WorkingArea.Bottom)
if (!rectangle.Bottom.Equals(screen.WorkingArea.Bottom))
borderThickness.Bottom = 1;
WindowBorder.BorderThickness = borderThickness;