diff --git a/Source/Hurl.BrowserSelector/App.xaml b/Source/Hurl.BrowserSelector/App.xaml
index 9607ca83..3ba3ceeb 100644
--- a/Source/Hurl.BrowserSelector/App.xaml
+++ b/Source/Hurl.BrowserSelector/App.xaml
@@ -3,12 +3,12 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Hurl.BrowserSelector"
- xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
+ xmlns:wpfui="http://schemas.lepo.co/wpfui/2022/xaml">
-
-
+
+
diff --git a/Source/Hurl.BrowserSelector/App.xaml.cs b/Source/Hurl.BrowserSelector/App.xaml.cs
index 42cf587b..06c50aeb 100644
--- a/Source/Hurl.BrowserSelector/App.xaml.cs
+++ b/Source/Hurl.BrowserSelector/App.xaml.cs
@@ -29,7 +29,7 @@ public partial class App : Application
public App()
{
- this.Dispatcher.UnhandledException += Dispatcher_UnhandledException;
+ Dispatcher.UnhandledException += Dispatcher_UnhandledException;
}
private void Dispatcher_UnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
@@ -72,7 +72,7 @@ protected override void OnStartup(StartupEventArgs e)
{
if (Current.MainWindow is { } window)
{
- _mainWindow.MaximizeWindow();
+ _mainWindow.ShowWindow();
}
else
{
@@ -129,12 +129,10 @@ public void PipeServer()
try
{
- using (StreamReader sr = new(pipeserver))
- {
- string args = sr.ReadToEnd();
- string[] argsArray = JsonSerializer.Deserialize(args) ?? [];
- OnInstanceInvoked(argsArray);
- }
+ using StreamReader sr = new(pipeserver);
+ string args = sr.ReadToEnd();
+ string[] argsArray = JsonSerializer.Deserialize(args) ?? [];
+ OnInstanceInvoked(argsArray);
}
catch (Exception e)
{
diff --git a/Source/Hurl.BrowserSelector/Controls/BrowsersList.xaml b/Source/Hurl.BrowserSelector/Controls/BrowsersList.xaml
index fa371036..083f4b3b 100644
--- a/Source/Hurl.BrowserSelector/Controls/BrowsersList.xaml
+++ b/Source/Hurl.BrowserSelector/Controls/BrowsersList.xaml
@@ -55,7 +55,7 @@
CornerRadius="5"
Cursor="Hand"
Focusable="True"
- MouseLeftButtonUp="BtnArea_MouseLeftButtonUp"
+ MouseLeftButtonUp="BrowserButton_Click"
Tag="{Binding}"
ToolTip="{Binding Path=Name}">
@@ -130,6 +130,4 @@
-
-
diff --git a/Source/Hurl.BrowserSelector/Controls/BrowsersList.xaml.cs b/Source/Hurl.BrowserSelector/Controls/BrowsersList.xaml.cs
index d3a3807a..79c304f8 100644
--- a/Source/Hurl.BrowserSelector/Controls/BrowsersList.xaml.cs
+++ b/Source/Hurl.BrowserSelector/Controls/BrowsersList.xaml.cs
@@ -15,7 +15,7 @@ public partial class BrowsersList : UserControl
{
public BrowsersList()
{
- DataContext = Globals.SettingsGlobal.GetBrowsers();
+ DataContext = SettingsGlobal.GetBrowsers();
InitializeComponent();
Loaded += (s, e) =>
{
@@ -41,9 +41,9 @@ private void OnPreviewKeyUp(object sender, KeyEventArgs e)
//if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control)) { }
}
- private void BtnArea_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ private void BrowserButton_Click(object sender, MouseButtonEventArgs e)
{
- var tag = (sender as Border).Tag as Browser;
+ var tag = ((Border)sender).Tag as Browser;
OpenLink(tag);
MinimizeWindow();
}
@@ -66,12 +66,12 @@ private void AdditionalBtn_Click(object sender, RoutedEventArgs e)
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
- var alt = (sender as MenuItem).Tag as AltLaunchParentConverter.AltLaunchParent;
+ var alt = ((MenuItem)sender).Tag as AltLaunchParentConverter.AltLaunchParent;
OpenAltLaunch(alt.AltLaunch, alt.Browser);
MinimizeWindow();
}
- public void OpenLink(Browser clickedbrowser)
+ public static void OpenLink(Browser clickedbrowser)
{
var browser = clickedbrowser;
var Link = UriGlobal.Value;
@@ -88,7 +88,7 @@ public void OpenLink(Browser clickedbrowser)
}
}
- public void OpenAltLaunch(AlternateLaunch alt, Browser browser)
+ public static void OpenAltLaunch(AlternateLaunch alt, Browser browser)
{
if (alt.LaunchArgs.Contains("%URL%"))
{
diff --git a/Source/Hurl.BrowserSelector/Converters/AltLaunchParentConverter.cs b/Source/Hurl.BrowserSelector/Converters/AltLaunchParentConverter.cs
index c1010622..ebb0a310 100644
--- a/Source/Hurl.BrowserSelector/Converters/AltLaunchParentConverter.cs
+++ b/Source/Hurl.BrowserSelector/Converters/AltLaunchParentConverter.cs
@@ -24,10 +24,10 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
- return new object[] {
+ return [
(value as AltLaunchParent).AltLaunch,
(value as AltLaunchParent).Browser
- };
+ ];
}
}
}
diff --git a/Source/Hurl.BrowserSelector/Globals/Settings.cs b/Source/Hurl.BrowserSelector/Globals/Settings.cs
index f0d0725e..adb17e45 100644
--- a/Source/Hurl.BrowserSelector/Globals/Settings.cs
+++ b/Source/Hurl.BrowserSelector/Globals/Settings.cs
@@ -7,11 +7,11 @@ namespace Hurl.BrowserSelector.Globals
{
public class SettingsGlobal
{
- private static SettingsGlobal _instance = new();
+ private static readonly SettingsGlobal _instance = new();
- private Library.Models.Settings _settings = SettingsFile.GetSettings();
+ private Settings _settings = SettingsFile.GetSettings();
- public static Library.Models.Settings Value
+ public static Settings Value
{
get
{
@@ -27,7 +27,7 @@ public static void AddBrowserRule(List rules, string name)
{
if (Value?.Rulesets == null)
{
- Value.Rulesets = new List { };
+ Value.Rulesets = [];
}
Value.Rulesets.Add(new Ruleset() { Rules = rules, BrowserName = name });
@@ -40,11 +40,11 @@ public static void AdjustWindowSize(SizeChangedEventArgs e)
{
if (Value.AppSettings != null)
{
- Value.AppSettings.WindowSize = new int[] { (int)e.NewSize.Width, (int)e.NewSize.Height };
+ Value.AppSettings.WindowSize = [(int)e.NewSize.Width, (int)e.NewSize.Height];
}
else
{
- Value.AppSettings = new AppSettings() { WindowSize = new int[] { (int)e.NewSize.Width, (int)e.NewSize.Height } };
+ Value.AppSettings = new AppSettings() { WindowSize = [(int)e.NewSize.Width, (int)e.NewSize.Height] };
}
Save();
diff --git a/Source/Hurl.BrowserSelector/Globals/Uri.cs b/Source/Hurl.BrowserSelector/Globals/Uri.cs
index f256a07d..c0de4901 100644
--- a/Source/Hurl.BrowserSelector/Globals/Uri.cs
+++ b/Source/Hurl.BrowserSelector/Globals/Uri.cs
@@ -5,10 +5,7 @@ namespace Hurl.BrowserSelector.Globals
{
public sealed class UriGlobal : INotifyPropertyChanged
{
- private UriGlobal(string Url)
- {
- this.Url = Url;
- }
+ private UriGlobal(string Url) => this.Url = Url;
private string _url;
private string Url
@@ -24,31 +21,25 @@ private string Url
}
}
- private static UriGlobal _instance = null;
+ private static UriGlobal? _instance;
public static string Value
{
get
{
- if (_instance == null)
- {
- _instance = new UriGlobal(string.Empty);
- }
+ _instance ??= new UriGlobal(string.Empty);
return _instance.Url;
}
set
{
- if (_instance == null)
- {
- _instance = new UriGlobal(value);
- }
+ _instance ??= new UriGlobal(value);
_instance.Url = value;
}
}
public event PropertyChangedEventHandler PropertyChanged;
- protected void OnPropertyChanged([CallerMemberName] string name = null)
+ protected void OnPropertyChanged([CallerMemberName] string? name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
diff --git a/Source/Hurl.BrowserSelector/Helpers/CursorPosition.cs b/Source/Hurl.BrowserSelector/Helpers/CursorPosition.cs
index acc26d02..c2762ea8 100644
--- a/Source/Hurl.BrowserSelector/Helpers/CursorPosition.cs
+++ b/Source/Hurl.BrowserSelector/Helpers/CursorPosition.cs
@@ -3,11 +3,11 @@
namespace Hurl.BrowserSelector.Helpers
{
- public static class CursorPosition
+ public static partial class CursorPosition
{
- [DllImport("user32.dll")]
+ [LibraryImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool GetCursorPos(ref Win32Point pt);
+ internal static partial bool GetCursorPos(ref Win32Point pt);
[StructLayout(LayoutKind.Sequential)]
internal struct Win32Point
diff --git a/Source/Hurl.BrowserSelector/Hurl.BrowserSelector.csproj b/Source/Hurl.BrowserSelector/Hurl.BrowserSelector.csproj
index 21768e74..7bbff54e 100644
--- a/Source/Hurl.BrowserSelector/Hurl.BrowserSelector.csproj
+++ b/Source/Hurl.BrowserSelector/Hurl.BrowserSelector.csproj
@@ -10,6 +10,7 @@
true
Assets\internet.ico
Hurl.BrowserSelector.App
+ true
x64
diff --git a/Source/Hurl.BrowserSelector/Windows/MainWindow.xaml b/Source/Hurl.BrowserSelector/Windows/MainWindow.xaml
index 71f8fe59..3da2109c 100644
--- a/Source/Hurl.BrowserSelector/Windows/MainWindow.xaml
+++ b/Source/Hurl.BrowserSelector/Windows/MainWindow.xaml
@@ -16,7 +16,7 @@
Deactivated="Window_Deactivated"
ExtendsContentIntoTitleBar="True"
PreviewKeyUp="Window_KeyEvents"
- SizeChanged="UiWindow_SizeChanged"
+ SizeChanged="Window_SizeChanged"
Topmost="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen"
@@ -129,7 +129,7 @@
Padding="7,3"
Background="{x:Null}"
BorderBrush="{x:Null}"
- Click="linkpreview_Click"
+ Click="Linkpreview_Click"
Cursor="Hand"
Foreground="AliceBlue"
ToolTip="Edit URL (E)" />
diff --git a/Source/Hurl.BrowserSelector/Windows/MainWindow.xaml.cs b/Source/Hurl.BrowserSelector/Windows/MainWindow.xaml.cs
index b3a73ff3..7ef7a9f0 100644
--- a/Source/Hurl.BrowserSelector/Windows/MainWindow.xaml.cs
+++ b/Source/Hurl.BrowserSelector/Windows/MainWindow.xaml.cs
@@ -17,7 +17,7 @@ public partial class MainWindow : FluentWindow
public MainWindow()
{
- var settings = Globals.SettingsGlobal.Value;
+ var settings = SettingsGlobal.Value;
InitializeComponent();
@@ -56,17 +56,17 @@ public void Init(CliArgs data)
if (data.IsRunAsMin || isRuleCheckSuccess)
{
- Show(); // TODO: try to remove the flashing
MinimizeWindow();
+ Show();
}
else
{
- Show();
PositionWindowUnderTheMouse();
if (data.IsSecondInstance)
{
WindowState = WindowState.Normal;
}
+ Show();
}
linkpreview.Content = string.IsNullOrEmpty(UriGlobal.Value) ? "No Url Opened" : UriGlobal.Value;
@@ -127,33 +127,33 @@ private void LinkCopyBtnClick(object sender, RoutedEventArgs e)
}
private void SettingsBtnClick(object sender, RoutedEventArgs e) => Process.Start("explorer", "\"" + Constants.APP_SETTINGS_MAIN + "\"");
- private void Draggable(object sender, MouseButtonEventArgs e) => this.DragMove();
+ private void Draggable(object sender, MouseButtonEventArgs e) => DragMove();
private void CloseBtnClick(object sender, RoutedEventArgs e) => MinimizeWindow();
private void MinimizeWindow()
{
- this.WindowState = WindowState.Minimized;
- this.Hide();
+ WindowState = WindowState.Minimized;
+ Hide();
}
- public void MaximizeWindow()
+ public void ShowWindow()
{
- this.Show();
+ Show();
PositionWindowUnderTheMouse();
- this.WindowState = WindowState.Normal;
+ WindowState = WindowState.Normal;
}
private void TrayMenuItem_OnClick(object sender, RoutedEventArgs e)
{
- var settings = Globals.SettingsGlobal.Value;
+ _ = SettingsGlobal.Value;
- string tag = (sender as Wpf.Ui.Controls.MenuItem).Tag as string;
+ string tag = ((MenuItem)sender).Tag as string;
try
{
switch (tag)
{
case "open":
- MaximizeWindow();
+ ShowWindow();
break;
case "settings":
Process.Start("explorer", "\"" + Constants.APP_SETTINGS_MAIN + "\"");
@@ -176,7 +176,7 @@ private void TrayMenuItem_OnClick(object sender, RoutedEventArgs e)
}
}
- private void NotifyIcon_LeftClick(object sender, RoutedEventArgs e) => MaximizeWindow();
+ private void NotifyIcon_LeftClick(object sender, RoutedEventArgs e) => ShowWindow();
private void Window_Deactivated(object sender, EventArgs e)
{
@@ -189,7 +189,7 @@ private void Window_Deactivated(object sender, EventArgs e)
private void PositionWindowUnderTheMouse()
{
- var settings = Globals.SettingsGlobal.Value;
+ var settings = SettingsGlobal.Value;
if (settings.AppSettings != null && settings.AppSettings.LaunchUnderMouse)
{
@@ -198,20 +198,20 @@ private void PositionWindowUnderTheMouse()
Left = mouse.X;
Top = mouse.Y;
- Debug.WriteLine($"{Left}x{Top} while screen res: {SystemParameters.FullPrimaryScreenWidth}x{SystemParameters.FullPrimaryScreenHeight}");
+ Debug.WriteLine($"{Left}×{Top} with screen resolution: {SystemParameters.FullPrimaryScreenWidth}×{SystemParameters.FullPrimaryScreenHeight}");
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
forcePreventWindowDeactivationEvent = true;
- new TimeSelectWindow(Globals.SettingsGlobal.Value.Browsers).ShowDialog();
+ new TimeSelectWindow(SettingsGlobal.Value.Browsers).ShowDialog();
forcePreventWindowDeactivationEvent = false;
}
- private void UiWindow_SizeChanged(object sender, SizeChangedEventArgs e) => Globals.SettingsGlobal.AdjustWindowSize(e);
+ private void Window_SizeChanged(object sender, SizeChangedEventArgs e) => SettingsGlobal.AdjustWindowSize(e);
- async private void linkpreview_Click(object sender, RoutedEventArgs e)
+ async private void Linkpreview_Click(object sender, RoutedEventArgs e)
{
forcePreventWindowDeactivationEvent = true;
@@ -219,8 +219,8 @@ async private void linkpreview_Click(object sender, RoutedEventArgs e)
if (!string.IsNullOrEmpty(NewUrl))
{
UriGlobal.Value = NewUrl;
- (sender as Wpf.Ui.Controls.Button).Content = NewUrl;
- (sender as Wpf.Ui.Controls.Button).ToolTip = NewUrl;
+ ((Button)sender).Content = NewUrl;
+ ((Button)sender).ToolTip = NewUrl;
}
forcePreventWindowDeactivationEvent = false;
@@ -232,4 +232,3 @@ private void Button_Click_1(object sender, RoutedEventArgs e)
Process.Start(Constants.SETTINGS_APP);
}
}
-
diff --git a/Source/Hurl.BrowserSelector/Windows/TimeSelectWindow.xaml b/Source/Hurl.BrowserSelector/Windows/TimeSelectWindow.xaml
index b7d44939..b5cdda9b 100644
--- a/Source/Hurl.BrowserSelector/Windows/TimeSelectWindow.xaml
+++ b/Source/Hurl.BrowserSelector/Windows/TimeSelectWindow.xaml
@@ -40,13 +40,13 @@
ItemsSource="{Binding}" />
-
+
Cancel Current
diff --git a/Source/Hurl.BrowserSelector/Windows/TimeSelectWindow.xaml.cs b/Source/Hurl.BrowserSelector/Windows/TimeSelectWindow.xaml.cs
index c6309db9..e134e479 100644
--- a/Source/Hurl.BrowserSelector/Windows/TimeSelectWindow.xaml.cs
+++ b/Source/Hurl.BrowserSelector/Windows/TimeSelectWindow.xaml.cs
@@ -10,7 +10,7 @@ namespace Hurl.BrowserSelector.Windows
///
public partial class TimeSelectWindow : FluentWindow
{
- private List browsers;
+ private readonly List browsers;
public TimeSelectWindow(List x)
{
@@ -19,7 +19,7 @@ public TimeSelectWindow(List x)
DataContext = x.ConvertAll(y => y.Name);
}
- private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
+ private void SetBtn_Click(object sender, System.Windows.RoutedEventArgs e)
{
var x = TimeBox.Value;
var y = BrowserBox.SelectedIndex;
@@ -28,14 +28,14 @@ private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
TimedBrowserSelect.Create((int)x, browsers[y]);
- this.Close();
+ Close();
}
}
- private void Button_Click_1(object sender, System.Windows.RoutedEventArgs e)
+ private void CancelBtn_Click(object sender, System.Windows.RoutedEventArgs e)
{
TimedBrowserSelect.DeleteCurrent();
- this.Close();
+ Close();
}
}
}
diff --git a/Source/Hurl.Library/Constants.cs b/Source/Hurl.Library/Constants.cs
index 6a5d4922..e0cfbf5b 100644
--- a/Source/Hurl.Library/Constants.cs
+++ b/Source/Hurl.Library/Constants.cs
@@ -1,5 +1,4 @@
-using System;
-using System.IO;
+using System.IO;
namespace Hurl.Library;
diff --git a/Source/Hurl.Library/Extensions/IEnumerableExtensions.cs b/Source/Hurl.Library/Extensions/IEnumerableExtensions.cs
index 2daa99c0..b977108c 100644
--- a/Source/Hurl.Library/Extensions/IEnumerableExtensions.cs
+++ b/Source/Hurl.Library/Extensions/IEnumerableExtensions.cs
@@ -1,7 +1,4 @@
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Hurl.Library.Extensions;
+namespace Hurl.Library.Extensions;
public static class IEnumerableExtensions
{
diff --git a/Source/Hurl.Library/GetBrowsers.cs b/Source/Hurl.Library/GetBrowsers.cs
index 67a80429..8f954a06 100644
--- a/Source/Hurl.Library/GetBrowsers.cs
+++ b/Source/Hurl.Library/GetBrowsers.cs
@@ -1,8 +1,6 @@
using Hurl.Library.Models;
using Microsoft.Win32;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
namespace Hurl.Library;
@@ -14,7 +12,7 @@ public static List FromRegistry()
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Clients\\StartMenuInternet"))
{
- browsers = new List();
+ browsers = [];
string[] x = key.GetSubKeyNames();
for (int i = 0; i < x.Length; i++)
{
diff --git a/Source/Hurl.Library/IconExtractor.cs b/Source/Hurl.Library/IconExtractor.cs
index 3410b2e0..e2730c4c 100644
--- a/Source/Hurl.Library/IconExtractor.cs
+++ b/Source/Hurl.Library/IconExtractor.cs
@@ -1,5 +1,4 @@
-using System;
-using System.ComponentModel;
+using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.InteropServices;
@@ -19,8 +18,8 @@ public static Icon FromFile(string filename)
{
try
{
- IntPtr[] phicon = new IntPtr[] { IntPtr.Zero };
- IntPtr[] piconid = new IntPtr[] { IntPtr.Zero };
+ IntPtr[] phicon = [IntPtr.Zero];
+ IntPtr[] piconid = [IntPtr.Zero];
PrivateExtractIcons(filename, 0, 128, 128, phicon, piconid, 1, 0);
diff --git a/Source/Hurl.Library/Models/AppSettings.cs b/Source/Hurl.Library/Models/AppSettings.cs
index 2cae787c..ffe08417 100644
--- a/Source/Hurl.Library/Models/AppSettings.cs
+++ b/Source/Hurl.Library/Models/AppSettings.cs
@@ -8,5 +8,5 @@ public class AppSettings
public string BackgroundType { get; set; } = "mica";
- public int[] WindowSize { get; set; } = new int[] { 420, 210 };
+ public int[] WindowSize { get; set; } = [420, 210];
}
diff --git a/Source/Hurl.Library/Models/Browser.cs b/Source/Hurl.Library/Models/Browser.cs
index 27120ef6..e0a8506b 100644
--- a/Source/Hurl.Library/Models/Browser.cs
+++ b/Source/Hurl.Library/Models/Browser.cs
@@ -1,4 +1,3 @@
-using System;
using System.Drawing;
using System.Text.Json.Serialization;
using System.Windows;
diff --git a/Source/Hurl.Library/Models/Ruleset.cs b/Source/Hurl.Library/Models/Ruleset.cs
index 730b858a..2d8af447 100644
--- a/Source/Hurl.Library/Models/Ruleset.cs
+++ b/Source/Hurl.Library/Models/Ruleset.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text.Json.Serialization;
+using System.Text.Json.Serialization;
namespace Hurl.Library.Models;
@@ -46,8 +44,8 @@ public Rule(string storedRule)
var modeLetter = split[0];
var content = split[1];
- this.RuleContent = content;
- this.Mode = modeLetter switch
+ RuleContent = content;
+ Mode = modeLetter switch
{
"d" => RuleMode.Domain,
"r" => RuleMode.Regex,
@@ -57,8 +55,8 @@ public Rule(string storedRule)
}
else
{
- this.RuleContent = storedRule;
- this.Mode = RuleMode.String;
+ RuleContent = storedRule;
+ Mode = RuleMode.String;
}
}
diff --git a/Source/Hurl.Library/Models/Settings.cs b/Source/Hurl.Library/Models/Settings.cs
index af7bc692..c128208c 100644
--- a/Source/Hurl.Library/Models/Settings.cs
+++ b/Source/Hurl.Library/Models/Settings.cs
@@ -1,5 +1,3 @@
-using System;
-using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Hurl.Library.Models;
diff --git a/Source/Hurl.Library/Models/TemporaryDefaultBrowser.cs b/Source/Hurl.Library/Models/TemporaryDefaultBrowser.cs
index 75ed5ee1..23fc4745 100644
--- a/Source/Hurl.Library/Models/TemporaryDefaultBrowser.cs
+++ b/Source/Hurl.Library/Models/TemporaryDefaultBrowser.cs
@@ -1,6 +1,4 @@
-using System;
-
-namespace Hurl.Library.Models;
+namespace Hurl.Library.Models;
public class TemporaryDefaultBrowser
{
diff --git a/Source/Hurl.Library/RuleMatch.cs b/Source/Hurl.Library/RuleMatch.cs
index cb7045fa..3d8ffdf1 100644
--- a/Source/Hurl.Library/RuleMatch.cs
+++ b/Source/Hurl.Library/RuleMatch.cs
@@ -1,8 +1,5 @@
using DotNet.Globbing;
using Hurl.Library.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Text.RegularExpressions;
namespace Hurl.Library;
diff --git a/Source/Hurl.Library/SettingsFile.cs b/Source/Hurl.Library/SettingsFile.cs
index 1c0de3aa..73f3967e 100644
--- a/Source/Hurl.Library/SettingsFile.cs
+++ b/Source/Hurl.Library/SettingsFile.cs
@@ -1,6 +1,4 @@
using Hurl.Library.Models;
-using System;
-using System.Collections.Generic;
using System.IO;
namespace Hurl.Library;
@@ -11,7 +9,7 @@ public class SettingsFile
private SettingsFile(Settings settings)
{
- this.SettingsObject = settings;
+ SettingsObject = settings;
}
public static SettingsFile TryLoading()
diff --git a/Source/Hurl.RulesetManager/App.xaml b/Source/Hurl.RulesetManager/App.xaml
index 3b167770..92aa63ce 100644
--- a/Source/Hurl.RulesetManager/App.xaml
+++ b/Source/Hurl.RulesetManager/App.xaml
@@ -3,14 +3,14 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Hurl.RulesetManager"
- xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
+ xmlns:wpfui="http://schemas.lepo.co/wpfui/2022/xaml"
DispatcherUnhandledException="Dispatcher_UnhandledException"
Startup="Application_Startup">
-
-
+
+
diff --git a/Source/Hurl.RulesetManager/Controls/RulesetAccordion.xaml b/Source/Hurl.RulesetManager/Controls/RulesetAccordion.xaml
index 820faa87..9511a9be 100644
--- a/Source/Hurl.RulesetManager/Controls/RulesetAccordion.xaml
+++ b/Source/Hurl.RulesetManager/Controls/RulesetAccordion.xaml
@@ -5,11 +5,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Hurl.RulesetManager.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
+ xmlns:wpfui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d">
-
-
+
+
@@ -37,34 +37,34 @@
Grid.Column="2"
Margin="8,0"
Orientation="Horizontal">
-
-
+
-
+
-
+
+ Foreground="{wpfui:ThemeResource SystemFillColorCriticalBrush}"
+ Icon="{wpfui:SymbolIcon Delete16}" />
-
+
-
+
-
+
-
+
diff --git a/Source/Hurl.RulesetManager/Controls/RulesetAccordion.xaml.cs b/Source/Hurl.RulesetManager/Controls/RulesetAccordion.xaml.cs
index d9d9eae8..ee7d8b44 100644
--- a/Source/Hurl.RulesetManager/Controls/RulesetAccordion.xaml.cs
+++ b/Source/Hurl.RulesetManager/Controls/RulesetAccordion.xaml.cs
@@ -53,9 +53,7 @@ private void UpButton_Click(object sender, RoutedEventArgs e)
}
else
{
- var temp = SettingsState.Rulesets[index];
- SettingsState.Rulesets[index] = SettingsState.Rulesets[index - 1];
- SettingsState.Rulesets[index - 1] = temp;
+ (SettingsState.Rulesets[index - 1], SettingsState.Rulesets[index]) = (SettingsState.Rulesets[index], SettingsState.Rulesets[index - 1]);
SettingsState.Update();
Refresh?.Invoke();
}
@@ -71,9 +69,7 @@ private void DownButton_Click(object sender, RoutedEventArgs e)
}
else
{
- var temp = SettingsState.Rulesets[index];
- SettingsState.Rulesets[index] = SettingsState.Rulesets[index + 1];
- SettingsState.Rulesets[index + 1] = temp;
+ (SettingsState.Rulesets[index + 1], SettingsState.Rulesets[index]) = (SettingsState.Rulesets[index], SettingsState.Rulesets[index + 1]);
SettingsState.Update();
Refresh?.Invoke();
}
@@ -91,4 +87,3 @@ private void DeleteButton_Click(object sender, RoutedEventArgs e)
}
}
}
-
diff --git a/Source/Hurl.RulesetManager/SettingsState.cs b/Source/Hurl.RulesetManager/SettingsState.cs
index 004d2444..a48a76de 100644
--- a/Source/Hurl.RulesetManager/SettingsState.cs
+++ b/Source/Hurl.RulesetManager/SettingsState.cs
@@ -12,7 +12,7 @@ private SettingsState()
private static readonly SettingsState _state = new();
- private Settings _settings;
+ private readonly Settings _settings;
public static Settings Get => _state._settings;
@@ -22,7 +22,7 @@ public static List Rulesets
{
if (Get.Rulesets == null)
{
- Get.Rulesets = new();
+ Get.Rulesets = [];
}
return Get.Rulesets;
}
diff --git a/Source/Hurl.RulesetManager/ViewModels/EditRulesetViewModel.cs b/Source/Hurl.RulesetManager/ViewModels/EditRulesetViewModel.cs
index c40f7b9c..d6190043 100644
--- a/Source/Hurl.RulesetManager/ViewModels/EditRulesetViewModel.cs
+++ b/Source/Hurl.RulesetManager/ViewModels/EditRulesetViewModel.cs
@@ -21,7 +21,7 @@ public EditRulesetViewModel(Ruleset? set)
Name = set?.RulesetName;
Rules = set?.Rules?
.Select(x => new Rule(x))
- .ToList() ?? new List();
+ .ToList() ?? [];
if (set?.BrowserName is string browser)
SelectedBrowser = Browsers.IndexOf(browser);
@@ -34,7 +34,7 @@ public EditRulesetViewModel()
Browsers = SettingsState.GetBrowsers()
.Select(x => x.Name)
.ToList();
- Rules = new List();
+ Rules = [];
}
private int _selectedBrowser;
@@ -66,7 +66,7 @@ private void SelectedBrowserChanged(int? value)
var altLaunchesWithNone = new List { "< None >" };
altLaunchesWithNone.AddRange(selected?.AlternateLaunches?
.Select(x => x.ItemName)
- .ToList() ?? new List());
+ .ToList() ?? []);
AltLaunches = altLaunchesWithNone;
//SelectedAltLaunch = 0;
}
diff --git a/Source/Hurl.RulesetManager/Windows/EditRuleset.xaml b/Source/Hurl.RulesetManager/Windows/EditRuleset.xaml
index e1b5e8ff..06dfcf31 100644
--- a/Source/Hurl.RulesetManager/Windows/EditRuleset.xaml
+++ b/Source/Hurl.RulesetManager/Windows/EditRuleset.xaml
@@ -1,11 +1,11 @@
-
-
-
-
+
-
+
-
+
@@ -86,9 +86,9 @@
ItemsSource="{Binding AltLaunches, Mode=TwoWay}"
SelectedIndex="{Binding SelectedAltLaunch, Mode=TwoWay}" />
-
+
-
+
@@ -112,34 +112,34 @@
String
-
-
+ Icon="{wpfui:SymbolIcon Info16}">
Info
-
-
+
+ Icon="{wpfui:SymbolIcon Add16}">
Add
-
+
-
+
@@ -148,7 +148,7 @@
-
+
@@ -174,7 +174,7 @@
Remove
-
+
@@ -183,27 +183,27 @@
-
+
-
Cancel
-
-
+
Save
-
+
-
+
-
+
diff --git a/Source/Hurl.RulesetManager/Windows/EditRuleset.xaml.cs b/Source/Hurl.RulesetManager/Windows/EditRuleset.xaml.cs
index f7679b98..53ca9f40 100644
--- a/Source/Hurl.RulesetManager/Windows/EditRuleset.xaml.cs
+++ b/Source/Hurl.RulesetManager/Windows/EditRuleset.xaml.cs
@@ -66,13 +66,13 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
_successCallback(DataContext as EditRulesetViewModel);
- this.Close();
+ Close();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
- this.Close();
+ Close();
}
private void RuleRemoveButton_Click(object sender, RoutedEventArgs e)
@@ -84,4 +84,3 @@ private void RuleRemoveButton_Click(object sender, RoutedEventArgs e)
Refresh();
}
}
-
diff --git a/Source/Hurl.RulesetManager/Windows/MainWindow.xaml b/Source/Hurl.RulesetManager/Windows/MainWindow.xaml
index bfb44645..92dd9400 100644
--- a/Source/Hurl.RulesetManager/Windows/MainWindow.xaml
+++ b/Source/Hurl.RulesetManager/Windows/MainWindow.xaml
@@ -1,11 +1,11 @@
-
-
+
-
Create
-
+
-
Test
-
+
@@ -63,4 +63,4 @@
-
+
diff --git a/Source/Hurl.RulesetManager/Windows/RuleTestingWindow.xaml b/Source/Hurl.RulesetManager/Windows/RuleTestingWindow.xaml
index 98f56c5f..f0328df6 100644
--- a/Source/Hurl.RulesetManager/Windows/RuleTestingWindow.xaml
+++ b/Source/Hurl.RulesetManager/Windows/RuleTestingWindow.xaml
@@ -1,11 +1,11 @@
-
-
-
+
Enter a URI to test
@@ -44,7 +44,7 @@
x:Name="_UriInput"
Margin="0,12,0,0"
HorizontalAlignment="Stretch" />
-
Test against Existing Rules
-
+
-
+
-
+
Test the above URI with a custom rule
@@ -94,28 +94,28 @@
AcceptsReturn="True" />
-
-
Test with Rule
-
+
-
+
-
+
-
+
-
+