diff --git a/src/JustABlocker/App.xaml.cs b/src/JustABlocker/App.xaml.cs
index 121b287..c7ce19c 100644
--- a/src/JustABlocker/App.xaml.cs
+++ b/src/JustABlocker/App.xaml.cs
@@ -1,17 +1,18 @@
using System.Diagnostics;
using System.Drawing;
+using System.Threading;
using System.Windows;
-using System.Windows.Forms;
using JustABlocker.Services;
+using Forms = System.Windows.Forms;
namespace JustABlocker;
-public partial class App : Application
+public partial class App : System.Windows.Application
{
private Mutex? _mutex;
private WfpFilterService? _wfpService;
private BlacklistManager? _blacklistManager;
- private NotifyIcon? _trayIcon;
+ private Forms.NotifyIcon? _trayIcon;
private MainWindow? _mainWindow;
protected override void OnStartup(StartupEventArgs e)
@@ -64,18 +65,18 @@ public partial class App : Application
private void SetupTray()
{
- _trayIcon = new NotifyIcon
+ _trayIcon = new Forms.NotifyIcon
{
Icon = CreateTrayIcon(),
Text = "Just a Blocker",
Visible = true,
};
- var menu = new ContextMenuStrip();
+ var menu = new Forms.ContextMenuStrip();
menu.Items.Add("Show / Hide", null, (_, _) => ToggleWindow());
- menu.Items.Add(new ToolStripSeparator());
+ menu.Items.Add(new Forms.ToolStripSeparator());
menu.Items.Add("Pause", null, (_, _) => TogglePause());
- menu.Items.Add(new ToolStripSeparator());
+ menu.Items.Add(new Forms.ToolStripSeparator());
menu.Items.Add("Exit", null, (_, _) => ExitApp());
_trayIcon.ContextMenuStrip = menu;
@@ -90,8 +91,8 @@ public partial class App : Application
using var brush = new SolidBrush(Color.Red);
g.FillRectangle(brush, 3, 3, 10, 10);
using var whiteBrush = new SolidBrush(Color.White);
- var font = new Font("Segoe UI", 8, FontStyle.Bold);
- g.DrawString("!", font, whiteBrush, 4, 2);
+ using var font = new System.Drawing.Font("Segoe UI", 8, System.Drawing.FontStyle.Bold);
+ g.DrawString("!", font, whiteBrush, 4.0f, 2.0f);
var hicon = bitmap.GetHicon();
return Icon.FromHandle(hicon);
}
@@ -162,8 +163,12 @@ public partial class App : Application
private void ExitApp()
{
- _trayIcon?.Visible = false;
- _trayIcon?.Dispose();
+ if (_trayIcon != null)
+ {
+ _trayIcon.Visible = false;
+ _trayIcon.Dispose();
+ _trayIcon = null;
+ }
Current.Shutdown();
}
diff --git a/src/JustABlocker/JustABlocker.csproj b/src/JustABlocker/JustABlocker.csproj
index 197981c..a9d43cc 100644
--- a/src/JustABlocker/JustABlocker.csproj
+++ b/src/JustABlocker/JustABlocker.csproj
@@ -8,6 +8,11 @@
JustABlocker
JustABlocker
app.manifest
+ enable
true
+
+
+
+
diff --git a/src/JustABlocker/MainWindow.xaml.cs b/src/JustABlocker/MainWindow.xaml.cs
index 18bda2f..b6ed653 100644
--- a/src/JustABlocker/MainWindow.xaml.cs
+++ b/src/JustABlocker/MainWindow.xaml.cs
@@ -1,3 +1,5 @@
+using System;
+using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -93,7 +95,7 @@ public partial class MainWindow : Window
InputBox.Focus();
}
- private void InputBox_OnKeyDown(object sender, KeyEventArgs e)
+ private void InputBox_OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
diff --git a/src/JustABlocker/Models/BlacklistEntry.cs b/src/JustABlocker/Models/BlacklistEntry.cs
index 2bda73a..3a39b5b 100644
--- a/src/JustABlocker/Models/BlacklistEntry.cs
+++ b/src/JustABlocker/Models/BlacklistEntry.cs
@@ -1,3 +1,4 @@
+using System;
using System.Text.Json.Serialization;
namespace JustABlocker.Models;
diff --git a/src/JustABlocker/Native/WfpNative.cs b/src/JustABlocker/Native/WfpNative.cs
index 79df899..fb2a7cd 100644
--- a/src/JustABlocker/Native/WfpNative.cs
+++ b/src/JustABlocker/Native/WfpNative.cs
@@ -1,3 +1,4 @@
+using System;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
diff --git a/src/JustABlocker/Services/BlacklistManager.cs b/src/JustABlocker/Services/BlacklistManager.cs
index 1528674..1c0104f 100644
--- a/src/JustABlocker/Services/BlacklistManager.cs
+++ b/src/JustABlocker/Services/BlacklistManager.cs
@@ -1,4 +1,7 @@
+using System;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.IO;
using System.Text.Json;
using JustABlocker.Models;
diff --git a/src/JustABlocker/Services/DnsResolver.cs b/src/JustABlocker/Services/DnsResolver.cs
index c8b15a7..66ee6ed 100644
--- a/src/JustABlocker/Services/DnsResolver.cs
+++ b/src/JustABlocker/Services/DnsResolver.cs
@@ -1,3 +1,5 @@
+using System;
+using System.Collections.Generic;
using System.Net;
using JustABlocker.Models;
diff --git a/src/JustABlocker/Services/WfpFilterService.cs b/src/JustABlocker/Services/WfpFilterService.cs
index 40d0bc4..6968810 100644
--- a/src/JustABlocker/Services/WfpFilterService.cs
+++ b/src/JustABlocker/Services/WfpFilterService.cs
@@ -1,3 +1,5 @@
+using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;