Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ The website is deployed to GitHub Pages at: https://borntoberoot.net/NETworkMana
- **`Source/NETworkManager.sln`**: Main Visual Studio solution
- **`Source/GlobalAssemblyInfo.cs`**: Shared assembly version info
- **`Source/global.json`**: .NET SDK version specification (also used by AppVeyor)
- **`Source/Directory.Build.props`**: Properties for all projects (CS0108 / CS0114 - a member hiding an inherited one - are
errors: WPF binds by name, a hiding property of a view model silently replaces e.g. `ProfileSearch` of
`ProfileHostViewModelBase`)
- **`Source/.editorconfig`**: C# code style configuration
- **`appveyor.yml`**: AppVeyor CI/CD configuration
- **`.github/workflows/codeql.yml`**: CodeQL security analysis workflow
Expand Down
10 changes: 10 additions & 0 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<!-- Applies to all projects in Source/ -->
<PropertyGroup>
<!-- A member that hides an inherited member without "new" / "override" is an error: e.g. a property of a view
model with the same name as one of ProfileHostViewModelBase hides it, and WPF binds the view to the hiding
property by name without any error at runtime (the profile search was bound to the search of the Ping
Monitor hosts) -->
<WarningsAsErrors>$(WarningsAsErrors);CS0108;CS0114</WarningsAsErrors>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;
using NETworkManager.Models.Network;

namespace NETworkManager.Converters;

/// <summary>
/// Formats the count of hosts up (reachable), down (unreachable) or paused (not running) within
/// a Ping Monitor group, selected via <c>ConverterParameter</c> ("Up", "Down", "Paused" - formats the
/// Formats the count of all hosts, the hosts up (reachable), down (unreachable) or paused (not running) within
/// a Ping Monitor group, selected via <c>ConverterParameter</c> ("Hosts", "Up", "Down", "Paused" - formats the
/// count with the format string bound as the third value, e.g. <c>Strings.XUp</c> = "{0} Up", so the
/// word order can be translated - or "PausedVisibility", which instead returns a
/// <see cref="Visibility"/> so the paused count can be hidden while zero).
/// word order can be translated). Pending hosts (status not established yet) are only counted in "Hosts".
/// </summary>
/// <remarks>
/// Bound as a <see cref="MultiBinding"/> with the <see cref="CollectionViewGroup"/> as the first
/// value and a per-group change-notification trigger as the second. The second value isn't used
/// value, a per-group change-notification trigger as the second, the format as the third and optionally all hosts
/// as the fourth (the summary counts all hosts of the group, also the ones hidden by the search / status filter). The second value isn't used
/// directly, it only forces re-evaluation whenever a host's <see cref="IPingMonitorHostStatus"/>
/// changes, since <see cref="CollectionViewGroup"/> itself only raises change notifications for
/// item add/remove, not for property changes on its items.
Expand All @@ -26,16 +26,27 @@ public sealed class PingMonitorGroupSummaryConverter : IMultiValueConverter
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length == 0 || values[0] is not CollectionViewGroup group)
return parameter as string == "PausedVisibility" ? Visibility.Collapsed : string.Empty;
return string.Empty;

var total = 0;
var up = 0;
var down = 0;
var paused = 0;

foreach (var host in group.Items.OfType<IPingMonitorHostStatus>())
// All hosts of the group (fourth value: all hosts), not only the hosts shown by the filter
var groupName = group.Name?.ToString();
var hosts = values.Length > 3 && values[3] is IEnumerable allHosts
? allHosts.OfType<IPingMonitorHostStatus>().Where(x => x.Group == groupName)
: group.Items.OfType<IPingMonitorHostStatus>();

foreach (var host in hosts)
{
total++;

if (!host.IsRunning)
paused++;
else if (host.IsPending)
continue; // Neither up nor down until its status is established
else if (host.IsReachable)
up++;
else
Expand All @@ -46,10 +57,10 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur

return parameter as string switch
{
"Hosts" => string.Format(culture, format, total),
"Up" => string.Format(culture, format, up),
"Down" => string.Format(culture, format, down),
"Paused" => string.Format(culture, format, paused),
"PausedVisibility" => paused > 0 ? Visibility.Visible : Visibility.Collapsed,
_ => string.Empty
};
}
Expand Down
107 changes: 105 additions & 2 deletions Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 40 additions & 3 deletions Source/NETworkManager.Localization/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2518,13 +2518,13 @@ is disabled!</value>
<value>Success threshold</value>
</data>
<data name="HelpMessage_NotificationSuccessThreshold" xml:space="preserve">
<value>Number of consecutive successful pings required before a "Host is up" notification is shown. Higher values reduce noise from flapping hosts.</value>
<value>Number of consecutive successful pings required before a host is shown as up (status icon, group counters) and a "Host is up" notification is shown. Higher values reduce noise from flapping hosts.</value>
</data>
<data name="NotificationFailureThreshold" xml:space="preserve">
<value>Failure threshold</value>
</data>
<data name="HelpMessage_NotificationFailureThreshold" xml:space="preserve">
<value>Number of consecutive failed pings (timeouts) required before a "Host is down" notification is shown. Higher values reduce noise from flapping hosts.</value>
<value>Number of consecutive failed pings (timeouts) required before a host is shown as down (status icon, group counters) and a "Host is down" notification is shown. Higher values reduce noise from flapping hosts.</value>
</data>
<data name="NotificationDurationInSeconds" xml:space="preserve">
<value>Display duration (seconds)</value>
Expand Down Expand Up @@ -5917,4 +5917,41 @@ Own row: above the speed test.</value>

Open Windows Settings &gt; Privacy &amp; security &gt; Location and enable access for Desktop Apps / NETworkManager. The widget shows the connection a few seconds later, a restart is not needed.</value>
</data>
</root>
<data name="PingMonitorManyHostsMessage" xml:space="preserve">
<value>{0} hosts will be added. Each host is pinged continuously and has its own chart, this needs a lot of resources.

Do you want to add the hosts?</value>
</data>
<data name="PingMonitorTooManyHostsMessage" xml:space="preserve">
<value>{0} hosts cannot be monitored at once (maximum {1}). Split the input into smaller ranges.</value>
</data>
<data name="HistoryInHours" xml:space="preserve">
<value>History (hours)</value>
</data>
<data name="HelpMessage_PingMonitorHistoryHours" xml:space="preserve">
<value>Pings older than this are removed from the history of a host (export, chart when returning to live mode). The counters (received, lost, packet loss) include all pings since the host was started.</value>
</data>
<data name="TheFollowingHostsAreAlreadyMonitoredInThisGroup" xml:space="preserve">
<value>The following hosts are already monitored in this group:</value>
</data>
<data name="PauseAll" xml:space="preserve">
<value>Pause all</value>
</data>
<data name="ResumeAll" xml:space="preserve">
<value>Resume all</value>
</data>
<data name="XHosts" xml:space="preserve">
<value>{0} Hosts</value>
</data>
<data name="CloseAllHostsMessage" xml:space="preserve">
<value>{0} hosts will be stopped and removed.

Do you want to close all hosts?</value>
</data>
<data name="MonitoredHosts" xml:space="preserve">
<value>Monitored hosts</value>
</data>
<data name="Actions" xml:space="preserve">
<value>Actions</value>
</data>
</root>
Loading