From 821a471f29ff46b5600b78f8f01a0f35bb6b7ef2 Mon Sep 17 00:00:00 2001 From: BornToBeRoot <16019165+BornToBeRoot@users.noreply.github.com> Date: Tue, 14 Mar 2023 22:54:14 +0100 Subject: [PATCH] Feature: IP Scanner button in network interface, fix bug in redirect (#2046) * Feature: IP Scanner button for selected interface * Fix: Show error message if application was not found on redirect * Docs: Add #2046 --- ...ssSubnetmaskTupleArrayToStringConverter.cs | 4 +- .../Resources/Strings.Designer.cs | 9 +++ .../Resources/Strings.resx | 3 + .../EventSystem/EventSystem.cs | 2 +- Source/NETworkManager/MainWindow.xaml.cs | 17 +++++- .../Resources/Styles/RectangleStyles.xaml | 7 +++ .../Resources/Styles/TextBlockStyles.xaml | 9 ++- .../Resources/Styles/TextBoxStyles.xaml | 2 +- .../ViewModels/NetworkInterfaceViewModel.cs | 16 ++++- .../Views/NetworkInterfaceView.xaml | 61 ++++++++++++++----- docs/Changelog/next-release.md | 3 + 11 files changed, 109 insertions(+), 24 deletions(-) diff --git a/Source/NETworkManager.Converters/IPAddressSubnetmaskTupleArrayToStringConverter.cs b/Source/NETworkManager.Converters/IPAddressSubnetmaskTupleArrayToStringConverter.cs index bef60b6ef9..2cd9f3cf16 100644 --- a/Source/NETworkManager.Converters/IPAddressSubnetmaskTupleArrayToStringConverter.cs +++ b/Source/NETworkManager.Converters/IPAddressSubnetmaskTupleArrayToStringConverter.cs @@ -11,11 +11,11 @@ namespace NETworkManager.Converters; public sealed class IPAddressSubnetmaskTupleArrayToStringConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { + { if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) return "-/-"; - if (!(value is Tuple[] ipAddresses)) + if (value is not Tuple[] ipAddresses) return "-/-"; var result = string.Empty; diff --git a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs index f7757c09f6..880fab8af2 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.Designer.cs +++ b/Source/NETworkManager.Localization/Resources/Strings.Designer.cs @@ -1860,6 +1860,15 @@ public class Strings { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Could not find the application "{0}". Maybe the application was hidden in the settings? ähnelt. + /// + public static string CouldNotFindApplicationXXXMessage { + get { + return ResourceManager.GetString("CouldNotFindApplicationXXXMessage", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Could not get public ip address via WebRequest (http/https) from "{0}"! Check your network connection (firewall, proxy, etc.). ähnelt. /// diff --git a/Source/NETworkManager.Localization/Resources/Strings.resx b/Source/NETworkManager.Localization/Resources/Strings.resx index 37fb54b538..3d5b5d0cc2 100644 --- a/Source/NETworkManager.Localization/Resources/Strings.resx +++ b/Source/NETworkManager.Localization/Resources/Strings.resx @@ -3316,4 +3316,7 @@ Changes to this value will take effect after the application is restarted. Wheth Scan ports + + Could not find the application "{0}". Maybe the application was hidden in the settings? + \ No newline at end of file diff --git a/Source/NETworkManager.Models/EventSystem/EventSystem.cs b/Source/NETworkManager.Models/EventSystem/EventSystem.cs index a10c55c137..6518d009df 100644 --- a/Source/NETworkManager.Models/EventSystem/EventSystem.cs +++ b/Source/NETworkManager.Models/EventSystem/EventSystem.cs @@ -4,7 +4,7 @@ namespace NETworkManager.Models.EventSystem; public class EventSystem { - // This will notify the mail window, to change the view to another application and redirect some data (hostname, ip) + // This will notify the main window, to change the view to another application and redirect some data (hostname, ip) public static event EventHandler OnRedirectDataToApplicationEvent; public static void RedirectToApplication(ApplicationName application, string data) diff --git a/Source/NETworkManager/MainWindow.xaml.cs b/Source/NETworkManager/MainWindow.xaml.cs index f60852980b..00289824a8 100644 --- a/Source/NETworkManager/MainWindow.xaml.cs +++ b/Source/NETworkManager/MainWindow.xaml.cs @@ -936,13 +936,26 @@ private void ClearSearchOnApplicationListMinimize() ListViewApplication.ScrollIntoView(SelectedApplication); } - private void EventSystem_RedirectDataToApplicationEvent(object sender, EventArgs e) + private async void EventSystem_RedirectDataToApplicationEvent(object sender, EventArgs e) { if (e is not EventSystemRedirectArgs data) return; // Change view - SelectedApplication = Applications.SourceCollection.Cast().FirstOrDefault(x => x.Name == data.Application); + var application = Applications.Cast().FirstOrDefault(x => x.Name == data.Application); + + if (application == null) + { + var settings = AppearanceManager.MetroDialog; + settings.AffirmativeButtonText = Localization.Resources.Strings.OK; + + await this.ShowMessageAsync(Localization.Resources.Strings.Error, string.Format(Localization.Resources.Strings.CouldNotFindApplicationXXXMessage, data.Application.ToString())); + + return; + } + + // Change view + SelectedApplication = application; // Crate a new tab / perform action switch (data.Application) diff --git a/Source/NETworkManager/Resources/Styles/RectangleStyles.xaml b/Source/NETworkManager/Resources/Styles/RectangleStyles.xaml index b4c53eadb3..bccdd49df2 100644 --- a/Source/NETworkManager/Resources/Styles/RectangleStyles.xaml +++ b/Source/NETworkManager/Resources/Styles/RectangleStyles.xaml @@ -1,6 +1,13 @@  + + + + diff --git a/Source/NETworkManager/Resources/Styles/TextBoxStyles.xaml b/Source/NETworkManager/Resources/Styles/TextBoxStyles.xaml index 3a71eff69e..fc54780b7d 100644 --- a/Source/NETworkManager/Resources/Styles/TextBoxStyles.xaml +++ b/Source/NETworkManager/Resources/Styles/TextBoxStyles.xaml @@ -11,7 +11,7 @@ - + + + + + + + + + + + + + + @@ -260,12 +289,12 @@ - + - + @@ -276,12 +305,12 @@ - + - + @@ -603,6 +632,7 @@ + @@ -612,8 +642,8 @@ - - + + @@ -623,8 +653,8 @@ - - + + @@ -650,7 +680,7 @@ - + @@ -677,6 +707,7 @@ + @@ -684,8 +715,8 @@ - - + + @@ -694,8 +725,8 @@ - - + + diff --git a/docs/Changelog/next-release.md b/docs/Changelog/next-release.md index 64b5f13725..0eabf063fd 100644 --- a/docs/Changelog/next-release.md +++ b/docs/Changelog/next-release.md @@ -26,6 +26,8 @@ Release date: **xx.xx.2023** - Reselect profile or select first profile after (re)loading or search [#2014](https://github.com/BornToBeRoot/NETworkManager/pull/2014){:target="\_blank"} - Some designs have been improved (Error & Warning icons). [#2014](https://github.com/BornToBeRoot/NETworkManager/pull/2014){:target="\_blank"} - You can now configure the application wide [ThreadPool](https://learn.microsoft.com/en-us/dotnet/standard/threading/the-managed-thread-pool) under `Settings > General > Multithreading`, which is used for the IP scanner and the port scanner. The default value for min. threads are CPU threads + 512. Depending on the hardware, this can improve the performance of the scan. [#2026](https://github.com/BornToBeRoot/NETworkManager/pull/2026){:target="\_blank"} +- **Network Interface** + - Add a button to redirect the the IPv4 address and subnetmask of the selected network interface to the IP scanner [#2046](https://github.com/BornToBeRoot/NETworkManager/pull/2046){:target="\_blank"} - **IP Scanner** - Option added to limit the number of concurrent threads per host scan (256) & port scan (5). Increasing the values can speed up the scan, but can also lead to resource problems. [#2026](https://github.com/BornToBeRoot/NETworkManager/pull/2026){:target="\_blank"} - **Port Scanner** @@ -33,6 +35,7 @@ Release date: **xx.xx.2023** ## Bugfixes +- Show error message when redirecting to another application, but the application is hidden in the settings or somehow invalid [#2046](https://github.com/BornToBeRoot/NETworkManager/pull/2046){:target="\_blank"} - Group name check is now case insensitive and a group name can only be used once. If you create a group named `Test`, you cannot create a group named `test`. [#2014](https://github.com/BornToBeRoot/NETworkManager/pull/2014){:target="\_blank"} - Profile dialog - Validate AWS Session Manager input (instance ID, profile, region) [#2025](https://github.com/BornToBeRoot/NETworkManager/pull/2025){:target="\_blank"}