Skip to content

Feature: Improve bandwidth meter & fix bugs#3457

Merged
mergify[bot] merged 9 commits into
mainfrom
feature/improve-bandwidth-meter
May 30, 2026
Merged

Feature: Improve bandwidth meter & fix bugs#3457
mergify[bot] merged 9 commits into
mainfrom
feature/improve-bandwidth-meter

Conversation

@BornToBeRoot
Copy link
Copy Markdown
Owner

Changes proposed in this pull request

  • Migrate to livecharts2
  • multiple bug fixes & improvements for bandwidth meter

Related issue(s)

Copilot generated summary

Provide a Copilot generated summary of the changes in this pull request.

Copilot summary

This pull request introduces several improvements and refactorings related to bandwidth measurement, charting, and tooltips in the Network Interface section. The changes modernize the bandwidth meter logic, unify and enhance chart tooltips using LiveCharts v2, and clean up obsolete converters and code.

Bandwidth measurement and charting improvements:

  • Refactored BandwidthMeter to use precise timing with a Stopwatch, robust error handling for interface state changes, and per-second rate calculation based on elapsed time. Added a constant for the default sample interval and improved handling of interface removal and counter resets. [1] [2] [3] [4]
  • Added a new setting NetworkInterface_BandwidthChartTime to control the bandwidth chart time window, with corresponding static configuration and property in SettingsInfo. [1] [2]

Chart tooltip modernization:

  • Replaced the old LvlChartsBandwidthTooltip (and related converter) with a new LiveChartsBandwidthTooltip control and code-behind, supporting LiveCharts v2, improved appearance, and more flexible data binding. [1] [2] [3] [4] [5] [6]

Converters and formatting:

  • Enhanced BandwidthBytesToSpeedConverter to allow formatting as either bytes per second or bits per second, with improved parameter handling and documentation.
  • Added a new BytesToExactStringConverter for displaying exact byte counts with thousands separators and unit, intended for tooltips.

Settings and documentation integration:

  • Added NetworkInterface to SettingsName and integrated it into the settings view manager and documentation identifier mapping, ensuring proper settings and documentation support for the Network Interface module. [1] [2] [3]

Summary of most important changes:

1. Bandwidth measurement and charting

  • Refactored BandwidthMeter for accurate per-second rate calculation using a Stopwatch, robust interface state handling, and improved sample interval management. [1] [2] [3] [4]
  • Added a setting for bandwidth chart time window (NetworkInterface_BandwidthChartTime) and integrated it into the configuration and settings model. [1] [2]

2. Chart tooltip modernization

  • Replaced the old LiveCharts v1 tooltip (LvlChartsBandwidthTooltip) and its converter with a new LiveChartsBandwidthTooltip control for LiveCharts v2, providing better formatting, appearance, and data binding. [1] [2] [3] [4] [5] [6]

3. Converters and formatting

  • Improved BandwidthBytesToSpeedConverter to allow both byte/s and bit/s formatting, with clearer documentation and parameter handling.
  • Added BytesToExactStringConverter for displaying exact byte counts in tooltips.

4. Settings and documentation integration

  • Added NetworkInterface to SettingsName, integrated it into the settings view manager, and mapped it in documentation identifier logic for proper settings and help support. [1] [2] [3]

To-Do

Contributing

By submitting this pull request, I confirm the following:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the Network Interface bandwidth meter by migrating its charting to LiveCharts2, improving sampling accuracy, and adding a configurable chart time window with settings/documentation support.

Changes:

  • Replaced the bandwidth chart and tooltip with LiveCharts2 equivalents, including live/pan/zoom behavior.
  • Refactored bandwidth sampling to use elapsed time and handle interface/statistics failures more robustly.
  • Added Network Interface chart-time settings, converters, and documentation updates.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Website/docs/application/network-interface.md Documents bandwidth chart behavior and the new chart-time setting.
Source/NETworkManager/Views/NetworkInterfaceView.xaml Migrates bandwidth UI chart to LiveCharts2 and updates speed/byte tooltips.
Source/NETworkManager/Views/NetworkInterfaceSettingsView.xaml Adds Network Interface settings UI.
Source/NETworkManager/Views/NetworkInterfaceSettingsView.xaml.cs Wires the settings view to its view model.
Source/NETworkManager/ViewModels/SettingsViewModel.cs Registers the Network Interface settings page.
Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs Adds LiveCharts2 chart state, live mode, history, and settings reactions.
Source/NETworkManager/ViewModels/NetworkInterfaceSettingsViewModel.cs Adds chart-time setting binding.
Source/NETworkManager/Controls/LvlChartsBandwidthTooltip.xaml Removes old LiveCharts v1 tooltip UI.
Source/NETworkManager/Controls/LvlChartsBandwidthTooltip.xaml.cs Removes old LiveCharts v1 tooltip code.
Source/NETworkManager/Controls/LiveChartsBandwidthTooltip.xaml Adds LiveCharts2 bandwidth tooltip UI.
Source/NETworkManager/Controls/LiveChartsBandwidthTooltip.xaml.cs Adds LiveCharts2 bandwidth tooltip behavior.
Source/NETworkManager.Settings/SettingsViewManager.cs Adds Network Interface to application settings list.
Source/NETworkManager.Settings/SettingsName.cs Adds Network Interface settings enum value.
Source/NETworkManager.Settings/SettingsInfo.cs Adds persisted bandwidth chart-time setting.
Source/NETworkManager.Settings/GlobalStaticConfiguration.cs Adds default bandwidth chart-time value.
Source/NETworkManager.Models/Network/BandwidthMeter.cs Improves bandwidth sampling timing and error handling.
Source/NETworkManager.Documentation/DocumentationManager.cs Maps Network Interface settings to documentation.
Source/NETworkManager.Converters/LvlChartsBandwidthValueConverter.cs Removes obsolete LiveCharts v1 converter.
Source/NETworkManager.Converters/BytesToExactStringConverter.cs Adds exact byte-count tooltip converter.
Source/NETworkManager.Converters/BandwidthBytesWithSizeConverter.cs Removes replaced byte-size converter.
Source/NETworkManager.Converters/BandwidthBytesToSpeedConverter.cs Updates speed formatting to support bit/s and byte/s modes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +755 to +757
_bandwidthReceivedValues = [];
_bandwidthSentValues = [];
_bandwidthSessionStartTime = DateTime.Now;
@BornToBeRoot BornToBeRoot changed the title Feature/improve bandwidth meter Feature: Improve bandwidth meter & fix bugs May 30, 2026
@BornToBeRoot BornToBeRoot requested a review from Copilot May 30, 2026 14:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 23 changed files in this pull request and generated 3 comments.

- Migrated from `LiveCharts` to `LiveCharts2` (`LiveChartsCore.SkiaSharpView.WPF`) for chart rendering. [#3449](https://github.com/BornToBeRoot/NETworkManager/pull/3449)
- Fixed `CancellationTokenSource` leak in `IPScanner`, `PortScanner`, `Traceroute`, `PingMonitor`, `PingMonitorHost` and `SNMP` ViewModels. The previous instance was never disposed before being overwritten on each run, leaking the underlying `WaitHandle`. [#3448](https://github.com/BornToBeRoot/NETworkManager/pull/3448)
- Fixed a `Dispatcher.ShutdownStarted` handler leak in the Dragablz tab items (PowerShell, PuTTY, TigerVNC, Remote Desktop and Web Console controls, plus the IP Scanner, Port Scanner, Traceroute, DNS Lookup, IP Geolocation, SNMP, SNTP Lookup and Whois views). The handler was subscribed in the constructor but never removed, keeping each closed tab (view and view model) alive until the application exited. It is now unsubscribed in `CloseTab()`; the Web Console additionally disposes its WebView2 instance. [#3454](https://github.com/BornToBeRoot/NETworkManager/pull/3454)
- Migrated from `LiveCharts` to `LiveCharts2` (`LiveChartsCore.SkiaSharpView.WPF`) for chart rendering. [#3449](https://github.com/BornToBeRoot/NETworkManager/pull/3449) [#3457](https://github.com/BornToBeRoot/NETworkManager/pull/3457)
Comment thread Source/NETworkManager/ViewModels/NetworkInterfaceSettingsViewModel.cs Outdated
Comment on lines +1942 to 1944
// Amount transferred since the measurement started (this session)
BandwidthDiffBytesReceived = BandwidthTotalBytesReceived - _bandwidthTotalBytesReceivedTemp;
BandwidthDiffBytesSent = BandwidthTotalBytesSent - _bandwidthTotalBytesSentTemp;
@mergify mergify Bot merged commit 8cf1955 into main May 30, 2026
5 checks passed
@mergify mergify Bot deleted the feature/improve-bandwidth-meter branch May 30, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants