diff --git a/Source/NETworkManager.Models/Network/IPScanner.cs b/Source/NETworkManager.Models/Network/IPScanner.cs index c1c94bfaf6..7ff2e412a0 100644 --- a/Source/NETworkManager.Models/Network/IPScanner.cs +++ b/Source/NETworkManager.Models/Network/IPScanner.cs @@ -12,6 +12,10 @@ namespace NETworkManager.Models.Network; +/// +/// Class to scan for IP addresses in a network. +/// +/// The scan options. public sealed class IPScanner(IPScannerOptions options) { #region Variables @@ -22,6 +26,9 @@ public sealed class IPScanner(IPScannerOptions options) #region Events + /// + /// Occurs when a host has been scanned. + /// public event EventHandler HostScanned; private void OnHostScanned(IPScannerHostScannedArgs e) @@ -29,6 +36,9 @@ private void OnHostScanned(IPScannerHostScannedArgs e) HostScanned?.Invoke(this, e); } + /// + /// Occurs when the scan is complete. + /// public event EventHandler ScanComplete; private void OnScanComplete() @@ -36,6 +46,9 @@ private void OnScanComplete() ScanComplete?.Invoke(this, EventArgs.Empty); } + /// + /// Occurs when the scan progress has changed. + /// public event EventHandler ProgressChanged; private void OnProgressChanged() @@ -43,6 +56,9 @@ private void OnProgressChanged() ProgressChanged?.Invoke(this, new ProgressChangedArgs(_progressValue)); } + /// + /// Occurs when the user has canceled the scan. + /// public event EventHandler UserHasCanceled; private void OnUserHasCanceled() @@ -54,6 +70,11 @@ private void OnUserHasCanceled() #region Methods + /// + /// Starts the IP scan asynchronously. + /// + /// The list of hosts to scan. + /// The token to monitor for cancellation requests. public void ScanAsync(IEnumerable<(IPAddress ipAddress, string hostname)> hosts, CancellationToken cancellationToken) { diff --git a/Source/NETworkManager.Models/Network/NetworkInterface.cs b/Source/NETworkManager.Models/Network/NetworkInterface.cs index 1cd51bc80c..d56f5b102c 100644 --- a/Source/NETworkManager.Models/Network/NetworkInterface.cs +++ b/Source/NETworkManager.Models/Network/NetworkInterface.cs @@ -11,10 +11,16 @@ namespace NETworkManager.Models.Network; +/// +/// Provides functionality to manage network interfaces. +/// public sealed class NetworkInterface { #region Events + /// + /// Occurs when the user has canceled an operation (e.g. UAC prompt). + /// public event EventHandler UserHasCanceled; private void OnUserHasCanceled() @@ -26,11 +32,19 @@ private void OnUserHasCanceled() #region Methods + /// + /// Gets a list of all available network interfaces asynchronously. + /// + /// A task that represents the asynchronous operation. The task result contains a list of . public static Task> GetNetworkInterfacesAsync() { return Task.Run(GetNetworkInterfaces); } + /// + /// Gets a list of all available network interfaces. + /// + /// A list of describing the available network interfaces. public static List GetNetworkInterfaces() { List listNetworkInterfaceInfo = new(); @@ -156,11 +170,21 @@ public static List GetNetworkInterfaces() return listNetworkInterfaceInfo; } + /// + /// Detects the local IP address based on routing to a remote IP address asynchronously. + /// + /// The remote IP address to check routing against. + /// A task that represents the asynchronous operation. The task result contains the local used to reach the remote address. public static Task DetectLocalIPAddressBasedOnRoutingAsync(IPAddress remoteIPAddress) { return Task.Run(() => DetectLocalIPAddressBasedOnRouting(remoteIPAddress)); } + /// + /// Detects the local IP address based on routing to a remote IP address. + /// + /// The remote IP address to check routing against. + /// The local used to reach the remote address. private static IPAddress DetectLocalIPAddressBasedOnRouting(IPAddress remoteIPAddress) { var isIPv4 = remoteIPAddress.AddressFamily == AddressFamily.InterNetwork; @@ -184,11 +208,21 @@ private static IPAddress DetectLocalIPAddressBasedOnRouting(IPAddress remoteIPAd return null; } + /// + /// Detects the gateway IP address based on a local IP address asynchronously. + /// + /// The local IP address to find the gateway for. + /// A task that represents the asynchronous operation. The task result contains the gateway . public static Task DetectGatewayBasedOnLocalIPAddressAsync(IPAddress localIPAddress) { return Task.Run(() => DetectGatewayBasedOnLocalIPAddress(localIPAddress)); } + /// + /// Detects the gateway IP address based on a local IP address. + /// + /// The local IP address to find the gateway for. + /// The gateway . private static IPAddress DetectGatewayBasedOnLocalIPAddress(IPAddress localIPAddress) { foreach (var networkInterface in GetNetworkInterfaces()) @@ -210,11 +244,20 @@ private static IPAddress DetectGatewayBasedOnLocalIPAddress(IPAddress localIPAdd return null; } + /// + /// Configures a network interface with the specified configuration asynchronously. + /// + /// The configuration to apply. + /// A task that represents the asynchronous operation. public Task ConfigureNetworkInterfaceAsync(NetworkInterfaceConfig config) { return Task.Run(() => ConfigureNetworkInterface(config)); } + /// + /// Configures a network interface with the specified configuration. + /// + /// The configuration to apply. private void ConfigureNetworkInterface(NetworkInterfaceConfig config) { // IP diff --git a/Source/NETworkManager.Models/Network/Ping.cs b/Source/NETworkManager.Models/Network/Ping.cs index ccf645bb0c..fc06a056d2 100644 --- a/Source/NETworkManager.Models/Network/Ping.cs +++ b/Source/NETworkManager.Models/Network/Ping.cs @@ -8,14 +8,36 @@ namespace NETworkManager.Models.Network; +/// +/// Provides functionality to ping a network host. +/// public sealed class Ping { #region Variables + /// + /// The time in milliseconds to wait between ping requests. Default is 1000ms. + /// public int WaitTime = 1000; + + /// + /// The time in milliseconds to wait for a reply. Default is 4000ms. + /// public int Timeout = 4000; + + /// + /// The buffer to send with the ping request. Default is 32 bytes. + /// public byte[] Buffer = new byte[32]; + + /// + /// The Time to Live (TTL) value for the ping request. Default is 64. + /// public int TTL = 64; + + /// + /// Indicates whether to prevent fragmentation of the data packets. Default is true. + /// public bool DontFragment = true; private const int ExceptionCancelCount = 3; @@ -24,6 +46,9 @@ public sealed class Ping #region Events + /// + /// Occurs when a ping reply is received. + /// public event EventHandler PingReceived; private void OnPingReceived(PingReceivedArgs e) @@ -31,6 +56,9 @@ private void OnPingReceived(PingReceivedArgs e) PingReceived?.Invoke(this, e); } + /// + /// Occurs when the ping operation is completed. + /// public event EventHandler PingCompleted; private void OnPingCompleted() @@ -38,6 +66,9 @@ private void OnPingCompleted() PingCompleted?.Invoke(this, EventArgs.Empty); } + /// + /// Occurs when a ping exception is thrown. + /// public event EventHandler PingException; private void OnPingException(PingExceptionArgs e) @@ -45,6 +76,9 @@ private void OnPingException(PingExceptionArgs e) PingException?.Invoke(this, e); } + /// + /// Occurs when the hostname is resolved. + /// public event EventHandler HostnameResolved; private void OnHostnameResolved(HostnameArgs e) @@ -52,6 +86,9 @@ private void OnHostnameResolved(HostnameArgs e) HostnameResolved?.Invoke(this, e); } + /// + /// Occurs when the user has canceled the operation. + /// public event EventHandler UserHasCanceled; private void OnUserHasCanceled() @@ -63,6 +100,11 @@ private void OnUserHasCanceled() #region Methods + /// + /// Sends ping requests to the specified IP address asynchronously. + /// + /// The IP address to ping. + /// The token to monitor for cancellation requests. public void SendAsync(IPAddress ipAddress, CancellationToken cancellationToken) { Task.Run(async () => @@ -153,6 +195,13 @@ public void SendAsync(IPAddress ipAddress, CancellationToken cancellationToken) } // Param: disableSpecialChar --> ExportManager --> "<" this char cannot be displayed in xml + /// + /// Converts the ping time to a string representation. + /// + /// The IP status of the ping reply. + /// The round-trip time in milliseconds. + /// If true, disables special characters like '<' in the output (e.g., for XML export). + /// The formatted time string. public static string TimeToString(IPStatus status, long time, bool disableSpecialChar = false) { if (status != IPStatus.Success && status != IPStatus.TtlExpired) diff --git a/Source/NETworkManager/ViewModels/ARPTableAddEntryViewModel.cs b/Source/NETworkManager/ViewModels/ARPTableAddEntryViewModel.cs index 7193651949..a24b7ea6e0 100644 --- a/Source/NETworkManager/ViewModels/ARPTableAddEntryViewModel.cs +++ b/Source/NETworkManager/ViewModels/ARPTableAddEntryViewModel.cs @@ -4,12 +4,26 @@ namespace NETworkManager.ViewModels; +/// +/// View model for adding an ARP table entry. +/// public class ArpTableAddEntryViewModel : ViewModelBase { + /// + /// Backing field for . + /// private string _ipAddress; + /// + /// Backing field for . + /// private string _macAddress; + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when the add command is invoked. + /// The action to execute when the cancel command is invoked. public ArpTableAddEntryViewModel(Action addCommand, Action cancelHandler) { @@ -17,10 +31,19 @@ public ArpTableAddEntryViewModel(Action addCommand, CancelCommand = new RelayCommand(_ => cancelHandler(this)); } + /// + /// Gets the command to add the entry. + /// public ICommand AddCommand { get; } + /// + /// Gets the command to cancel the operation. + /// public ICommand CancelCommand { get; } + /// + /// Gets or sets the IP address. + /// public string IPAddress { get => _ipAddress; @@ -34,6 +57,9 @@ public string IPAddress } } + /// + /// Gets or sets the MAC address. + /// public string MACAddress { get => _macAddress; diff --git a/Source/NETworkManager/ViewModels/ARPTableViewModel.cs b/Source/NETworkManager/ViewModels/ARPTableViewModel.cs index 2295b589a4..b7de224c1b 100644 --- a/Source/NETworkManager/ViewModels/ARPTableViewModel.cs +++ b/Source/NETworkManager/ViewModels/ARPTableViewModel.cs @@ -22,10 +22,17 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the ARP table view. +/// public class ARPTableViewModel : ViewModelBase { #region Contructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public ARPTableViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -74,13 +81,29 @@ public ARPTableViewModel(IDialogCoordinator instance) private static readonly ILog Log = LogManager.GetLogger(typeof(ARPTableViewModel)); + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + + /// + /// The timer for auto-refresh. + /// private readonly DispatcherTimer _autoRefreshTimer = new(); + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -97,8 +120,14 @@ public string Search } } + /// + /// Backing field for . + /// private ObservableCollection _results = []; + /// + /// Gets or sets the collection of ARP results. + /// public ObservableCollection Results { get => _results; @@ -112,10 +141,19 @@ public ObservableCollection Results } } + /// + /// Gets the collection view for the ARP results. + /// public ICollectionView ResultsView { get; } + /// + /// Backing field for . + /// private ARPInfo _selectedResult; + /// + /// Gets or sets the currently selected ARP result. + /// public ARPInfo SelectedResult { get => _selectedResult; @@ -129,8 +167,14 @@ public ARPInfo SelectedResult } } + /// + /// Backing field for . + /// private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of selected ARP results. + /// public IList SelectedResults { get => _selectedResults; @@ -144,8 +188,14 @@ public IList SelectedResults } } + /// + /// Backing field for . + /// private bool _autoRefreshEnabled; + /// + /// Gets or sets a value indicating whether auto-refresh is enabled. + /// public bool AutoRefreshEnabled { get => _autoRefreshEnabled; @@ -174,10 +224,19 @@ public bool AutoRefreshEnabled } } + /// + /// Gets the collection view for the auto-refresh times. + /// public ICollectionView AutoRefreshTimes { get; } + /// + /// Backing field for . + /// private AutoRefreshTimeInfo _selectedAutoRefreshTime; + /// + /// Gets or sets the selected auto-refresh time. + /// public AutoRefreshTimeInfo SelectedAutoRefreshTime { get => _selectedAutoRefreshTime; @@ -201,8 +260,14 @@ public AutoRefreshTimeInfo SelectedAutoRefreshTime } } + /// + /// Backing field for . + /// private bool _isRefreshing; + /// + /// Gets or sets a value indicating whether the view model is currently refreshing. + /// public bool IsRefreshing { get => _isRefreshing; @@ -216,8 +281,14 @@ public bool IsRefreshing } } + /// + /// Backing field for . + /// private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -231,8 +302,14 @@ public bool IsStatusMessageDisplayed } } + /// + /// Backing field for . + /// private string _statusMessage; + /// + /// Gets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -250,8 +327,16 @@ private set #region ICommands & Actions + /// + /// Gets the command to refresh the ARP table. + /// public ICommand RefreshCommand => new RelayCommand(_ => RefreshAction().ConfigureAwait(false), Refresh_CanExecute); + /// + /// Checks if the refresh command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool Refresh_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -261,6 +346,9 @@ private bool Refresh_CanExecute(object parameter) !AutoRefreshEnabled; } + /// + /// Action to refresh the ARP table. + /// private async Task RefreshAction() { IsStatusMessageDisplayed = false; @@ -268,9 +356,17 @@ private async Task RefreshAction() await Refresh(); } + /// + /// Gets the command to delete the ARP table. + /// public ICommand DeleteTableCommand => new RelayCommand(_ => DeleteTableAction().ConfigureAwait(false), DeleteTable_CanExecute); + /// + /// Checks if the delete table command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool DeleteTable_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -278,6 +374,9 @@ private bool DeleteTable_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Action to delete the ARP table. + /// private async Task DeleteTableAction() { IsStatusMessageDisplayed = false; @@ -299,9 +398,17 @@ private async Task DeleteTableAction() } } + /// + /// Gets the command to delete an ARP entry. + /// public ICommand DeleteEntryCommand => new RelayCommand(_ => DeleteEntryAction().ConfigureAwait(false), DeleteEntry_CanExecute); + /// + /// Checks if the delete entry command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool DeleteEntry_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -309,6 +416,9 @@ private bool DeleteEntry_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Action to delete an ARP entry. + /// private async Task DeleteEntryAction() { IsStatusMessageDisplayed = false; @@ -330,9 +440,17 @@ private async Task DeleteEntryAction() } } + /// + /// Gets the command to add an ARP entry. + /// public ICommand AddEntryCommand => new RelayCommand(_ => AddEntryAction().ConfigureAwait(false), AddEntry_CanExecute); + /// + /// Checks if the add entry command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool AddEntry_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -340,6 +458,9 @@ private bool AddEntry_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Action to add an ARP entry. + /// private async Task AddEntryAction() { IsStatusMessageDisplayed = false; @@ -378,8 +499,14 @@ private async Task AddEntryAction() await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); } + /// + /// Gets the command to export the ARP table. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Action to export the ARP table. + /// private Task ExportAction() { var childWindow = new ExportChildWindow(); @@ -432,6 +559,10 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, #region Methods + /// + /// Refreshes the ARP table. + /// + /// Indicates whether this is the initial refresh. private async Task Refresh(bool init = false) { IsRefreshing = true; @@ -452,6 +583,9 @@ private async Task Refresh(bool init = false) IsRefreshing = false; } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { // Restart timer... @@ -459,6 +593,9 @@ public void OnViewVisible() _autoRefreshTimer.Start(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { // Temporarily stop timer... @@ -470,12 +607,18 @@ public void OnViewHide() #region Events + /// + /// Handles the UserHasCanceled event from the ARP table. + /// private void ArpTable_UserHasCanceled(object sender, EventArgs e) { StatusMessage = Strings.CanceledByUserMessage; IsStatusMessageDisplayed = true; } + /// + /// Handles the Tick event of the auto-refresh timer. + /// private async void AutoRefreshTimer_Tick(object sender, EventArgs e) { // Stop timer... diff --git a/Source/NETworkManager/ViewModels/AboutViewModel.cs b/Source/NETworkManager/ViewModels/AboutViewModel.cs index 5813c1ef3d..2bd8c56f92 100644 --- a/Source/NETworkManager/ViewModels/AboutViewModel.cs +++ b/Source/NETworkManager/ViewModels/AboutViewModel.cs @@ -13,10 +13,16 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the About view. +/// public class AboutViewModel : ViewModelBase { #region Constructor + /// + /// Initializes a new instance of the class. + /// public AboutViewModel() { LibrariesView = CollectionViewSource.GetDefaultView(LibraryManager.List); @@ -34,6 +40,9 @@ public AboutViewModel() #region Methods + /// + /// Checks for updates asynchronously. + /// private async Task CheckForUpdatesAsync() { IsUpdateAvailable = false; @@ -58,13 +67,25 @@ private async Task CheckForUpdatesAsync() #region Variables + /// + /// Gets the application version string. + /// public string Version => $"{Strings.Version} {AssemblyManager.Current.Version}"; + /// + /// Gets the text indicating who developed and maintains the application. + /// public string DevelopedByText => string.Format(Strings.DevelopedAndMaintainedByX + " ", Resources.NETworkManager_GitHub_User); + /// + /// Backing field for . + /// private bool _isUpdateCheckRunning; + /// + /// Gets or sets a value indicating whether the update check is currently running. + /// public bool IsUpdateCheckRunning { get => _isUpdateCheckRunning; @@ -78,8 +99,14 @@ public bool IsUpdateCheckRunning } } + /// + /// Backing field for . + /// private bool _isUpdateAvailable; + /// + /// Gets or sets a value indicating whether an update is available. + /// public bool IsUpdateAvailable { get => _isUpdateAvailable; @@ -93,8 +120,14 @@ public bool IsUpdateAvailable } } + /// + /// Backing field for . + /// private string _updateText; + /// + /// Gets the text describing the available update. + /// public string UpdateText { get => _updateText; @@ -108,8 +141,14 @@ private set } } + /// + /// Backing field for . + /// private string _updateReleaseUrl; + /// + /// Gets the URL for the release notes or download page. + /// public string UpdateReleaseUrl { get => _updateReleaseUrl; @@ -123,8 +162,14 @@ private set } } + /// + /// Backing field for . + /// private bool _showUpdaterMessage; + /// + /// Gets or sets a value indicating whether to show a message from the updater. + /// public bool ShowUpdaterMessage { get => _showUpdaterMessage; @@ -138,8 +183,14 @@ public bool ShowUpdaterMessage } } + /// + /// Backing field for . + /// private string _updaterMessage; + /// + /// Gets the message from the updater (e.g., no update available, error). + /// public string UpdaterMessage { get => _updaterMessage; @@ -153,10 +204,19 @@ private set } } + /// + /// Gets the collection view for the list of used libraries. + /// public ICollectionView LibrariesView { get; } + /// + /// Backing field for . + /// private LibraryInfo _selectedLibraryInfo; + /// + /// Gets or sets the currently selected library information. + /// public LibraryInfo SelectedLibraryInfo { get => _selectedLibraryInfo; @@ -170,10 +230,19 @@ public LibraryInfo SelectedLibraryInfo } } + /// + /// Gets the collection view for the list of used external services. + /// public ICollectionView ExternalServicesView { get; } + /// + /// Backing field for . + /// private ExternalServicesInfo _selectedExternalServicesInfo; + /// + /// Gets or sets the currently selected external service information. + /// public ExternalServicesInfo SelectedExternalServicesInfo { get => _selectedExternalServicesInfo; @@ -187,10 +256,19 @@ public ExternalServicesInfo SelectedExternalServicesInfo } } + /// + /// Gets the collection view for the list of used resources. + /// public ICollectionView ResourcesView { get; } + /// + /// Backing field for . + /// private ResourceInfo _selectedResourceInfo; + /// + /// Gets or sets the currently selected resource information. + /// public ResourceInfo SelectedResourceInfo { get => _selectedResourceInfo; @@ -208,32 +286,57 @@ public ResourceInfo SelectedResourceInfo #region Commands & Actions + /// + /// Gets the command to check for updates. + /// public ICommand CheckForUpdatesCommand => new RelayCommand(_ => CheckForUpdatesAction()); + /// + /// Action to check for updates. + /// private void CheckForUpdatesAction() { CheckForUpdatesAsync(); } + /// + /// Gets the command to open the website. + /// public ICommand OpenWebsiteCommand => new RelayCommand(OpenWebsiteAction); + /// + /// Action to open the website. + /// + /// The URL to open. private static void OpenWebsiteAction(object url) { ExternalProcessStarter.OpenUrl((string)url); } + /// + /// Gets the command to open the documentation. + /// public ICommand OpenDocumentationCommand { get { return new RelayCommand(_ => OpenDocumentationAction()); } } + /// + /// Action to open the documentation. + /// private void OpenDocumentationAction() { DocumentationManager.OpenDocumentation(DocumentationIdentifier.Default); } + /// + /// Gets the command to open the license folder. + /// public ICommand OpenLicenseFolderCommand => new RelayCommand(_ => OpenLicenseFolderAction()); + /// + /// Action to open the license folder. + /// private void OpenLicenseFolderAction() { Process.Start("explorer.exe", LibraryManager.GetLicenseLocation()); @@ -243,6 +346,9 @@ private void OpenLicenseFolderAction() #region Events + /// + /// Handles the UpdateAvailable event from the Updater. + /// private void Updater_UpdateAvailable(object sender, UpdateAvailableArgs e) { UpdateText = string.Format(Strings.VersionxxIsAvailable, e.Release.TagName); @@ -252,6 +358,9 @@ private void Updater_UpdateAvailable(object sender, UpdateAvailableArgs e) IsUpdateAvailable = true; } + /// + /// Handles the NoUpdateAvailable event from the Updater. + /// private void Updater_NoUpdateAvailable(object sender, EventArgs e) { UpdaterMessage = Strings.NoUpdateAvailable; @@ -260,6 +369,9 @@ private void Updater_NoUpdateAvailable(object sender, EventArgs e) ShowUpdaterMessage = true; } + /// + /// Handles the Error event from the Updater. + /// private void Updater_Error(object sender, EventArgs e) { UpdaterMessage = Strings.ErrorCheckingApiGithubComVerifyYourNetworkConnection; diff --git a/Source/NETworkManager/ViewModels/BitCalculatorSettingsViewModel.cs b/Source/NETworkManager/ViewModels/BitCalculatorSettingsViewModel.cs index 95b4d0c631..99e89b2bb1 100644 --- a/Source/NETworkManager/ViewModels/BitCalculatorSettingsViewModel.cs +++ b/Source/NETworkManager/ViewModels/BitCalculatorSettingsViewModel.cs @@ -6,16 +6,31 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the bit calculator settings. +/// public class BitCalculatorSettingsViewModel : ViewModelBase { #region Variables + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + /// + /// Gets the list of available notations. + /// public List Notations { get; private set; } + /// + /// Backing field for . + /// private BitCaluclatorNotation _notation; + /// + /// Gets or sets the selected notation. + /// public BitCaluclatorNotation Notation { get => _notation; @@ -38,6 +53,9 @@ public BitCaluclatorNotation Notation #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public BitCalculatorSettingsViewModel() { _isLoading = true; @@ -47,6 +65,9 @@ public BitCalculatorSettingsViewModel() _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { Notations = Enum.GetValues(typeof(BitCaluclatorNotation)).Cast() diff --git a/Source/NETworkManager/ViewModels/BitCalculatorViewModel.cs b/Source/NETworkManager/ViewModels/BitCalculatorViewModel.cs index 2f400f31f6..b4e2c816a5 100644 --- a/Source/NETworkManager/ViewModels/BitCalculatorViewModel.cs +++ b/Source/NETworkManager/ViewModels/BitCalculatorViewModel.cs @@ -19,17 +19,33 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the bit calculator view. +/// public class BitCalculatorViewModel : ViewModelBase { #region Variables + + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; private static readonly ILog Log = LogManager.GetLogger(typeof(BitCalculatorViewModel)); + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + /// + /// Backing field for . + /// private string _input; + /// + /// Gets or sets the input value. + /// public string Input { get => _input; @@ -43,10 +59,19 @@ public string Input } } + /// + /// Gets the collection view for the input history. + /// public ICollectionView InputHistoryView { get; } + /// + /// Backing field for . + /// private readonly List _units = new(); + /// + /// Gets the list of available units. + /// public List Units { get => _units; @@ -60,8 +85,14 @@ private init } } + /// + /// Backing field for . + /// private BitCaluclatorUnit _unit; + /// + /// Gets or sets the selected unit. + /// public BitCaluclatorUnit Unit { get => _unit; @@ -78,8 +109,14 @@ public BitCaluclatorUnit Unit } } + /// + /// Backing field for . + /// private bool _isRunning; + /// + /// Gets or sets a value indicating whether the calculation is running. + /// public bool IsRunning { get => _isRunning; @@ -93,8 +130,14 @@ public bool IsRunning } } + /// + /// Backing field for . + /// private bool _isResultVisible; + /// + /// Gets or sets a value indicating whether the result is visible. + /// public bool IsResultVisible { get => _isResultVisible; @@ -109,8 +152,14 @@ public bool IsResultVisible } } + /// + /// Backing field for . + /// private BitCaluclatorInfo _result = new(); + /// + /// Gets the calculation result. + /// public BitCaluclatorInfo Result { get => _result; @@ -128,6 +177,10 @@ private set #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public BitCalculatorViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -143,6 +196,9 @@ public BitCalculatorViewModel(IDialogCoordinator instance) _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { } @@ -151,8 +207,16 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to calculate the result. + /// public ICommand CalculateCommand => new RelayCommand(_ => CalculateAction(), Calculate_CanExecute); + /// + /// Checks if the calculate command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool Calculate_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -160,13 +224,22 @@ private bool Calculate_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Action to calculate the result. + /// private void CalculateAction() { Calculate(); } + /// + /// Gets the command to export the result. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Action to export the result. + /// private Task ExportAction() { var childWindow = new ExportChildWindow(); @@ -217,6 +290,9 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, #region Methods + /// + /// Calculates the result based on the input. + /// private async void Calculate() { IsResultVisible = false; @@ -234,6 +310,10 @@ private async void Calculate() IsRunning = false; } + /// + /// Adds the input to the history. + /// + /// The input string. private void AddInputToHistory(string input) { // Create the new list @@ -248,10 +328,16 @@ private void AddInputToHistory(string input) list.ForEach(x => SettingsManager.Current.BitCalculator_InputHistory.Add(x)); } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { } diff --git a/Source/NETworkManager/ViewModels/CommandLineViewModel.cs b/Source/NETworkManager/ViewModels/CommandLineViewModel.cs index f2c8e4cee2..08ba26c985 100644 --- a/Source/NETworkManager/ViewModels/CommandLineViewModel.cs +++ b/Source/NETworkManager/ViewModels/CommandLineViewModel.cs @@ -8,10 +8,16 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the command line view. +/// public class CommandLineViewModel : ViewModelBase { #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public CommandLineViewModel() { if (!string.IsNullOrEmpty(CommandLineManager.Current.WrongParameter)) @@ -32,8 +38,14 @@ public CommandLineViewModel() #region Variables + /// + /// Backing field for . + /// private bool _displayWrongParameter; + /// + /// Gets or sets a value indicating whether to display the wrong parameter message. + /// public bool DisplayWrongParameter { get => _displayWrongParameter; @@ -47,8 +59,14 @@ public bool DisplayWrongParameter } } + /// + /// Backing field for . + /// private string _wrongParameter; + /// + /// Gets or sets the wrong parameter. + /// public string WrongParameter { get => _wrongParameter; @@ -62,8 +80,14 @@ public string WrongParameter } } + /// + /// Backing field for . + /// private string _parameterHelp; + /// + /// Gets or sets the help parameter. + /// public string ParameterHelp { get => _parameterHelp; @@ -77,8 +101,14 @@ public string ParameterHelp } } + /// + /// Backing field for . + /// private string _parameterResetSettings; + /// + /// Gets or sets the reset settings parameter. + /// public string ParameterResetSettings { get => _parameterResetSettings; @@ -92,8 +122,14 @@ public string ParameterResetSettings } } + /// + /// Backing field for . + /// private string _parameterApplication; + /// + /// Gets or sets the application parameter. + /// public string ParameterApplication { get => _parameterApplication; @@ -107,8 +143,14 @@ public string ParameterApplication } } + /// + /// Backing field for . + /// private string _parameterApplicationValues; + /// + /// Gets or sets the available application parameter values. + /// public string ParameterApplicationValues { get => _parameterApplicationValues; @@ -126,11 +168,17 @@ public string ParameterApplicationValues #region ICommand & Actions + /// + /// Gets the command to open the documentation. + /// public ICommand OpenDocumentationCommand { get { return new RelayCommand(_ => OpenDocumentationAction()); } } + /// + /// Action to open the documentation. + /// private void OpenDocumentationAction() { DocumentationManager.OpenDocumentation(DocumentationIdentifier.CommandLineArguments); diff --git a/Source/NETworkManager/ViewModels/ConnectionsViewModel.cs b/Source/NETworkManager/ViewModels/ConnectionsViewModel.cs index 4747e69360..7298212d95 100644 --- a/Source/NETworkManager/ViewModels/ConnectionsViewModel.cs +++ b/Source/NETworkManager/ViewModels/ConnectionsViewModel.cs @@ -23,10 +23,17 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the connections view. +/// public class ConnectionsViewModel : ViewModelBase { #region Contructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public ConnectionsViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -80,6 +87,9 @@ public ConnectionsViewModel(IDialogCoordinator instance) #region Events + /// + /// Handles the Tick event of the auto-refresh timer. + /// private async void AutoRefreshTimer_Tick(object sender, EventArgs e) { // Stop timer... @@ -98,13 +108,29 @@ private async void AutoRefreshTimer_Tick(object sender, EventArgs e) private static readonly ILog Log = LogManager.GetLogger(typeof(ConnectionsViewModel)); + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + + /// + /// The timer for auto-refresh. + /// private readonly DispatcherTimer _autoRefreshTimer = new(); + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -121,8 +147,14 @@ public string Search } } + /// + /// Backing field for . + /// private ObservableCollection _results = new(); + /// + /// Gets or sets the collection of connection results. + /// public ObservableCollection Results { get => _results; @@ -136,10 +168,19 @@ public ObservableCollection Results } } + /// + /// Gets the collection view for the connection results. + /// public ICollectionView ResultsView { get; } + /// + /// Backing field for . + /// private ConnectionInfo _selectedResult; + /// + /// Gets or sets the currently selected connection result. + /// public ConnectionInfo SelectedResult { get => _selectedResult; @@ -153,8 +194,14 @@ public ConnectionInfo SelectedResult } } + /// + /// Backing field for . + /// private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of selected connection results. + /// public IList SelectedResults { get => _selectedResults; @@ -168,8 +215,14 @@ public IList SelectedResults } } + /// + /// Backing field for . + /// private bool _autoRefreshEnabled; + /// + /// Gets or sets a value indicating whether auto-refresh is enabled. + /// public bool AutoRefreshEnabled { get => _autoRefreshEnabled; @@ -198,10 +251,19 @@ public bool AutoRefreshEnabled } } + /// + /// Gets the collection view for the auto-refresh times. + /// public ICollectionView AutoRefreshTimes { get; } + /// + /// Backing field for . + /// private AutoRefreshTimeInfo _selectedAutoRefreshTime; + /// + /// Gets or sets the selected auto-refresh time. + /// public AutoRefreshTimeInfo SelectedAutoRefreshTime { get => _selectedAutoRefreshTime; @@ -225,8 +287,14 @@ public AutoRefreshTimeInfo SelectedAutoRefreshTime } } + /// + /// Backing field for . + /// private bool _isRefreshing; + /// + /// Gets or sets a value indicating whether the view model is currently refreshing. + /// public bool IsRefreshing { get => _isRefreshing; @@ -240,8 +308,14 @@ public bool IsRefreshing } } + /// + /// Backing field for . + /// private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -255,8 +329,14 @@ public bool IsStatusMessageDisplayed } } + /// + /// Backing field for . + /// private string _statusMessage; + /// + /// Gets or sets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -274,8 +354,16 @@ public string StatusMessage #region ICommands & Actions + /// + /// Gets the command to refresh the connections. + /// public ICommand RefreshCommand => new RelayCommand(_ => RefreshAction().ConfigureAwait(false), Refresh_CanExecute); + /// + /// Checks if the refresh command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool Refresh_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -285,6 +373,9 @@ private bool Refresh_CanExecute(object parameter) !AutoRefreshEnabled; } + /// + /// Action to refresh the connections. + /// private async Task RefreshAction() { IsStatusMessageDisplayed = false; @@ -292,8 +383,14 @@ private async Task RefreshAction() await Refresh(); } + /// + /// Gets the command to export the connections. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Action to export the connections. + /// private Task ExportAction() { var childWindow = new ExportChildWindow(); @@ -348,6 +445,10 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, #region Methods + /// + /// Refreshes the connections. + /// + /// Indicates whether this is the initial refresh. private async Task Refresh(bool init = false) { IsRefreshing = true; @@ -368,6 +469,9 @@ private async Task Refresh(bool init = false) IsRefreshing = false; } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { // Restart timer... @@ -375,6 +479,9 @@ public void OnViewVisible() _autoRefreshTimer.Start(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { // Temporarily stop timer... diff --git a/Source/NETworkManager/ViewModels/CredentialsChangePasswordViewModel.cs b/Source/NETworkManager/ViewModels/CredentialsChangePasswordViewModel.cs index 9a29dc2507..9d13ed0955 100644 --- a/Source/NETworkManager/ViewModels/CredentialsChangePasswordViewModel.cs +++ b/Source/NETworkManager/ViewModels/CredentialsChangePasswordViewModel.cs @@ -5,6 +5,9 @@ namespace NETworkManager.ViewModels; +/// +/// View model for changing the credentials password. +/// public class CredentialsChangePasswordViewModel : ViewModelBase { /// @@ -33,7 +36,7 @@ public class CredentialsChangePasswordViewModel : ViewModelBase private SecureString _password = new(); /// - /// Initialize a new class with and + /// Initialize a new class with and /// . /// /// which is executed on OK click. diff --git a/Source/NETworkManager/ViewModels/CredentialsPasswordProfileFileViewModel.cs b/Source/NETworkManager/ViewModels/CredentialsPasswordProfileFileViewModel.cs index 6ad8a41c67..e7b0e47069 100644 --- a/Source/NETworkManager/ViewModels/CredentialsPasswordProfileFileViewModel.cs +++ b/Source/NETworkManager/ViewModels/CredentialsPasswordProfileFileViewModel.cs @@ -5,6 +5,9 @@ namespace NETworkManager.ViewModels; +/// +/// View model for entering the password for a profile file. +/// public class CredentialsPasswordProfileFileViewModel : ViewModelBase { /// diff --git a/Source/NETworkManager/ViewModels/CredentialsPasswordViewModel.cs b/Source/NETworkManager/ViewModels/CredentialsPasswordViewModel.cs index d401bbf7a8..dbebb8ce62 100644 --- a/Source/NETworkManager/ViewModels/CredentialsPasswordViewModel.cs +++ b/Source/NETworkManager/ViewModels/CredentialsPasswordViewModel.cs @@ -5,6 +5,9 @@ namespace NETworkManager.ViewModels; +/// +/// View model for entering a password. +/// public class CredentialsPasswordViewModel : ViewModelBase { /// diff --git a/Source/NETworkManager/ViewModels/CredentialsSetPasswordViewModel.cs b/Source/NETworkManager/ViewModels/CredentialsSetPasswordViewModel.cs index 2872d8a21d..32c047a8cd 100644 --- a/Source/NETworkManager/ViewModels/CredentialsSetPasswordViewModel.cs +++ b/Source/NETworkManager/ViewModels/CredentialsSetPasswordViewModel.cs @@ -5,6 +5,9 @@ namespace NETworkManager.ViewModels; +/// +/// View model for setting a password. +/// public class CredentialsSetPasswordViewModel : ViewModelBase { /// diff --git a/Source/NETworkManager/ViewModels/CustomCommandViewModel.cs b/Source/NETworkManager/ViewModels/CustomCommandViewModel.cs index f633549153..b10e59b342 100644 --- a/Source/NETworkManager/ViewModels/CustomCommandViewModel.cs +++ b/Source/NETworkManager/ViewModels/CustomCommandViewModel.cs @@ -4,23 +4,58 @@ namespace NETworkManager.ViewModels; +/// +/// View model for a custom command. +/// public class CustomCommandViewModel : ViewModelBase { + /// + /// Backing field for . + /// private readonly Guid _id; + /// + /// The original custom command info. + /// private readonly CustomCommandInfo _info; + + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + /// + /// Backing field for . + /// private string _arguments; + /// + /// Backing field for . + /// private string _filePath; + /// + /// Backing field for . + /// private bool _infoChanged; + /// + /// Backing field for . + /// private bool _isEdited; + /// + /// Backing field for . + /// private string _name; + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when saving. + /// The action to execute when canceling. + /// Indicates if the command is being edited. + /// The custom command info. public CustomCommandViewModel(Action saveCommand, Action cancelHandler, bool isEdited = false, CustomCommandInfo info = null) { @@ -42,10 +77,19 @@ public CustomCommandViewModel(Action saveCommand, _isLoading = false; } + /// + /// Gets the save command. + /// public ICommand SaveCommand { get; } + /// + /// Gets the cancel command. + /// public ICommand CancelCommand { get; } + /// + /// Gets the ID of the custom command. + /// public Guid ID { get => _id; @@ -59,6 +103,9 @@ private init } } + /// + /// Gets or sets the name of the custom command. + /// public string Name { get => _name; @@ -76,6 +123,9 @@ public string Name } } + /// + /// Gets or sets the file path of the custom command. + /// public string FilePath { get => _filePath; @@ -93,6 +143,9 @@ public string FilePath } } + /// + /// Gets or sets the arguments of the custom command. + /// public string Arguments { get => _arguments; @@ -110,6 +163,9 @@ public string Arguments } } + /// + /// Gets or sets a value indicating whether the info has changed. + /// public bool InfoChanged { get => _infoChanged; @@ -123,6 +179,9 @@ public bool InfoChanged } } + /// + /// Gets or sets a value indicating whether the command is being edited. + /// public bool IsEdited { get => _isEdited; @@ -136,6 +195,9 @@ public bool IsEdited } } + /// + /// Checks if the info has changed. + /// private void CheckInfoChanged() { InfoChanged = _info.Name != null || _info.FilePath != FilePath || _info.Arguments != Arguments; diff --git a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs index 9758c6de37..da95fab145 100644 --- a/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/DNSLookupHostViewModel.cs @@ -18,6 +18,9 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the DNS lookup host view. +/// public class DNSLookupHostViewModel : ViewModelBase, IProfileManager { #region Variables @@ -25,10 +28,19 @@ public class DNSLookupHostViewModel : ViewModelBase, IProfileManager private readonly DispatcherTimer _searchDispatcherTimer = new(); private bool _searchDisabled; + /// + /// Gets the client for inter-tab operations. + /// public IInterTabClient InterTabClient { get; } + /// + /// Backing field for . + /// private string _interTabPartition; + /// + /// Gets or sets the inter-tab partition key. + /// public string InterTabPartition { get => _interTabPartition; @@ -42,13 +54,22 @@ public string InterTabPartition } } + /// + /// Gets the collection of tab items. + /// public ObservableCollection TabItems { get; } private readonly bool _isLoading; private bool _isViewActive = true; + /// + /// Backing field for . + /// private int _selectedTabIndex; + /// + /// Gets or sets the index of the selected tab. + /// public int SelectedTabIndex { get => _selectedTabIndex; @@ -64,8 +85,14 @@ public int SelectedTabIndex #region Profiles + /// + /// Backing field for . + /// private ICollectionView _profiles; + /// + /// Gets the collection view of profiles. + /// public ICollectionView Profiles { get => _profiles; @@ -79,8 +106,14 @@ private set } } + /// + /// Backing field for . + /// private ProfileInfo _selectedProfile = new(); + /// + /// Gets or sets the selected profile. + /// public ProfileInfo SelectedProfile { get => _selectedProfile; @@ -94,8 +127,14 @@ public ProfileInfo SelectedProfile } } + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -117,8 +156,14 @@ public string Search } } + /// + /// Backing field for . + /// private bool _isSearching; + /// + /// Gets or sets a value indicating whether a search is in progress. + /// public bool IsSearching { get => _isSearching; @@ -132,8 +177,14 @@ public bool IsSearching } } + /// + /// Backing field for . + /// private bool _profileFilterIsOpen; + /// + /// Gets or sets a value indicating whether the profile filter is open. + /// public bool ProfileFilterIsOpen { get => _profileFilterIsOpen; @@ -147,12 +198,24 @@ public bool ProfileFilterIsOpen } } + /// + /// Gets the collection view for profile filter tags. + /// public ICollectionView ProfileFilterTagsView { get; } + /// + /// Gets the collection of profile filter tags. + /// private ObservableCollection ProfileFilterTags { get; } = []; + /// + /// Backing field for . + /// private bool _profileFilterTagsMatchAny = GlobalStaticConfiguration.Profile_TagsMatchAny; + /// + /// Gets or sets a value indicating whether any tag match is sufficient for filtering. + /// public bool ProfileFilterTagsMatchAny { get => _profileFilterTagsMatchAny; @@ -166,8 +229,14 @@ public bool ProfileFilterTagsMatchAny } } + /// + /// Backing field for . + /// private bool _profileFilterTagsMatchAll; + /// + /// Gets or sets a value indicating whether all tags must match for filtering. + /// public bool ProfileFilterTagsMatchAll { get => _profileFilterTagsMatchAll; @@ -181,8 +250,14 @@ public bool ProfileFilterTagsMatchAll } } + /// + /// Backing field for . + /// private bool _isProfileFilterSet; + /// + /// Gets or sets a value indicating whether a profile filter is set. + /// public bool IsProfileFilterSet { get => _isProfileFilterSet; @@ -202,8 +277,14 @@ public bool IsProfileFilterSet private bool _canProfileWidthChange = true; private double _tempProfileWidth; + /// + /// Backing field for . + /// private bool _expandProfileView; + /// + /// Gets or sets a value indicating whether the profile view is expanded. + /// public bool ExpandProfileView { get => _expandProfileView; @@ -224,8 +305,14 @@ public bool ExpandProfileView } } + /// + /// Backing field for . + /// private GridLength _profileWidth; + /// + /// Gets or sets the width of the profile view. + /// public GridLength ProfileWidth { get => _profileWidth; @@ -253,6 +340,9 @@ public GridLength ProfileWidth #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public DNSLookupHostViewModel() { _isLoading = true; @@ -287,6 +377,9 @@ public DNSLookupHostViewModel() _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { ExpandProfileView = SettingsManager.Current.DNSLookup_ExpandProfileView; @@ -302,27 +395,48 @@ private void LoadSettings() #region ICommand & Actions + /// + /// Gets the command to add a new tab. + /// public ICommand AddTabCommand => new RelayCommand(_ => AddTabAction()); + /// + /// Action to add a new tab. + /// private void AddTabAction() { AddTab(); } + /// + /// Gets the command to lookup the selected profile. + /// public ICommand LookupProfileCommand => new RelayCommand(_ => LookupProfileAction(), LookupProfile_CanExecute); + /// + /// Checks if the lookup profile command can be executed. + /// private bool LookupProfile_CanExecute(object obj) { return !IsSearching && SelectedProfile != null; } + /// + /// Action to lookup the selected profile. + /// private void LookupProfileAction() { AddTab(SelectedProfile.DNSLookup_Host); } + /// + /// Gets the command to add a new profile. + /// public ICommand AddProfileCommand => new RelayCommand(_ => AddProfileAction()); + /// + /// Action to add a new profile. + /// private void AddProfileAction() { ProfileDialogManager @@ -330,29 +444,50 @@ private void AddProfileAction() .ConfigureAwait(false); } + /// + /// Checks if the profile modification commands can be executed. + /// private bool ModifyProfile_CanExecute(object obj) { return SelectedProfile is { IsDynamic: false }; } + /// + /// Gets the command to edit the selected profile. + /// public ICommand EditProfileCommand => new RelayCommand(_ => EditProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to edit the selected profile. + /// private void EditProfileAction() { ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile) .ConfigureAwait(false); } + /// + /// Gets the command to copy the selected profile as a new profile. + /// public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to copy the selected profile as a new profile. + /// private void CopyAsProfileAction() { ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow, this, SelectedProfile) .ConfigureAwait(false); } + /// + /// Gets the command to delete the selected profile. + /// public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to delete the selected profile. + /// private void DeleteProfileAction() { ProfileDialogManager @@ -360,8 +495,14 @@ private void DeleteProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to edit a profile group. + /// public ICommand EditGroupCommand => new RelayCommand(EditGroupAction); + /// + /// Action to edit a profile group. + /// private void EditGroupAction(object group) { ProfileDialogManager @@ -369,15 +510,27 @@ private void EditGroupAction(object group) .ConfigureAwait(false); } + /// + /// Gets the command to open the profile filter. + /// public ICommand OpenProfileFilterCommand => new RelayCommand(_ => OpenProfileFilterAction()); + /// + /// Action to open the profile filter. + /// private void OpenProfileFilterAction() { ProfileFilterIsOpen = true; } + /// + /// Gets the command to apply the profile filter. + /// public ICommand ApplyProfileFilterCommand => new RelayCommand(_ => ApplyProfileFilterAction()); + /// + /// Action to apply the profile filter. + /// private void ApplyProfileFilterAction() { RefreshProfiles(); @@ -385,8 +538,14 @@ private void ApplyProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to clear the profile filter. + /// public ICommand ClearProfileFilterCommand => new RelayCommand(_ => ClearProfileFilterAction()); + /// + /// Action to clear the profile filter. + /// private void ClearProfileFilterAction() { _searchDisabled = true; @@ -402,22 +561,40 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to expand all profile groups. + /// public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + /// + /// Action to expand all profile groups. + /// private void ExpandAllProfileGroupsAction() { SetIsExpandedForAllProfileGroups(true); } + /// + /// Gets the command to collapse all profile groups. + /// public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + /// + /// Action to collapse all profile groups. + /// private void CollapseAllProfileGroupsAction() { SetIsExpandedForAllProfileGroups(false); } - + + /// + /// Gets the callback for closing a tab item. + /// public ItemActionCallback CloseItemCommand => CloseItemAction; + /// + /// Action to close a tab item. + /// private static void CloseItemAction(ItemActionCallbackArgs args) { ((args.DragablzItem.Content as DragablzTabItem)?.View as DNSLookupView)?.CloseTab(); @@ -427,12 +604,20 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #region Methods + /// + /// Sets the IsExpanded property for all profile groups. + /// + /// The value to set. private void SetIsExpandedForAllProfileGroups(bool isExpanded) { foreach (var group in Profiles.Groups.Cast()) GroupExpanderStateStore[group.Name.ToString()] = isExpanded; } - + + /// + /// Resizes the profile view. + /// + /// Indicates if the resize is due to a changed size. private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; @@ -462,6 +647,10 @@ private void ResizeProfile(bool dueToChangedSize) _canProfileWidthChange = true; } + /// + /// Adds a new tab for the specified host. + /// + /// The host to lookup. public void AddTab(string host = null) { var tabId = Guid.NewGuid(); @@ -472,6 +661,9 @@ public void AddTab(string host = null) SelectedTabIndex = TabItems.Count - 1; } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { _isViewActive = true; @@ -479,11 +671,17 @@ public void OnViewVisible() RefreshProfiles(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { _isViewActive = false; } + /// + /// Creates the profile filter tags. + /// private void CreateTags() { var tags = ProfileManager.Groups.SelectMany(x => x.Profiles).Where(x => x.DNSLookup_Enabled) @@ -505,6 +703,11 @@ private void CreateTags() } } + /// + /// Sets the profiles view with the specified filter. + /// + /// The profile filter. + /// The profile to select. private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = null) { Profiles = new CollectionViewSource @@ -536,6 +739,9 @@ private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = nul SelectedProfile = Profiles.Cast().FirstOrDefault(); } + /// + /// Refreshes the profiles. + /// private void RefreshProfiles() { if (!_isViewActive) @@ -557,6 +763,9 @@ private void RefreshProfiles() #region Event + /// + /// Handles the OnProfilesUpdated event of the ProfileManager. + /// private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e) { CreateTags(); @@ -564,6 +773,9 @@ private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e) RefreshProfiles(); } + /// + /// Handles the Tick event of the search dispatcher timer. + /// private void SearchDispatcherTimer_Tick(object sender, EventArgs e) { _searchDispatcherTimer.Stop(); diff --git a/Source/NETworkManager/ViewModels/DNSLookupSettingsViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupSettingsViewModel.cs index 1bcfe63d1d..6cb9a0f035 100644 --- a/Source/NETworkManager/ViewModels/DNSLookupSettingsViewModel.cs +++ b/Source/NETworkManager/ViewModels/DNSLookupSettingsViewModel.cs @@ -17,19 +17,41 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the DNS lookup settings. +/// public class DNSLookupSettingsViewModel : ViewModelBase { #region Variables + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + + /// + /// Default values for the profile dialog. + /// private readonly ServerConnectionInfo _profileDialogDefaultValues = new("10.0.0.1", 53, TransportProtocol.Udp); + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Gets the collection view of DNS servers. + /// public ICollectionView DNSServers { get; } + /// + /// Backing field for . + /// private DNSServerConnectionInfoProfile _selectedDNSServer = new(); + /// + /// Gets or sets the selected DNS server. + /// public DNSServerConnectionInfoProfile SelectedDNSServer { get => _selectedDNSServer; @@ -43,14 +65,23 @@ public DNSServerConnectionInfoProfile SelectedDNSServer } } + /// + /// Gets the list of server info profile names. + /// private List ServerInfoProfileNames => [ .. SettingsManager.Current.DNSLookup_DNSServers .Where(x => !x.UseWindowsDNSServer).Select(x => x.Name) ]; + /// + /// Backing field for . + /// private bool _addDNSSuffix; + /// + /// Gets or sets a value indicating whether to add DNS suffix. + /// public bool AddDNSSuffix { get => _addDNSSuffix; @@ -67,8 +98,14 @@ public bool AddDNSSuffix } } + /// + /// Backing field for . + /// private bool _useCustomDNSSuffix; + /// + /// Gets or sets a value indicating whether to use a custom DNS suffix. + /// public bool UseCustomDNSSuffix { get => _useCustomDNSSuffix; @@ -85,8 +122,14 @@ public bool UseCustomDNSSuffix } } + /// + /// Backing field for . + /// private string _customDNSSuffix; + /// + /// Gets or sets the custom DNS suffix. + /// public string CustomDNSSuffix { get => _customDNSSuffix; @@ -103,8 +146,14 @@ public string CustomDNSSuffix } } + /// + /// Backing field for . + /// private bool _recursion; + /// + /// Gets or sets a value indicating whether recursion is enabled. + /// public bool Recursion { get => _recursion; @@ -121,8 +170,14 @@ public bool Recursion } } + /// + /// Backing field for . + /// private bool _useCache; + /// + /// Gets or sets a value indicating whether to use cache. + /// public bool UseCache { get => _useCache; @@ -139,10 +194,19 @@ public bool UseCache } } + /// + /// Gets the list of available query classes. + /// public List QueryClasses { get; private set; } + /// + /// Backing field for . + /// private QueryClass _queryClass; + /// + /// Gets or sets the selected query class. + /// public QueryClass QueryClass { get => _queryClass; @@ -161,7 +225,7 @@ public QueryClass QueryClass /* * Disabled until more query types are implemented. - * + private bool _showOnlyMostCommonQueryTypes; @@ -182,8 +246,14 @@ public bool ShowOnlyMostCommonQueryTypes } */ + /// + /// Backing field for . + /// private bool _useTCPOnly; + /// + /// Gets or sets a value indicating whether to use TCP only. + /// public bool UseTCPOnly { get => _useTCPOnly; @@ -200,8 +270,14 @@ public bool UseTCPOnly } } + /// + /// Backing field for . + /// private int _retries; + /// + /// Gets or sets the number of retries. + /// public int Retries { get => _retries; @@ -218,8 +294,14 @@ public int Retries } } + /// + /// Backing field for . + /// private int _timeout; + /// + /// Gets or sets the timeout in milliseconds. + /// public int Timeout { get => _timeout; @@ -240,6 +322,10 @@ public int Timeout #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public DNSLookupSettingsViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -262,6 +348,9 @@ public DNSLookupSettingsViewModel(IDialogCoordinator instance) _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { AddDNSSuffix = SettingsManager.Current.DNSLookup_AddDNSSuffix; @@ -278,25 +367,43 @@ private void LoadSettings() } #endregion - + #region ICommand & Actions + /// + /// Gets the command to add a DNS server. + /// public ICommand AddDNSServerCommand => new RelayCommand(_ => AddDNSServerAction()); + /// + /// Action to add a DNS server. + /// private void AddDNSServerAction() { AddDNSServer().ConfigureAwait(false); } + /// + /// Gets the command to edit a DNS server. + /// public ICommand EditDNSServerCommand => new RelayCommand(_ => EditDNSServerAction()); + /// + /// Action to edit a DNS server. + /// private void EditDNSServerAction() { EditDNSServer().ConfigureAwait(false); } + /// + /// Gets the command to delete a DNS server. + /// public ICommand DeleteDNSServerCommand => new RelayCommand(_ => DeleteDNSServerAction()); + /// + /// Action to delete a DNS server. + /// private void DeleteDNSServerAction() { DeleteDNSServer().ConfigureAwait(false); @@ -306,6 +413,9 @@ private void DeleteDNSServerAction() #region Methods + /// + /// Adds a new DNS server. + /// private async Task AddDNSServer() { var customDialog = new CustomDialog @@ -331,6 +441,9 @@ private async Task AddDNSServer() await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); } + /// + /// Edits the selected DNS server. + /// public async Task EditDNSServer() { var customDialog = new CustomDialog @@ -357,6 +470,9 @@ public async Task EditDNSServer() await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); } + /// + /// Deletes the selected DNS server. + /// private async Task DeleteDNSServer() { var result = await DialogHelper.ShowOKCancelMessageAsync(Application.Current.MainWindow, diff --git a/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs b/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs index 288cef0176..36a0e99795 100644 --- a/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs +++ b/Source/NETworkManager/ViewModels/DNSLookupViewModel.cs @@ -24,21 +24,36 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the DNS lookup view. +/// public class DNSLookupViewModel : ViewModelBase { #region Variables private static readonly ILog Log = LogManager.GetLogger(typeof(DNSLookupViewModel)); + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; private readonly Guid _tabId; private bool _firstLoad = true; private bool _closed; + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + /// + /// Backing field for . + /// private string _host; + /// + /// Gets or sets the host to lookup. + /// public string Host { get => _host; @@ -52,12 +67,24 @@ public string Host } } + /// + /// Gets the collection view of host history. + /// public ICollectionView HostHistoryView { get; } + /// + /// Gets the collection view of DNS servers. + /// public ICollectionView DNSServers { get; } + /// + /// Backing field for . + /// private DNSServerConnectionInfoProfile _dnsServer = new(); + /// + /// Gets or sets the selected DNS server. + /// public DNSServerConnectionInfoProfile DNSServer { get => _dnsServer; @@ -74,8 +101,14 @@ public DNSServerConnectionInfoProfile DNSServer } } + /// + /// Backing field for . + /// private List _queryTypes = new(); + /// + /// Gets the list of available query types. + /// public List QueryTypes { get => _queryTypes; @@ -89,8 +122,14 @@ private set } } + /// + /// Backing field for . + /// private QueryType _queryType; + /// + /// Gets or sets the selected query type. + /// public QueryType QueryType { get => _queryType; @@ -107,8 +146,14 @@ public QueryType QueryType } } + /// + /// Backing field for . + /// private bool _isRunning; + /// + /// Gets or sets a value indicating whether the lookup is running. + /// public bool IsRunning { get => _isRunning; @@ -122,8 +167,14 @@ public bool IsRunning } } + /// + /// Backing field for . + /// private ObservableCollection _results = new(); + /// + /// Gets or sets the collection of lookup results. + /// public ObservableCollection Results { get => _results; @@ -136,10 +187,19 @@ public ObservableCollection Results } } + /// + /// Gets the collection view for lookup results. + /// public ICollectionView ResultsView { get; } + /// + /// Backing field for . + /// private DNSLookupRecordInfo _selectedResult; + /// + /// Gets or sets the selected lookup result. + /// public DNSLookupRecordInfo SelectedResult { get => _selectedResult; @@ -153,8 +213,14 @@ public DNSLookupRecordInfo SelectedResult } } + /// + /// Backing field for . + /// private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of selected lookup results. + /// public IList SelectedResults { get => _selectedResults; @@ -168,8 +234,14 @@ public IList SelectedResults } } + /// + /// Backing field for . + /// private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -183,8 +255,14 @@ public bool IsStatusMessageDisplayed } } + /// + /// Backing field for . + /// private string _statusMessage; + /// + /// Gets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -202,6 +280,12 @@ private set #region Contructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. + /// The ID of the tab. + /// The host to lookup. public DNSLookupViewModel(IDialogCoordinator instance, Guid tabId, string host) { _isLoading = true; @@ -237,6 +321,9 @@ public DNSLookupViewModel(IDialogCoordinator instance, Guid tabId, string host) _isLoading = false; } + /// + /// Called when the view is loaded. + /// public void OnLoaded() { if (!_firstLoad) @@ -248,11 +335,17 @@ public void OnLoaded() _firstLoad = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { LoadTypes(); } + /// + /// Loads the query types. + /// private void LoadTypes() { var queryTypes = (QueryType[])Enum.GetValues(typeof(QueryType)); @@ -274,8 +367,16 @@ private void LoadTypes() #region ICommands & Actions + /// + /// Gets the command to start the query. + /// public ICommand QueryCommand => new RelayCommand(_ => QueryAction(), Query_CanExecute); + /// + /// Checks if the query command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool Query_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -283,14 +384,23 @@ private bool Query_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Action to start the query. + /// private void QueryAction() { if (!IsRunning) Query(); } + /// + /// Gets the command to export the results. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction()); + /// + /// Action to export the results. + /// private void ExportAction() { Export().ConfigureAwait(false); @@ -300,6 +410,9 @@ private void ExportAction() #region Methods + /// + /// Performs the DNS query. + /// private void Query() { IsStatusMessageDisplayed = false; @@ -343,6 +456,9 @@ private void Query() dnsLookup.ResolveAsync([.. Host.Split(';').Select(x => x.Trim())]); } + /// + /// Called when the view is closed. + /// public void OnClose() { // Prevent multiple calls @@ -355,6 +471,10 @@ public void OnClose() } // Modify history list + /// + /// Adds the host to the history. + /// + /// The host to add. private void AddHostToHistory(string host) { // Create the new list @@ -370,6 +490,9 @@ private void AddHostToHistory(string host) } + /// + /// Exports the results. + /// private Task Export() { var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive); @@ -426,12 +549,18 @@ await _dialogCoordinator.ShowMessageAsync(window, Strings.Error, #region Events + /// + /// Handles the RecordReceived event of the DNS lookup. + /// private void DNSLookup_RecordReceived(object sender, DNSLookupRecordReceivedArgs e) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate { Results.Add(e.Args); })); } + /// + /// Handles the LookupError event of the DNS lookup. + /// private void DNSLookup_LookupError(object sender, DNSLookupErrorArgs e) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate @@ -453,11 +582,17 @@ private void DNSLookup_LookupError(object sender, DNSLookupErrorArgs e) })); } + /// + /// Handles the LookupComplete event of the DNS lookup. + /// private void DNSLookup_LookupComplete(object sender, EventArgs e) { IsRunning = false; } + /// + /// Handles the PropertyChanged event of the SettingsManager. + /// private void SettingsManager_PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) diff --git a/Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs b/Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs index c5ad55a0ce..87b6abefa4 100644 --- a/Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs +++ b/Source/NETworkManager/ViewModels/DashboardSettingsViewModel.cs @@ -2,14 +2,26 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the dashboard settings. +/// public class DashboardSettingsViewModel : ViewModelBase { #region Variables + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + /// + /// Backing field for . + /// private string _publicIPv4Address; + /// + /// Gets or sets the public IPv4 address. + /// public string PublicIPv4Address { get => _publicIPv4Address; @@ -26,8 +38,14 @@ public string PublicIPv4Address } } + /// + /// Backing field for . + /// private string _publicIPv6Address; + /// + /// Gets or sets the public IPv6 address. + /// public string PublicIPv6Address { get => _publicIPv6Address; @@ -44,8 +62,14 @@ public string PublicIPv6Address } } + /// + /// Backing field for . + /// private bool _checkPublicIPAddressEnabled; + /// + /// Gets or sets a value indicating whether checking public IP address is enabled. + /// public bool CheckPublicIPAddressEnabled { get => _checkPublicIPAddressEnabled; @@ -62,8 +86,14 @@ public bool CheckPublicIPAddressEnabled } } + /// + /// Backing field for . + /// private bool _usePublicIPv4AddressCustomAPI; + /// + /// Gets or sets a value indicating whether to use a custom API for public IPv4 address. + /// public bool UsePublicIPv4AddressCustomAPI { get => _usePublicIPv4AddressCustomAPI; @@ -80,8 +110,14 @@ public bool UsePublicIPv4AddressCustomAPI } } + /// + /// Backing field for . + /// private string _customPublicIPv4AddressAPI; + /// + /// Gets or sets the custom API URL for public IPv4 address. + /// public string CustomPublicIPv4AddressAPI { get => _customPublicIPv4AddressAPI; @@ -98,8 +134,14 @@ public string CustomPublicIPv4AddressAPI } } + /// + /// Backing field for . + /// private bool _usePublicIPv6AddressCustomAPI; + /// + /// Gets or sets a value indicating whether to use a custom API for public IPv6 address. + /// public bool UsePublicIPv6AddressCustomAPI { get => _usePublicIPv6AddressCustomAPI; @@ -116,8 +158,14 @@ public bool UsePublicIPv6AddressCustomAPI } } + /// + /// Backing field for . + /// private string _customPublicIPv6AddressAPI; + /// + /// Gets or sets the custom API URL for public IPv6 address. + /// public string CustomPublicIPv6AddressAPI { get => _customPublicIPv6AddressAPI; @@ -134,8 +182,14 @@ public string CustomPublicIPv6AddressAPI } } + /// + /// Backing field for . + /// private bool _checkIPApiIPGeolocationEnabled; + /// + /// Gets or sets a value indicating whether checking IP geolocation is enabled. + /// public bool CheckIPApiIPGeolocationEnabled { get => _checkIPApiIPGeolocationEnabled; @@ -152,8 +206,14 @@ public bool CheckIPApiIPGeolocationEnabled } } + /// + /// Backing field for . + /// private bool _checkIPApiDNSResolverEnabled; + /// + /// Gets or sets a value indicating whether checking IP API DNS resolver is enabled. + /// public bool CheckIPApiDNSResolverEnabled { get => _checkIPApiDNSResolverEnabled; @@ -174,6 +234,9 @@ public bool CheckIPApiDNSResolverEnabled #region Contructor, load settings + /// + /// Initializes a new instance of the class. + /// public DashboardSettingsViewModel() { _isLoading = true; @@ -183,6 +246,9 @@ public DashboardSettingsViewModel() _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { PublicIPv4Address = SettingsManager.Current.Dashboard_PublicIPv4Address; diff --git a/Source/NETworkManager/ViewModels/DashboardViewModel.cs b/Source/NETworkManager/ViewModels/DashboardViewModel.cs index 58f3d9b06c..c9a51810b1 100644 --- a/Source/NETworkManager/ViewModels/DashboardViewModel.cs +++ b/Source/NETworkManager/ViewModels/DashboardViewModel.cs @@ -1,22 +1,37 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the Dashboard view. +/// public class DashboardViewModel : ViewModelBase { + /// + /// Initializes a new instance of the class. + /// public DashboardViewModel() { LoadSettings(); } + /// + /// Loads the dashboard settings. + /// private void LoadSettings() { } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { diff --git a/Source/NETworkManager/ViewModels/DiscoveryProtocolViewModel.cs b/Source/NETworkManager/ViewModels/DiscoveryProtocolViewModel.cs index 0c3a5d920e..f57a45d2fe 100644 --- a/Source/NETworkManager/ViewModels/DiscoveryProtocolViewModel.cs +++ b/Source/NETworkManager/ViewModels/DiscoveryProtocolViewModel.cs @@ -18,20 +18,47 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the discovery protocol view. +/// public class DiscoveryProtocolViewModel : ViewModelBase { #region Variables private static readonly ILog Log = LogManager.GetLogger(typeof(DiscoveryProtocolViewModel)); + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// The discovery protocol capture instance. + /// private readonly DiscoveryProtocolCapture _discoveryProtocolCapture = new(); + + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + + /// + /// The timer for the remaining time. + /// private readonly Timer _remainingTimer; + + /// + /// The seconds remaining for the capture. + /// private int _secondsRemaining; + /// + /// Backing field for . + /// private bool _firstRun = true; + /// + /// Gets or sets a value indicating whether this is the first run. + /// public bool FirstRun { get => _firstRun; @@ -45,8 +72,14 @@ public bool FirstRun } } + /// + /// Backing field for . + /// private List _protocols = new(); + /// + /// Gets the list of available discovery protocols. + /// public List Protocols { get => _protocols; @@ -60,8 +93,14 @@ private set } } + /// + /// Backing field for . + /// private DiscoveryProtocol _selectedProtocol; + /// + /// Gets or sets the selected discovery protocol. + /// public DiscoveryProtocol SelectedProtocol { get => _selectedProtocol; @@ -78,8 +117,14 @@ public DiscoveryProtocol SelectedProtocol } } + /// + /// Backing field for . + /// private List _durations; + /// + /// Gets the list of available durations. + /// public List Durations { get => _durations; @@ -93,8 +138,14 @@ private set } } + /// + /// Backing field for . + /// private int _selectedDuration; + /// + /// Gets or sets the selected duration. + /// public int SelectedDuration { get => _selectedDuration; @@ -111,8 +162,14 @@ public int SelectedDuration } } + /// + /// Backing field for . + /// private bool _isCapturing; + /// + /// Gets or sets a value indicating whether the capture is running. + /// public bool IsCapturing { get => _isCapturing; @@ -126,8 +183,14 @@ public bool IsCapturing } } + /// + /// Backing field for . + /// private string _timeRemainingMessage; + /// + /// Gets the message for the remaining time. + /// public string TimeRemainingMessage { get => _timeRemainingMessage; @@ -141,8 +204,14 @@ private set } } + /// + /// Backing field for . + /// private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -156,8 +225,14 @@ public bool IsStatusMessageDisplayed } } + /// + /// Backing field for . + /// private string _statusMessage; + /// + /// Gets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -171,8 +246,14 @@ private set } } + /// + /// Backing field for . + /// private bool _discoveryPackageReceived; + /// + /// Gets or sets a value indicating whether a discovery package has been received. + /// public bool DiscoveryPackageReceived { get => _discoveryPackageReceived; @@ -186,8 +267,14 @@ public bool DiscoveryPackageReceived } } + /// + /// Backing field for . + /// private DiscoveryProtocolPackageInfo _discoveryPackage; + /// + /// Gets the received discovery package. + /// public DiscoveryProtocolPackageInfo DiscoveryPackage { get => _discoveryPackage; @@ -205,6 +292,10 @@ private set #region Constructor, LoadSettings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public DiscoveryProtocolViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -228,6 +319,9 @@ public DiscoveryProtocolViewModel(IDialogCoordinator instance) _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { Protocols = Enum.GetValues(typeof(DiscoveryProtocol)).Cast().OrderBy(x => x.ToString()) @@ -241,8 +335,14 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to restart the application as administrator. + /// public ICommand RestartAsAdminCommand => new RelayCommand(_ => RestartAsAdminAction().ConfigureAwait(false)); + /// + /// Action to restart the application as administrator. + /// private async Task RestartAsAdminAction() { try @@ -256,8 +356,14 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, ex.Message, } } + /// + /// Gets the command to start the capture. + /// public ICommand CaptureCommand => new RelayCommand(_ => CaptureAction().ConfigureAwait(false)); + /// + /// Action to start the capture. + /// private async Task CaptureAction() { if (FirstRun) @@ -291,8 +397,14 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, ex.Message, } } + /// + /// Gets the command to export the result. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Action to export the result. + /// private Task ExportAction() { var childWindow = new ExportChildWindow(); @@ -344,6 +456,9 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, #region Methods + /// + /// Handles the elapsed event of the remaining time timer. + /// private void Timer_Elapsed(object sender, ElapsedEventArgs e) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate @@ -356,10 +471,16 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e) })); } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { } @@ -368,6 +489,9 @@ public void OnViewHide() #region Events + /// + /// Handles the PackageReceived event of the discovery protocol capture. + /// private void DiscoveryProtocol_PackageReceived(object sender, DiscoveryProtocolPackageArgs e) { DiscoveryPackage = e.PackageInfo; @@ -375,6 +499,9 @@ private void DiscoveryProtocol_PackageReceived(object sender, DiscoveryProtocolP DiscoveryPackageReceived = true; } + /// + /// Handles the WarningReceived event of the discovery protocol capture. + /// private void DiscoveryProtocol_WarningReceived(object sender, DiscoveryProtocolWarningArgs e) { if (!string.IsNullOrEmpty(StatusMessage)) @@ -385,6 +512,9 @@ private void DiscoveryProtocol_WarningReceived(object sender, DiscoveryProtocolW IsStatusMessageDisplayed = true; } + /// + /// Handles the ErrorReceived event of the discovery protocol capture. + /// private void DiscoveryProtocol_ErrorReceived(object sender, DiscoveryProtocolErrorArgs e) { if (!string.IsNullOrEmpty(StatusMessage)) @@ -395,6 +525,9 @@ private void DiscoveryProtocol_ErrorReceived(object sender, DiscoveryProtocolErr IsStatusMessageDisplayed = true; } + /// + /// Handles the Complete event of the discovery protocol capture. + /// private void DiscoveryProtocol_Complete(object sender, EventArgs e) { _remainingTimer.Stop(); diff --git a/Source/NETworkManager/ViewModels/DropdownViewModel.cs b/Source/NETworkManager/ViewModels/DropdownViewModel.cs index 38215d4a1b..a24ebe2b58 100644 --- a/Source/NETworkManager/ViewModels/DropdownViewModel.cs +++ b/Source/NETworkManager/ViewModels/DropdownViewModel.cs @@ -6,14 +6,33 @@ namespace NETworkManager.ViewModels; +/// +/// View model for a dropdown dialog. +/// public class DropdownViewModel : ViewModelBase { + /// + /// Backing field for . + /// private readonly string _valueDescription; + /// + /// Backing field for . + /// private readonly List _values; + /// + /// Backing field for . + /// private string _selectedValue; + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when OK is clicked. + /// The action to execute when Cancel is clicked. + /// The list of values to display in the dropdown. + /// The description of the value. public DropdownViewModel(Action okCommand, Action cancelHandler, List values, string valueDescription) { @@ -26,10 +45,19 @@ public DropdownViewModel(Action okCommand, Action cancelHandler(this)); } + /// + /// Gets the command to confirm the selection. + /// public ICommand OKCommand { get; } + /// + /// Gets the command to cancel the operation. + /// public ICommand CancelCommand { get; } + /// + /// Gets the description of the value. + /// public string ValueDescription { get => _valueDescription; @@ -43,6 +71,9 @@ private init } } + /// + /// Gets the list of values. + /// public List Values { get => _values; @@ -56,6 +87,9 @@ private init } } + /// + /// Gets or sets the selected value. + /// public string SelectedValue { get => _selectedValue; diff --git a/Source/NETworkManager/ViewModels/ExportViewModel.cs b/Source/NETworkManager/ViewModels/ExportViewModel.cs index da1b8b71cb..ddd09e332d 100644 --- a/Source/NETworkManager/ViewModels/ExportViewModel.cs +++ b/Source/NETworkManager/ViewModels/ExportViewModel.cs @@ -10,38 +10,78 @@ namespace NETworkManager.ViewModels; /// +/// View model for exporting data. /// public class ExportViewModel : ViewModelBase { /// + /// Backing field for . /// private bool _exportAll = true; + /// + /// Backing field for . + /// private bool _exportSelected; + /// + /// Backing field for . + /// private string _filePath; + /// + /// Backing field for . + /// private bool _showCsv; /// + /// Backing field for . /// private bool _showExportSelected; + /// + /// Backing field for . + /// private bool _showJson; + /// + /// Backing field for . + /// private bool _showTxt; + /// + /// Backing field for . + /// private bool _showXml; + /// + /// Backing field for . + /// private bool _useCsv; + /// + /// Backing field for . + /// private bool _useJson; + /// + /// Backing field for . + /// private bool _useTxt; + /// + /// Backing field for . + /// private bool _useXml; + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when export is confirmed. + /// The action to execute when cancel is clicked. + /// The array of file types to show. + /// Indicates whether to show the "Export selected" option. private ExportViewModel(Action deleteCommand, Action cancelHandler, ExportFileType[] showFilesTypes, bool showExportSelected) { @@ -56,6 +96,15 @@ private ExportViewModel(Action deleteCommand, Action + /// Initializes a new instance of the class. + /// + /// The action to execute when export is confirmed. + /// The action to execute when cancel is clicked. + /// The array of file types to show. + /// Indicates whether to show the "Export selected" option. + /// The initial file type. + /// The initial file path. public ExportViewModel(Action deleteCommand, Action cancelHandler, ExportFileType[] showFilesTypes, bool showExportSelected, ExportFileType fileType, string filePath) : this(deleteCommand, cancelHandler, showFilesTypes, showExportSelected) @@ -82,14 +131,17 @@ public ExportViewModel(Action deleteCommand, Action + /// Gets the command to export data. /// public ICommand ExportCommand { get; } /// + /// Gets the command to cancel the operation. /// public ICommand CancelCommand { get; } /// + /// Gets or sets a value indicating whether to export all data. /// public bool ExportAll { @@ -105,6 +157,7 @@ public bool ExportAll } /// + /// Gets or sets a value indicating whether to show the "Export selected" option. /// public bool ShowExportSelected { @@ -119,6 +172,9 @@ public bool ShowExportSelected } } + /// + /// Gets or sets a value indicating whether to export only selected data. + /// public bool ExportSelected { get => _exportSelected; @@ -132,8 +188,14 @@ public bool ExportSelected } } + /// + /// Gets the selected file type for export. + /// public ExportFileType FileType { get; private set; } + /// + /// Gets or sets a value indicating whether to show the CSV option. + /// public bool ShowCsv { get => _showCsv; @@ -147,6 +209,9 @@ public bool ShowCsv } } + /// + /// Gets or sets a value indicating whether CSV format is selected. + /// public bool UseCsv { get => _useCsv; @@ -166,6 +231,9 @@ public bool UseCsv } } + /// + /// Gets or sets a value indicating whether to show the XML option. + /// public bool ShowXml { get => _showXml; @@ -179,6 +247,9 @@ public bool ShowXml } } + /// + /// Gets or sets a value indicating whether XML format is selected. + /// public bool UseXml { get => _useXml; @@ -198,6 +269,9 @@ public bool UseXml } } + /// + /// Gets or sets a value indicating whether to show the JSON option. + /// public bool ShowJson { get => _showJson; @@ -211,6 +285,9 @@ public bool ShowJson } } + /// + /// Gets or sets a value indicating whether JSON format is selected. + /// public bool UseJson { get => _useJson; @@ -230,6 +307,9 @@ public bool UseJson } } + /// + /// Gets or sets a value indicating whether to show the TXT option. + /// public bool ShowTxt { get => _showTxt; @@ -243,6 +323,9 @@ public bool ShowTxt } } + /// + /// Gets or sets a value indicating whether TXT format is selected. + /// public bool UseTxt { get => _useTxt; @@ -262,6 +345,9 @@ public bool UseTxt } } + /// + /// Gets or sets the file path for export. + /// public string FilePath { get => _filePath; @@ -275,8 +361,14 @@ public string FilePath } } + /// + /// Gets the command to browse for a file. + /// public ICommand BrowseFileCommand => new RelayCommand(_ => BrowseFileAction()); + /// + /// Action to browse for a file. + /// private void BrowseFileAction() { var saveFileDialog = new SaveFileDialog(); @@ -288,6 +380,10 @@ private void BrowseFileAction() if (saveFileDialog.ShowDialog() == DialogResult.OK) FilePath = saveFileDialog.FileName; } + /// + /// Changes the file path extension based on the selected file type. + /// + /// The new file type. private void ChangeFilePathExtension(ExportFileType fileType) { if (string.IsNullOrEmpty(FilePath)) diff --git a/Source/NETworkManager/ViewModels/GroupViewModel.cs b/Source/NETworkManager/ViewModels/GroupViewModel.cs index dcbd1311c4..9bac8b7e83 100644 --- a/Source/NETworkManager/ViewModels/GroupViewModel.cs +++ b/Source/NETworkManager/ViewModels/GroupViewModel.cs @@ -16,23 +16,48 @@ namespace NETworkManager.ViewModels; +/// +/// View model for a profile group. +/// public class GroupViewModel : ViewModelBase { #region Variables + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading = true; + /// + /// Gets a value indicating whether the profile file is encrypted. + /// public bool IsProfileFileEncrypted => ProfileManager.LoadedProfileFile.IsEncrypted; + /// + /// Gets the collection view of group views. + /// public ICollectionView GroupViews { get; } + + /// + /// Gets the group info. + /// public GroupInfo Group { get; } + /// + /// The list of existing group names. + /// private IReadOnlyCollection _groups { get; } #region General + /// + /// Backing field for . + /// private bool _nameIsValid = true; + /// + /// Gets or sets a value indicating whether the name is valid. + /// public bool NameIsValid { get => _nameIsValid; @@ -46,8 +71,14 @@ public bool NameIsValid } } + /// + /// Backing field for . + /// private string _name; + /// + /// Gets or sets the name of the group. + /// public string Name { get => _name; @@ -68,8 +99,14 @@ public string Name } } + /// + /// Backing field for . + /// private string _description; + /// + /// Gets or sets the description of the group. + /// public string Description { get => _description; @@ -87,8 +124,14 @@ public string Description #region Remote Desktop + /// + /// Backing field for . + /// private bool _remoteDesktop_UseCredentials; + /// + /// Gets or sets a value indicating whether to use credentials for Remote Desktop. + /// public bool RemoteDesktop_UseCredentials { get => _remoteDesktop_UseCredentials; @@ -102,8 +145,14 @@ public bool RemoteDesktop_UseCredentials } } + /// + /// Backing field for . + /// private string _remoteDesktop_Username; + /// + /// Gets or sets the username for Remote Desktop. + /// public string RemoteDesktop_Username { get => _remoteDesktop_Username; @@ -117,8 +166,14 @@ public string RemoteDesktop_Username } } + /// + /// Backing field for . + /// private string _remoteDesktop_Domain; + /// + /// Gets or sets the domain for Remote Desktop. + /// public string RemoteDesktop_Domain { get => _remoteDesktop_Domain; diff --git a/Source/NETworkManager/ViewModels/HostsFileEditorEntryViewModel.cs b/Source/NETworkManager/ViewModels/HostsFileEditorEntryViewModel.cs index 52ac61b05f..8603f1ccd6 100644 --- a/Source/NETworkManager/ViewModels/HostsFileEditorEntryViewModel.cs +++ b/Source/NETworkManager/ViewModels/HostsFileEditorEntryViewModel.cs @@ -50,6 +50,9 @@ public HostsFileEditorEntryViewModel(Action okCom /// public ICommand CancelCommand { get; } + /// + /// Gets the hosts file entry. + /// public HostsFileEntry Entry { get; } = null; /// diff --git a/Source/NETworkManager/ViewModels/HostsFileEditorViewModel.cs b/Source/NETworkManager/ViewModels/HostsFileEditorViewModel.cs index 041d5e720b..cb4937d19a 100644 --- a/Source/NETworkManager/ViewModels/HostsFileEditorViewModel.cs +++ b/Source/NETworkManager/ViewModels/HostsFileEditorViewModel.cs @@ -20,18 +20,33 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the hosts file editor. +/// public class HostsFileEditorViewModel : ViewModelBase { #region Variables private static readonly ILog Log = LogManager.GetLogger(typeof(HostsFileEditorViewModel)); + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -48,8 +63,14 @@ public string Search } } + /// + /// Backing field for . + /// private ObservableCollection _results = []; + /// + /// Gets or sets the collection of hosts file entries. + /// public ObservableCollection Results { get => _results; @@ -63,10 +84,19 @@ public ObservableCollection Results } } + /// + /// Gets the collection view for the hosts file entries. + /// public ICollectionView ResultsView { get; } + /// + /// Backing field for . + /// private HostsFileEntry _selectedResult; + /// + /// Gets or sets the selected hosts file entry. + /// public HostsFileEntry SelectedResult { get => _selectedResult; @@ -80,8 +110,14 @@ public HostsFileEntry SelectedResult } } + /// + /// Backing field for . + /// private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of selected hosts file entries. + /// public IList SelectedResults { get => _selectedResults; @@ -95,8 +131,14 @@ public IList SelectedResults } } + /// + /// Backing field for . + /// private bool _isModifying; + /// + /// Gets or sets a value indicating whether the view model is modifying an entry. + /// public bool IsModifying { get => _isModifying; @@ -110,8 +152,14 @@ public bool IsModifying } } + /// + /// Backing field for . + /// private bool _isRefreshing; + /// + /// Gets or sets a value indicating whether the view model is currently refreshing. + /// public bool IsRefreshing { get => _isRefreshing; @@ -125,8 +173,14 @@ public bool IsRefreshing } } + /// + /// Backing field for . + /// private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -140,8 +194,14 @@ public bool IsStatusMessageDisplayed } } + /// + /// Backing field for . + /// private string _statusMessage; + /// + /// Gets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -159,6 +219,10 @@ private set #region Constructor, LoadSettings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public HostsFileEditorViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -191,6 +255,9 @@ public HostsFileEditorViewModel(IDialogCoordinator instance) _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { } @@ -199,8 +266,16 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to refresh the entries. + /// public ICommand RefreshCommand => new RelayCommand(_ => RefreshAction().ConfigureAwait(false), Refresh_CanExecute); + /// + /// Checks if the refresh command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool Refresh_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -210,13 +285,22 @@ private bool Refresh_CanExecute(object parameter) !IsModifying; } + /// + /// Action to refresh the entries. + /// private async Task RefreshAction() { await Refresh(); } + /// + /// Gets the command to export the entries. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Action to export the entries. + /// private Task ExportAction() { var childWindow = new ExportChildWindow(); @@ -266,9 +350,15 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, return (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow); } + /// + /// Gets the command to enable the selected entry. + /// public ICommand EnableEntryCommand => new RelayCommand(_ => EnableEntryAction().ConfigureAwait(false), ModifyEntry_CanExecute); + /// + /// Action to enable the selected entry. + /// private async Task EnableEntryAction() { IsModifying = true; @@ -281,9 +371,15 @@ private async Task EnableEntryAction() IsModifying = false; } + /// + /// Gets the command to disable the selected entry. + /// public ICommand DisableEntryCommand => new RelayCommand(_ => DisableEntryAction().ConfigureAwait(false), ModifyEntry_CanExecute); + /// + /// Action to disable the selected entry. + /// private async Task DisableEntryAction() { IsModifying = true; @@ -296,9 +392,15 @@ private async Task DisableEntryAction() IsModifying = false; } + /// + /// Gets the command to add a new entry. + /// public ICommand AddEntryCommand => new RelayCommand(_ => AddEntryAction().ConfigureAwait(false), ModifyEntry_CanExecute); + /// + /// Action to add a new entry. + /// private async Task AddEntryAction() { IsModifying = true; @@ -327,7 +429,7 @@ private async Task AddEntryAction() { childWindow.IsOpen = false; ConfigurationManager.Current.IsChildWindowOpen = false; - + IsModifying = false; }); @@ -340,9 +442,15 @@ private async Task AddEntryAction() await (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow); } + /// + /// Gets the command to edit the selected entry. + /// public ICommand EditEntryCommand => new RelayCommand(_ => EditEntryAction().ConfigureAwait(false), ModifyEntry_CanExecute); + /// + /// Action to edit the selected entry. + /// private async Task EditEntryAction() { IsModifying = true; @@ -384,9 +492,15 @@ private async Task EditEntryAction() await (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow); } + /// + /// Gets the command to delete the selected entry. + /// public ICommand DeleteEntryCommand => new RelayCommand(_ => DeleteEntryAction().ConfigureAwait(false), ModifyEntry_CanExecute); + /// + /// Action to delete the selected entry. + /// private async Task DeleteEntryAction() { IsModifying = true; @@ -415,6 +529,9 @@ private async Task DeleteEntryAction() IsModifying = false; } + /// + /// Checks if the entry modification commands can be executed. + /// private bool ModifyEntry_CanExecute(object obj) { return ConfigurationManager.Current.IsAdmin && @@ -425,6 +542,10 @@ private bool ModifyEntry_CanExecute(object obj) !IsModifying; } + /// + /// Shows an error message for the given result. + /// + /// The result of the modification. private async Task ShowErrorMessageAsync(HostsFileEntryModifyResult result) { var message = result switch @@ -453,8 +574,14 @@ private async Task ShowErrorMessageAsync(HostsFileEntryModifyResult result) await (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow); } + /// + /// Gets the command to restart the application as administrator. + /// public ICommand RestartAsAdminCommand => new RelayCommand(_ => RestartAsAdminAction().ConfigureAwait(false)); + /// + /// Action to restart the application as administrator. + /// private async Task RestartAsAdminAction() { try @@ -485,6 +612,10 @@ private async Task RestartAsAdminAction() #region Methods + /// + /// Refreshes the hosts file entries. + /// + /// Indicates whether this is the initial refresh. private async Task Refresh(bool init = false) { if (IsRefreshing) @@ -534,10 +665,16 @@ private async Task Refresh(bool init = false) IsRefreshing = false; } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { } diff --git a/Source/NETworkManager/ViewModels/IPAddressAndSubnetmaskViewModel.cs b/Source/NETworkManager/ViewModels/IPAddressAndSubnetmaskViewModel.cs index 8f728e8d61..b43336f7c3 100644 --- a/Source/NETworkManager/ViewModels/IPAddressAndSubnetmaskViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPAddressAndSubnetmaskViewModel.cs @@ -4,12 +4,26 @@ namespace NETworkManager.ViewModels; +/// +/// View model for an IP address and a subnet mask. +/// public class IPAddressAndSubnetmaskViewModel : ViewModelBase { + /// + /// Backing field for . + /// private string _ipAddress; + /// + /// Backing field for . + /// private string _subnetmask; + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when OK is clicked. + /// The action to execute when Cancel is clicked. public IPAddressAndSubnetmaskViewModel(Action okCommand, Action cancelHandler) { @@ -17,10 +31,19 @@ public IPAddressAndSubnetmaskViewModel(Action o CancelCommand = new RelayCommand(_ => cancelHandler(this)); } + /// + /// Gets the command to confirm the operation. + /// public ICommand OKCommand { get; } + /// + /// Gets the command to cancel the operation. + /// public ICommand CancelCommand { get; } + /// + /// Gets or sets the IP address. + /// public string IPAddress { get => _ipAddress; @@ -34,6 +57,9 @@ public string IPAddress } } + /// + /// Gets or sets the subnet mask. + /// public string Subnetmask { get => _subnetmask; diff --git a/Source/NETworkManager/ViewModels/IPAddressViewModel.cs b/Source/NETworkManager/ViewModels/IPAddressViewModel.cs index 22e7bd4b69..eaf52d7f75 100644 --- a/Source/NETworkManager/ViewModels/IPAddressViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPAddressViewModel.cs @@ -4,20 +4,40 @@ namespace NETworkManager.ViewModels; +/// +/// View model for an IP address. +/// public abstract class IPAddressViewModel : ViewModelBase { + /// + /// Backing field for . + /// private string _ipAddress; + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when OK is clicked. + /// The action to execute when Cancel is clicked. protected IPAddressViewModel(Action okCommand, Action cancelHandler) { OKCommand = new RelayCommand(_ => okCommand(this)); CancelCommand = new RelayCommand(_ => cancelHandler(this)); } + /// + /// Gets the command to confirm the operation. + /// public ICommand OKCommand { get; } + /// + /// Gets the command to cancel the operation. + /// public ICommand CancelCommand { get; } + /// + /// Gets or sets the IP address. + /// public string IPAddress { get => _ipAddress; diff --git a/Source/NETworkManager/ViewModels/IPApiDNSResolverWidgetViewModel.cs b/Source/NETworkManager/ViewModels/IPApiDNSResolverWidgetViewModel.cs index b74e8319ae..1e7a56743d 100644 --- a/Source/NETworkManager/ViewModels/IPApiDNSResolverWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPApiDNSResolverWidgetViewModel.cs @@ -6,12 +6,21 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the IP API DNS resolver widget. +/// public class IPApiDNSResolverWidgetViewModel : ViewModelBase { #region Variables + /// + /// Backing field for . + /// private bool _isRunning; + /// + /// Gets or sets a value indicating whether the check is running. + /// public bool IsRunning { get => _isRunning; @@ -25,8 +34,14 @@ public bool IsRunning } } + /// + /// Backing field for . + /// private DNSResolverResult _result; + /// + /// Gets the result of the DNS resolver check. + /// public DNSResolverResult Result { get => _result; @@ -44,11 +59,17 @@ private set #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public IPApiDNSResolverWidgetViewModel() { LoadSettings(); } + /// + /// Loads the settings. + /// private void LoadSettings() { @@ -58,8 +79,14 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to check via hotkey. + /// public ICommand CheckViaHotkeyCommand => new RelayCommand(_ => CheckViaHotkeyAction()); + /// + /// Action to check via hotkey. + /// private void CheckViaHotkeyAction() { Check(); @@ -69,11 +96,17 @@ private void CheckViaHotkeyAction() #region Methods + /// + /// Checks the DNS resolver. + /// public void Check() { CheckAsync().ConfigureAwait(false); } + /// + /// Checks the DNS resolver asynchronously. + /// private async Task CheckAsync() { // Check is disabled via settings diff --git a/Source/NETworkManager/ViewModels/IPApiIPGeolocationWidgetViewModel.cs b/Source/NETworkManager/ViewModels/IPApiIPGeolocationWidgetViewModel.cs index 144f0ebd79..15ab8359dc 100644 --- a/Source/NETworkManager/ViewModels/IPApiIPGeolocationWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPApiIPGeolocationWidgetViewModel.cs @@ -7,14 +7,23 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the IP API IP geolocation widget. +/// public class IPApiIPGeolocationWidgetViewModel : ViewModelBase { #region Variables private static readonly ILog Log = LogManager.GetLogger(typeof(IPApiIPGeolocationWidgetViewModel)); + /// + /// Backing field for . + /// private bool _isRunning; + /// + /// Gets or sets a value indicating whether the check is running. + /// public bool IsRunning { get => _isRunning; @@ -28,8 +37,14 @@ public bool IsRunning } } + /// + /// Backing field for . + /// private IPGeolocationResult _result; + /// + /// Gets the result of the IP geolocation check. + /// public IPGeolocationResult Result { get => _result; @@ -47,11 +62,17 @@ private set #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public IPApiIPGeolocationWidgetViewModel() { LoadSettings(); } + /// + /// Loads the settings. + /// private void LoadSettings() { } @@ -60,8 +81,14 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to check via hotkey. + /// public ICommand CheckViaHotkeyCommand => new RelayCommand(_ => CheckViaHotkeyAction()); + /// + /// Action to check via hotkey. + /// private void CheckViaHotkeyAction() { Check(); @@ -71,11 +98,17 @@ private void CheckViaHotkeyAction() #region Methods + /// + /// Checks the IP geolocation. + /// public void Check() { CheckAsync().ConfigureAwait(false); } + /// + /// Checks the IP geolocation asynchronously. + /// private async Task CheckAsync() { // Check is disabled via settings diff --git a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs index a4e7052124..7f4fdc19f0 100644 --- a/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPGeolocationHostViewModel.cs @@ -19,6 +19,9 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the IP geolocation host view. +/// public class IPGeolocationHostViewModel : ViewModelBase, IProfileManager { #region Variables @@ -26,10 +29,19 @@ public class IPGeolocationHostViewModel : ViewModelBase, IProfileManager private readonly DispatcherTimer _searchDispatcherTimer = new(); private bool _searchDisabled; + /// + /// Gets the client for inter-tab operations. + /// public IInterTabClient InterTabClient { get; } + /// + /// Backing field for . + /// private string _interTabPartition; + /// + /// Gets or sets the inter-tab partition key. + /// public string InterTabPartition { get => _interTabPartition; @@ -43,13 +55,22 @@ public string InterTabPartition } } + /// + /// Gets the collection of tab items. + /// public ObservableCollection TabItems { get; } private readonly bool _isLoading; private bool _isViewActive = true; + /// + /// Backing field for . + /// private int _selectedTabIndex; + /// + /// Gets or sets the index of the selected tab. + /// public int SelectedTabIndex { get => _selectedTabIndex; @@ -65,8 +86,14 @@ public int SelectedTabIndex #region Profiles + /// + /// Backing field for . + /// private ICollectionView _profiles; + /// + /// Gets the collection view of profiles. + /// public ICollectionView Profiles { get => _profiles; @@ -80,8 +107,14 @@ private set } } + /// + /// Backing field for . + /// private ProfileInfo _selectedProfile = new(); + /// + /// Gets or sets the selected profile. + /// public ProfileInfo SelectedProfile { get => _selectedProfile; @@ -95,8 +128,14 @@ public ProfileInfo SelectedProfile } } + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -118,8 +157,14 @@ public string Search } } + /// + /// Backing field for . + /// private bool _isSearching; + /// + /// Gets or sets a value indicating whether a search is in progress. + /// public bool IsSearching { get => _isSearching; @@ -133,8 +178,14 @@ public bool IsSearching } } + /// + /// Backing field for . + /// private bool _profileFilterIsOpen; + /// + /// Gets or sets a value indicating whether the profile filter is open. + /// public bool ProfileFilterIsOpen { get => _profileFilterIsOpen; @@ -148,12 +199,24 @@ public bool ProfileFilterIsOpen } } + /// + /// Gets the collection view for profile filter tags. + /// public ICollectionView ProfileFilterTagsView { get; } + /// + /// Gets the collection of profile filter tags. + /// private ObservableCollection ProfileFilterTags { get; } = []; + /// + /// Backing field for . + /// private bool _profileFilterTagsMatchAny = GlobalStaticConfiguration.Profile_TagsMatchAny; + /// + /// Gets or sets a value indicating whether any tag match is sufficient for filtering. + /// public bool ProfileFilterTagsMatchAny { get => _profileFilterTagsMatchAny; @@ -167,8 +230,14 @@ public bool ProfileFilterTagsMatchAny } } + /// + /// Backing field for . + /// private bool _profileFilterTagsMatchAll; + /// + /// Gets or sets a value indicating whether all tags must match for filtering. + /// public bool ProfileFilterTagsMatchAll { get => _profileFilterTagsMatchAll; @@ -182,8 +251,14 @@ public bool ProfileFilterTagsMatchAll } } + /// + /// Backing field for . + /// private bool _isProfileFilterSet; + /// + /// Gets or sets a value indicating whether a profile filter is set. + /// public bool IsProfileFilterSet { get => _isProfileFilterSet; @@ -203,8 +278,14 @@ public bool IsProfileFilterSet private bool _canProfileWidthChange = true; private double _tempProfileWidth; + /// + /// Backing field for . + /// private bool _expandProfileView; + /// + /// Gets or sets a value indicating whether the profile view is expanded. + /// public bool ExpandProfileView { get => _expandProfileView; @@ -225,8 +306,14 @@ public bool ExpandProfileView } } + /// + /// Backing field for . + /// private GridLength _profileWidth; + /// + /// Gets or sets the width of the profile view. + /// public GridLength ProfileWidth { get => _profileWidth; @@ -254,6 +341,9 @@ public GridLength ProfileWidth #region Constructor + /// + /// Initializes a new instance of the class. + /// public IPGeolocationHostViewModel() { _isLoading = true; @@ -287,6 +377,9 @@ public IPGeolocationHostViewModel() _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { ExpandProfileView = SettingsManager.Current.IPGeolocation_ExpandProfileView; @@ -302,27 +395,48 @@ private void LoadSettings() #region ICommand & Actions + /// + /// Gets the command to add a new tab. + /// public ICommand AddTabCommand => new RelayCommand(_ => AddTabAction()); + /// + /// Action to add a new tab. + /// private void AddTabAction() { AddTab(); } + /// + /// Gets the command to query the selected profile. + /// public ICommand QueryProfileCommand => new RelayCommand(_ => QueryProfileAction(), QueryProfile_CanExecute); + /// + /// Checks if the query profile command can be executed. + /// private bool QueryProfile_CanExecute(object obj) { return !IsSearching && SelectedProfile != null; } + /// + /// Action to query the selected profile. + /// private void QueryProfileAction() { AddTab(SelectedProfile.IPGeolocation_Host); } + /// + /// Gets the command to add a new profile. + /// public ICommand AddProfileCommand => new RelayCommand(_ => AddProfileAction()); + /// + /// Action to add a new profile. + /// private void AddProfileAction() { ProfileDialogManager @@ -330,29 +444,50 @@ private void AddProfileAction() .ConfigureAwait(false); } + /// + /// Checks if the profile modification commands can be executed. + /// private bool ModifyProfile_CanExecute(object obj) { return SelectedProfile is { IsDynamic: false }; } + /// + /// Gets the command to edit the selected profile. + /// public ICommand EditProfileCommand => new RelayCommand(_ => EditProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to edit the selected profile. + /// private void EditProfileAction() { ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile) .ConfigureAwait(false); } + /// + /// Gets the command to copy the selected profile as a new profile. + /// public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to copy the selected profile as a new profile. + /// private void CopyAsProfileAction() { ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow, this, SelectedProfile) .ConfigureAwait(false); } + /// + /// Gets the command to delete the selected profile. + /// public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to delete the selected profile. + /// private void DeleteProfileAction() { ProfileDialogManager @@ -360,8 +495,14 @@ private void DeleteProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to edit a profile group. + /// public ICommand EditGroupCommand => new RelayCommand(EditGroupAction); + /// + /// Action to edit a profile group. + /// private void EditGroupAction(object group) { ProfileDialogManager @@ -369,15 +510,27 @@ private void EditGroupAction(object group) .ConfigureAwait(false); } + /// + /// Gets the command to open the profile filter. + /// public ICommand OpenProfileFilterCommand => new RelayCommand(_ => OpenProfileFilterAction()); + /// + /// Action to open the profile filter. + /// private void OpenProfileFilterAction() { ProfileFilterIsOpen = true; } + /// + /// Gets the command to apply the profile filter. + /// public ICommand ApplyProfileFilterCommand => new RelayCommand(_ => ApplyProfileFilterAction()); + /// + /// Action to apply the profile filter. + /// private void ApplyProfileFilterAction() { RefreshProfiles(); @@ -385,8 +538,14 @@ private void ApplyProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to clear the profile filter. + /// public ICommand ClearProfileFilterCommand => new RelayCommand(_ => ClearProfileFilterAction()); + /// + /// Action to clear the profile filter. + /// private void ClearProfileFilterAction() { _searchDisabled = true; @@ -402,22 +561,40 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to expand all profile groups. + /// public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + /// + /// Action to expand all profile groups. + /// private void ExpandAllProfileGroupsAction() { SetIsExpandedForAllProfileGroups(true); } + /// + /// Gets the command to collapse all profile groups. + /// public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + /// + /// Action to collapse all profile groups. + /// private void CollapseAllProfileGroupsAction() { SetIsExpandedForAllProfileGroups(false); } - + + /// + /// Gets the callback for closing a tab item. + /// public ItemActionCallback CloseItemCommand => CloseItemAction; + /// + /// Action to close a tab item. + /// private static void CloseItemAction(ItemActionCallbackArgs args) { ((args.DragablzItem.Content as DragablzTabItem)?.View as IPGeolocationView)?.CloseTab(); @@ -427,12 +604,20 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #region Methods + /// + /// Sets the IsExpanded property for all profile groups. + /// + /// The value to set. private void SetIsExpandedForAllProfileGroups(bool isExpanded) { foreach (var group in Profiles.Groups.Cast()) GroupExpanderStateStore[group.Name.ToString()] = isExpanded; } - + + /// + /// Resizes the profile view. + /// + /// Indicates whether the resize is due to a size change. private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; @@ -462,6 +647,10 @@ private void ResizeProfile(bool dueToChangedSize) _canProfileWidthChange = true; } + /// + /// Adds a new tab for the specified domain. + /// + /// The domain to query. private void AddTab(string domain = null) { var tabId = Guid.NewGuid(); @@ -472,6 +661,9 @@ private void AddTab(string domain = null) SelectedTabIndex = TabItems.Count - 1; } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { _isViewActive = true; @@ -479,11 +671,17 @@ public void OnViewVisible() RefreshProfiles(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { _isViewActive = false; } + /// + /// Creates the profile filter tags. + /// private void CreateTags() { var tags = ProfileManager.Groups.SelectMany(x => x.Profiles).Where(x => x.IPGeolocation_Enabled) @@ -505,6 +703,11 @@ private void CreateTags() } } + /// + /// Sets the profiles view with the specified filter. + /// + /// The profile filter. + /// The profile to select. private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = null) { Profiles = new CollectionViewSource @@ -536,6 +739,9 @@ private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = nul SelectedProfile = Profiles.Cast().FirstOrDefault(); } + /// + /// Refreshes the profiles. + /// private void RefreshProfiles() { if (!_isViewActive) @@ -557,6 +763,9 @@ private void RefreshProfiles() #region Event + /// + /// Handles the OnProfilesUpdated event of the ProfileManager. + /// private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e) { CreateTags(); @@ -564,6 +773,9 @@ private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e) RefreshProfiles(); } + /// + /// Handles the Tick event of the search dispatcher timer. + /// private void SearchDispatcherTimer_Tick(object sender, EventArgs e) { _searchDispatcherTimer.Stop(); diff --git a/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs b/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs index 518249ea9e..8538ce7c66 100644 --- a/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPGeolocationViewModel.cs @@ -19,20 +19,32 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the IP geolocation view. +/// public class IPGeolocationViewModel : ViewModelBase { #region Variables private static readonly ILog Log = LogManager.GetLogger(typeof(IPGeolocationViewModel)); + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; private readonly Guid _tabId; private bool _firstLoad = true; private bool _closed; + /// + /// Backing field for . + /// private string _host; + /// + /// Gets or sets the host to query. + /// public string Host { get => _host; @@ -46,10 +58,19 @@ public string Host } } + /// + /// Gets the collection view of host history. + /// public ICollectionView HostHistoryView { get; } + /// + /// Backing field for . + /// private bool _isRunning; + /// + /// Gets or sets a value indicating whether the query is running. + /// public bool IsRunning { get => _isRunning; @@ -63,8 +84,14 @@ public bool IsRunning } } + /// + /// Backing field for . + /// private bool _isResultVisible; + /// + /// Gets or sets a value indicating whether the result is visible. + /// public bool IsResultVisible { get => _isResultVisible; @@ -78,8 +105,14 @@ public bool IsResultVisible } } + /// + /// Backing field for . + /// private IPGeolocationInfo _result; + /// + /// Gets the IP geolocation result. + /// public IPGeolocationInfo Result { get => _result; @@ -93,8 +126,14 @@ private set } } + /// + /// Backing field for . + /// private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -108,8 +147,14 @@ public bool IsStatusMessageDisplayed } } + /// + /// Backing field for . + /// private string _statusMessage; + /// + /// Gets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -127,6 +172,12 @@ private set #region Contructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. + /// The ID of the tab. + /// The host to query. public IPGeolocationViewModel(IDialogCoordinator instance, Guid tabId, string host) { _dialogCoordinator = instance; @@ -142,6 +193,9 @@ public IPGeolocationViewModel(IDialogCoordinator instance, Guid tabId, string ho LoadSettings(); } + /// + /// Called when the view is loaded. + /// public void OnLoaded() { if (!_firstLoad) @@ -153,6 +207,9 @@ public void OnLoaded() _firstLoad = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { } @@ -161,8 +218,16 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to start the query. + /// public ICommand QueryCommand => new RelayCommand(_ => QueryAction(), Query_CanExecute); + /// + /// Checks if the query command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool Query_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -170,13 +235,22 @@ private bool Query_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Action to start the query. + /// private void QueryAction() { Query().ConfigureAwait(false); } + /// + /// Gets the command to export the result. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction()); + /// + /// Action to export the result. + /// private void ExportAction() { Export().ConfigureAwait(false); @@ -186,6 +260,9 @@ private void ExportAction() #region Methods + /// + /// Performs the IP geolocation query. + /// private async Task Query() { IsStatusMessageDisplayed = false; @@ -235,6 +312,9 @@ private async Task Query() IsRunning = false; } + /// + /// Exports the result. + /// private Task Export() { var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive); @@ -283,6 +363,9 @@ await _dialogCoordinator.ShowMessageAsync(window, Strings.Error, return window.ShowChildWindowAsync(childWindow); } + /// + /// Called when the view is closed. + /// public void OnClose() { // Prevent multiple calls @@ -294,6 +377,10 @@ public void OnClose() ConfigurationManager.Current.IPGeolocationTabCount--; } + /// + /// Adds the host to the history. + /// + /// The host to add. private void AddHostToHistory(string host) { // Create the new list diff --git a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs index 77ae93cb3c..6952823984 100644 --- a/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerHostViewModel.cs @@ -19,6 +19,9 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the IP scanner host view. +/// public class IPScannerHostViewModel : ViewModelBase, IProfileManager { #region Variables @@ -26,10 +29,19 @@ public class IPScannerHostViewModel : ViewModelBase, IProfileManager private readonly DispatcherTimer _searchDispatcherTimer = new(); private bool _searchDisabled; + /// + /// Gets the client for inter-tab operations. + /// public IInterTabClient InterTabClient { get; } + /// + /// Backing field for . + /// private string _interTabPartition; + /// + /// Gets or sets the inter-tab partition key. + /// public string InterTabPartition { get => _interTabPartition; @@ -43,13 +55,22 @@ public string InterTabPartition } } + /// + /// Gets the collection of tab items. + /// public ObservableCollection TabItems { get; } private readonly bool _isLoading; private bool _isViewActive = true; + /// + /// Backing field for . + /// private int _selectedTabIndex; + /// + /// Gets or sets the index of the selected tab. + /// public int SelectedTabIndex { get => _selectedTabIndex; @@ -65,8 +86,14 @@ public int SelectedTabIndex #region Profiles + /// + /// Backing field for . + /// private ICollectionView _profiles; + /// + /// Gets the collection view of profiles. + /// public ICollectionView Profiles { get => _profiles; @@ -80,8 +107,14 @@ private set } } + /// + /// Backing field for . + /// private ProfileInfo _selectedProfile = new(); + /// + /// Gets or sets the selected profile. + /// public ProfileInfo SelectedProfile { get => _selectedProfile; @@ -95,8 +128,14 @@ public ProfileInfo SelectedProfile } } + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -118,8 +157,14 @@ public string Search } } + /// + /// Backing field for . + /// private bool _isSearching; + /// + /// Gets or sets a value indicating whether a search is in progress. + /// public bool IsSearching { get => _isSearching; @@ -133,8 +178,14 @@ public bool IsSearching } } + /// + /// Backing field for . + /// private bool _profileFilterIsOpen; + /// + /// Gets or sets a value indicating whether the profile filter is open. + /// public bool ProfileFilterIsOpen { get => _profileFilterIsOpen; @@ -148,12 +199,24 @@ public bool ProfileFilterIsOpen } } + /// + /// Gets the collection view for profile filter tags. + /// public ICollectionView ProfileFilterTagsView { get; } + /// + /// Gets the collection of profile filter tags. + /// private ObservableCollection ProfileFilterTags { get; } = []; + /// + /// Backing field for . + /// private bool _profileFilterTagsMatchAny = GlobalStaticConfiguration.Profile_TagsMatchAny; + /// + /// Gets or sets a value indicating whether any tag match is sufficient for filtering. + /// public bool ProfileFilterTagsMatchAny { get => _profileFilterTagsMatchAny; @@ -167,8 +230,14 @@ public bool ProfileFilterTagsMatchAny } } + /// + /// Backing field for . + /// private bool _profileFilterTagsMatchAll; + /// + /// Gets or sets a value indicating whether all tags must match for filtering. + /// public bool ProfileFilterTagsMatchAll { get => _profileFilterTagsMatchAll; @@ -182,8 +251,14 @@ public bool ProfileFilterTagsMatchAll } } + /// + /// Backing field for . + /// private bool _isProfileFilterSet; + /// + /// Gets or sets a value indicating whether a profile filter is set. + /// public bool IsProfileFilterSet { get => _isProfileFilterSet; @@ -203,8 +278,14 @@ public bool IsProfileFilterSet private bool _canProfileWidthChange = true; private double _tempProfileWidth; + /// + /// Backing field for . + /// private bool _expandProfileView; + /// + /// Gets or sets a value indicating whether the profile view is expanded. + /// public bool ExpandProfileView { get => _expandProfileView; @@ -225,8 +306,14 @@ public bool ExpandProfileView } } + /// + /// Backing field for . + /// private GridLength _profileWidth; + /// + /// Gets or sets the width of the profile view. + /// public GridLength ProfileWidth { get => _profileWidth; @@ -254,6 +341,9 @@ public GridLength ProfileWidth #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public IPScannerHostViewModel() { _isLoading = true; @@ -287,6 +377,9 @@ public IPScannerHostViewModel() _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { ExpandProfileView = SettingsManager.Current.IPScanner_ExpandProfileView; @@ -302,27 +395,48 @@ private void LoadSettings() #region ICommand & Actions + /// + /// Gets the command to add a new tab. + /// public ICommand AddTabCommand => new RelayCommand(_ => AddTabAction()); + /// + /// Action to add a new tab. + /// private void AddTabAction() { AddTab(); } + /// + /// Gets the command to scan the selected profile. + /// public ICommand ScanProfileCommand => new RelayCommand(_ => ScanProfileAction(), ScanProfile_CanExecute); + /// + /// Checks if the scan profile command can be executed. + /// private bool ScanProfile_CanExecute(object obj) { return !IsSearching && SelectedProfile != null; } + /// + /// Action to scan the selected profile. + /// private void ScanProfileAction() { AddTab(SelectedProfile); } + /// + /// Gets the command to add a new profile. + /// public ICommand AddProfileCommand => new RelayCommand(_ => AddProfileAction()); + /// + /// Action to add a new profile. + /// private void AddProfileAction() { ProfileDialogManager @@ -330,29 +444,50 @@ private void AddProfileAction() .ConfigureAwait(false); } + /// + /// Checks if the profile modification commands can be executed. + /// private bool ModifyProfile_CanExecute(object obj) { return SelectedProfile is { IsDynamic: false }; } + /// + /// Gets the command to edit the selected profile. + /// public ICommand EditProfileCommand => new RelayCommand(_ => EditProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to edit the selected profile. + /// private void EditProfileAction() { ProfileDialogManager.ShowEditProfileDialog(Application.Current.MainWindow, this, SelectedProfile) .ConfigureAwait(false); } + /// + /// Gets the command to copy the selected profile as a new profile. + /// public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to copy the selected profile as a new profile. + /// private void CopyAsProfileAction() { ProfileDialogManager.ShowCopyAsProfileDialog(Application.Current.MainWindow, this, SelectedProfile) .ConfigureAwait(false); } + /// + /// Gets the command to delete the selected profile. + /// public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute); + /// + /// Action to delete the selected profile. + /// private void DeleteProfileAction() { ProfileDialogManager @@ -360,8 +495,14 @@ private void DeleteProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to edit a profile group. + /// public ICommand EditGroupCommand => new RelayCommand(EditGroupAction); + /// + /// Action to edit a profile group. + /// private void EditGroupAction(object group) { ProfileDialogManager @@ -369,15 +510,27 @@ private void EditGroupAction(object group) .ConfigureAwait(false); } + /// + /// Gets the command to open the profile filter. + /// public ICommand OpenProfileFilterCommand => new RelayCommand(_ => OpenProfileFilterAction()); + /// + /// Action to open the profile filter. + /// private void OpenProfileFilterAction() { ProfileFilterIsOpen = true; } + /// + /// Gets the command to apply the profile filter. + /// public ICommand ApplyProfileFilterCommand => new RelayCommand(_ => ApplyProfileFilterAction()); + /// + /// Action to apply the profile filter. + /// private void ApplyProfileFilterAction() { RefreshProfiles(); @@ -385,8 +538,14 @@ private void ApplyProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to clear the profile filter. + /// public ICommand ClearProfileFilterCommand => new RelayCommand(_ => ClearProfileFilterAction()); + /// + /// Action to clear the profile filter. + /// private void ClearProfileFilterAction() { _searchDisabled = true; @@ -401,23 +560,41 @@ private void ClearProfileFilterAction() IsProfileFilterSet = false; ProfileFilterIsOpen = false; } - + + /// + /// Gets the command to expand all profile groups. + /// public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); + /// + /// Action to expand all profile groups. + /// private void ExpandAllProfileGroupsAction() { SetIsExpandedForAllProfileGroups(true); } + /// + /// Gets the command to collapse all profile groups. + /// public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); + /// + /// Action to collapse all profile groups. + /// private void CollapseAllProfileGroupsAction() { SetIsExpandedForAllProfileGroups(false); } + /// + /// Gets the callback for closing a tab item. + /// public ItemActionCallback CloseItemCommand => CloseItemAction; + /// + /// Action to close a tab item. + /// private static void CloseItemAction(ItemActionCallbackArgs args) { ((args.DragablzItem.Content as DragablzTabItem)?.View as IPScannerView)?.CloseTab(); @@ -427,12 +604,20 @@ private static void CloseItemAction(ItemActionCallbackArgs args) #region Methods + /// + /// Sets the IsExpanded property for all profile groups. + /// + /// The value to set. private void SetIsExpandedForAllProfileGroups(bool isExpanded) { foreach (var group in Profiles.Groups.Cast()) GroupExpanderStateStore[group.Name.ToString()] = isExpanded; } - + + /// + /// Resizes the profile view. + /// + /// Indicates whether the resize is due to a size change. private void ResizeProfile(bool dueToChangedSize) { _canProfileWidthChange = false; @@ -462,6 +647,10 @@ private void ResizeProfile(bool dueToChangedSize) _canProfileWidthChange = true; } + /// + /// Adds a new tab for the specified host or IP range. + /// + /// The host or IP range to scan. public void AddTab(string hostOrIPRange = null) { var tabId = Guid.NewGuid(); @@ -472,11 +661,18 @@ public void AddTab(string hostOrIPRange = null) SelectedTabIndex = TabItems.Count - 1; } + /// + /// Adds a new tab for the specified profile. + /// + /// The profile to scan. private void AddTab(ProfileInfo profile) { AddTab(profile.IPScanner_HostOrIPRange); } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { _isViewActive = true; @@ -484,11 +680,17 @@ public void OnViewVisible() RefreshProfiles(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { _isViewActive = false; } + /// + /// Creates the profile filter tags. + /// private void CreateTags() { var tags = ProfileManager.Groups.SelectMany(x => x.Profiles).Where(x => x.IPScanner_Enabled) @@ -510,6 +712,11 @@ private void CreateTags() } } + /// + /// Sets the profiles view with the specified filter. + /// + /// The profile filter. + /// The profile to select. private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = null) { Profiles = new CollectionViewSource @@ -541,6 +748,9 @@ private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = nul SelectedProfile = Profiles.Cast().FirstOrDefault(); } + /// + /// Refreshes the profiles. + /// private void RefreshProfiles() { if (!_isViewActive) @@ -562,6 +772,9 @@ private void RefreshProfiles() #region Event + /// + /// Handles the OnProfilesUpdated event of the ProfileManager. + /// private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e) { CreateTags(); @@ -569,6 +782,9 @@ private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e) RefreshProfiles(); } + /// + /// Handles the Tick event of the search dispatcher timer. + /// private void SearchDispatcherTimer_Tick(object sender, EventArgs e) { _searchDispatcherTimer.Stop(); diff --git a/Source/NETworkManager/ViewModels/IPScannerSettingsViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerSettingsViewModel.cs index 9c8095bd90..b60ed88f02 100644 --- a/Source/NETworkManager/ViewModels/IPScannerSettingsViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerSettingsViewModel.cs @@ -12,16 +12,31 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the IP scanner settings. +/// public class IPScannerSettingsViewModel : ViewModelBase { #region Variables + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Backing field for . + /// private bool _showAllResults; + /// + /// Gets or sets a value indicating whether to show all results. + /// public bool ShowAllResults { get => _showAllResults; @@ -38,8 +53,14 @@ public bool ShowAllResults } } + /// + /// Backing field for . + /// private int _icmpAttempts; + /// + /// Gets or sets the number of ICMP attempts. + /// public int ICMPAttempts { get => _icmpAttempts; @@ -56,8 +77,14 @@ public int ICMPAttempts } } + /// + /// Backing field for . + /// private int _icmpTimeout; + /// + /// Gets or sets the ICMP timeout in milliseconds. + /// public int ICMPTimeout { get => _icmpTimeout; @@ -74,8 +101,14 @@ public int ICMPTimeout } } + /// + /// Backing field for . + /// private int _icmpBuffer; + /// + /// Gets or sets the ICMP buffer size. + /// public int ICMPBuffer { get => _icmpBuffer; @@ -92,8 +125,14 @@ public int ICMPBuffer } } + /// + /// Backing field for . + /// private bool _resolveHostname; + /// + /// Gets or sets a value indicating whether to resolve the hostname. + /// public bool ResolveHostname { get => _resolveHostname; @@ -110,8 +149,14 @@ public bool ResolveHostname } } + /// + /// Backing field for . + /// private bool _portScanEnabled; + /// + /// Gets or sets a value indicating whether port scanning is enabled. + /// public bool PortScanEnabled { get => _portScanEnabled; @@ -128,8 +173,14 @@ public bool PortScanEnabled } } + /// + /// Backing field for . + /// private string _portScanPorts; + /// + /// Gets or sets the ports to scan. + /// public string PortScanPorts { get => _portScanPorts; @@ -146,13 +197,17 @@ public string PortScanPorts } } + /// + /// Backing field for . + /// private int _portScanTimeout; + /// + /// Gets or sets the port scan timeout in milliseconds. + /// public int PortScanTimeout - { get => _portScanTimeout; - set { if (value == _portScanTimeout) @@ -166,8 +221,14 @@ public int PortScanTimeout } } + /// + /// Backing field for . + /// private bool _netBIOSEnabled; + /// + /// Gets or sets a value indicating whether NetBIOS is enabled. + /// public bool NetBIOSEnabled { get => _netBIOSEnabled; @@ -184,8 +245,14 @@ public bool NetBIOSEnabled } } + /// + /// Backing field for . + /// private int _netBIOSTimeout; + /// + /// Gets or sets the NetBIOS timeout in milliseconds. + /// public int NetBIOSTimeout { get => _netBIOSTimeout; @@ -202,8 +269,14 @@ public int NetBIOSTimeout } } + /// + /// Backing field for . + /// private bool _resolveMACAddress; + /// + /// Gets or sets a value indicating whether to resolve the MAC address. + /// public bool ResolveMACAddress { get => _resolveMACAddress; @@ -220,10 +293,19 @@ public bool ResolveMACAddress } } + /// + /// Gets the collection view of custom commands. + /// public ICollectionView CustomCommands { get; } + /// + /// Backing field for . + /// private CustomCommandInfo _selectedCustomCommand = new(); + /// + /// Gets or sets the selected custom command. + /// public CustomCommandInfo SelectedCustomCommand { get => _selectedCustomCommand; @@ -237,8 +319,14 @@ public CustomCommandInfo SelectedCustomCommand } } + /// + /// Backing field for . + /// private int _maxHostThreads; + /// + /// Gets or sets the maximum number of host threads. + /// public int MaxHostThreads { get => _maxHostThreads; @@ -255,8 +343,14 @@ public int MaxHostThreads } } + /// + /// Backing field for . + /// private int _maxPortThreads; + /// + /// Gets or sets the maximum number of port threads. + /// public int MaxPortThreads { get => _maxPortThreads; @@ -277,6 +371,10 @@ public int MaxPortThreads #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public IPScannerSettingsViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -292,6 +390,9 @@ public IPScannerSettingsViewModel(IDialogCoordinator instance) _isLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { ShowAllResults = SettingsManager.Current.IPScanner_ShowAllResults; @@ -313,22 +414,40 @@ private void LoadSettings() #region ICommand & Actions + /// + /// Gets the command to add a custom command. + /// public ICommand AddCustomCommandCommand => new RelayCommand(_ => AddCustomCommandAction()); + /// + /// Action to add a custom command. + /// private void AddCustomCommandAction() { AddCustomCommand(); } + /// + /// Gets the command to edit a custom command. + /// public ICommand EditCustomCommandCommand => new RelayCommand(_ => EditCustomCommandAction()); + /// + /// Action to edit a custom command. + /// private void EditCustomCommandAction() { EditCustomCommand(); } + /// + /// Gets the command to delete a custom command. + /// public ICommand DeleteCustomCommandCommand => new RelayCommand(_ => DeleteCustomCommandAction()); + /// + /// Action to delete a custom command. + /// private void DeleteCustomCommandAction() { DeleteCustomCommand().ConfigureAwait(false); @@ -338,6 +457,9 @@ private void DeleteCustomCommandAction() #region Methods + /// + /// Adds a new custom command. + /// private async void AddCustomCommand() { var customDialog = new CustomDialog @@ -361,6 +483,9 @@ private async void AddCustomCommand() await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); } + /// + /// Edits the selected custom command. + /// public async void EditCustomCommand() { var customDialog = new CustomDialog @@ -385,6 +510,9 @@ public async void EditCustomCommand() await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); } + /// + /// Deletes the selected custom command. + /// private async Task DeleteCustomCommand() { var result = await DialogHelper.ShowOKCancelMessageAsync(Application.Current.MainWindow, diff --git a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs index 6cfa7841ed..a747ccb077 100644 --- a/Source/NETworkManager/ViewModels/IPScannerViewModel.cs +++ b/Source/NETworkManager/ViewModels/IPScannerViewModel.cs @@ -31,6 +31,9 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the IP Scanner feature. +/// public class IPScannerViewModel : ViewModelBase, IProfileManagerMinimal { #region Variables @@ -46,6 +49,9 @@ public class IPScannerViewModel : ViewModelBase, IProfileManagerMinimal private string _host; + /// + /// Gets or sets the host or IP range to scan. + /// public string Host { get => _host; @@ -59,10 +65,16 @@ public string Host } } + /// + /// Gets the collection view for the host history. + /// public ICollectionView HostHistoryView { get; } private bool _isSubnetDetectionRunning; + /// + /// Gets or sets a value indicating whether subnet detection is running. + /// public bool IsSubnetDetectionRunning { get => _isSubnetDetectionRunning; @@ -79,6 +91,9 @@ public bool IsSubnetDetectionRunning private bool _isRunning; + /// + /// Gets or sets a value indicating whether the scan is currently running. + /// public bool IsRunning { get => _isRunning; @@ -94,6 +109,9 @@ public bool IsRunning private bool _isCanceling; + /// + /// Gets or sets a value indicating whether the scan is being canceled. + /// public bool IsCanceling { get => _isCanceling; @@ -109,6 +127,9 @@ public bool IsCanceling private ObservableCollection _results = []; + /// + /// Gets or sets the collection of scan results. + /// public ObservableCollection Results { get => _results; @@ -121,10 +142,16 @@ public ObservableCollection Results } } + /// + /// Gets the collection view for the scan results. + /// public ICollectionView ResultsView { get; } private IPScannerHostInfo _selectedResult; + /// + /// Gets or sets the currently selected scan result. + /// public IPScannerHostInfo SelectedResult { get => _selectedResult; @@ -140,6 +167,9 @@ public IPScannerHostInfo SelectedResult private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of currently selected scan results (for multi-selection). + /// public IList SelectedResults { get => _selectedResults; @@ -155,6 +185,9 @@ public IList SelectedResults private int _hostsToScan; + /// + /// Gets or sets the total number of hosts to scan. + /// public int HostsToScan { get => _hostsToScan; @@ -170,6 +203,9 @@ public int HostsToScan private int _hostsScanned; + /// + /// Gets or sets the number of hosts already scanned. + /// public int HostsScanned { get => _hostsScanned; @@ -185,6 +221,9 @@ public int HostsScanned private bool _preparingScan; + /// + /// Gets or sets a value indicating whether the scan is being prepared. + /// public bool PreparingScan { get => _preparingScan; @@ -200,6 +239,9 @@ public bool PreparingScan private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -215,6 +257,9 @@ public bool IsStatusMessageDisplayed private string _statusMessage; + /// + /// Gets the status message to display. + /// public string StatusMessage { get => _statusMessage; @@ -228,12 +273,21 @@ private set } } + /// + /// Gets the available custom commands for the IP Scanner. + /// public static IEnumerable CustomCommands => SettingsManager.Current.IPScanner_CustomCommands; #endregion #region Constructor, load settings, shutdown + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. + /// The unique identifier for the tab. + /// The initial host or IP range to scan. public IPScannerViewModel(IDialogCoordinator instance, Guid tabId, string hostOrIPRange) { _dialogCoordinator = instance; @@ -254,6 +308,9 @@ public IPScannerViewModel(IDialogCoordinator instance, Guid tabId, string hostOr IPAddressHelper.CompareIPAddresses(x.PingInfo.IPAddress, y.PingInfo.IPAddress)); } + /// + /// Called when the view is loaded. Starts the scan if it's the first load and a host is specified. + /// public void OnLoaded() { if (!_firstLoad) @@ -269,6 +326,9 @@ public void OnLoaded() #region ICommands & Actions + /// + /// Gets the command to start or stop the scan. + /// public ICommand ScanCommand => new RelayCommand(_ => ScanAction(), Scan_CanExecute); private bool Scan_CanExecute(object parameter) @@ -286,6 +346,9 @@ private void ScanAction() Start().ConfigureAwait(false); } + /// + /// Gets the command to detect the local subnet. + /// public ICommand DetectSubnetCommand => new RelayCommand(_ => DetectSubnetAction()); private void DetectSubnetAction() @@ -293,6 +356,9 @@ private void DetectSubnetAction() DetectIPRange().ConfigureAwait(false); } + /// + /// Gets the command to redirect the selected host to another application. + /// public ICommand RedirectDataToApplicationCommand => new RelayCommand(RedirectDataToApplicationAction); private void RedirectDataToApplicationAction(object name) @@ -307,6 +373,9 @@ private void RedirectDataToApplicationAction(object name) EventSystem.RedirectToApplication(applicationName, host); } + /// + /// Gets the command to perform a DNS lookup for the selected IP address. + /// public ICommand PerformDNSLookupIPAddressCommand => new RelayCommand(_ => PerformDNSLookupIPAddressAction()); private void PerformDNSLookupIPAddressAction() @@ -314,6 +383,9 @@ private void PerformDNSLookupIPAddressAction() EventSystem.RedirectToApplication(ApplicationName.DNSLookup, SelectedResult.PingInfo.IPAddress.ToString()); } + /// + /// Gets the command to perform a DNS lookup for the selected hostname. + /// public ICommand PerformDNSLookupHostnameCommand => new RelayCommand(_ => PerformDNSLookupHostnameAction()); private void PerformDNSLookupHostnameAction() @@ -321,6 +393,9 @@ private void PerformDNSLookupHostnameAction() EventSystem.RedirectToApplication(ApplicationName.DNSLookup, SelectedResult.Hostname); } + /// + /// Gets the command to execute a custom command for the selected host. + /// public ICommand CustomCommandCommand => new RelayCommand(CustomCommandAction); private void CustomCommandAction(object guid) @@ -328,6 +403,9 @@ private void CustomCommandAction(object guid) CustomCommand(guid).ConfigureAwait(false); } + /// + /// Gets the command to add the selected host as a profile. + /// public ICommand AddProfileSelectedHostCommand => new RelayCommand(_ => AddProfileSelectedHostAction()); private async void AddProfileSelectedHostAction() @@ -349,6 +427,9 @@ await ProfileDialogManager.ShowAddProfileDialog(window, this, profileInfo, null, ApplicationName.IPScanner); } + /// + /// Gets the command to copy the selected ports to the clipboard. + /// public ICommand CopySelectedPortsCommand => new RelayCommand(_ => CopySelectedPortsAction()); private void CopySelectedPortsAction() @@ -362,6 +443,9 @@ private void CopySelectedPortsAction() ClipboardHelper.SetClipboard(stringBuilder.ToString()); } + /// + /// Gets the command to export the scan results. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction()); private void ExportAction() @@ -373,6 +457,9 @@ private void ExportAction() #region Methods + /// + /// Starts the IP scan. + /// private async Task Start() { IsStatusMessageDisplayed = false; @@ -439,12 +526,18 @@ await PortRangeHelper.ConvertPortRangeToIntArrayAsync(SettingsManager.Current.IP ipScanner.ScanAsync(hosts.hosts, _cancellationTokenSource.Token); } + /// + /// Stops the IP scan. + /// private void Stop() { IsCanceling = true; _cancellationTokenSource.Cancel(); } + /// + /// Detects the local IP subnet. + /// private async Task DetectIPRange() { IsSubnetDetectionRunning = true; @@ -485,6 +578,10 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, IsSubnetDetectionRunning = false; } + /// + /// Executes a custom command. + /// + /// The GUID of the custom command to execute. private async Task CustomCommand(object guid) { if (guid is Guid id) @@ -525,6 +622,10 @@ await _dialogCoordinator.ShowMessageAsync(this, } } + /// + /// Adds the scanned host/range to the history. + /// + /// The host or IP range to add. private void AddHostToHistory(string ipRange) { // Create the new list @@ -539,6 +640,10 @@ private void AddHostToHistory(string ipRange) list.ForEach(SettingsManager.Current.IPScanner_HostHistory.Add); } + /// + /// Exports the scan results. + /// + /// A task that represents the asynchronous operation. private Task Export() { var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.IsActive); @@ -589,6 +694,9 @@ await _dialogCoordinator.ShowMessageAsync(window, Strings.Error, return window.ShowChildWindowAsync(childWindow); } + /// + /// Called when the tab is closed. Stops any running scan. + /// public void OnClose() { // Prevent multiple calls @@ -608,17 +716,32 @@ public void OnClose() #region Events + /// + /// Handles the HostScanned event. Adds the result to the list. + /// + /// The source of the event. + /// The instance containing the event data. private void HostScanned(object sender, IPScannerHostScannedArgs e) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(delegate { Results.Add(e.Args); })); } + /// + /// Handles the ProgressChanged event. Updates the progress. + /// + /// The source of the event. + /// The instance containing the event data. private void ProgressChanged(object sender, ProgressChangedArgs e) { HostsScanned = e.Value; } + /// + /// Handles the ScanComplete event. + /// + /// The source of the event. + /// The instance containing the event data. private void ScanComplete(object sender, EventArgs e) { if (Results.Count == 0) @@ -631,6 +754,11 @@ private void ScanComplete(object sender, EventArgs e) IsRunning = false; } + /// + /// Handles the UserHasCanceled event. + /// + /// The source of the event. + /// The instance containing the event data. private void UserHasCanceled(object sender, EventArgs e) { StatusMessage = Strings.CanceledByUserMessage; diff --git a/Source/NETworkManager/ViewModels/ListenersViewModel.cs b/Source/NETworkManager/ViewModels/ListenersViewModel.cs index 7f546c5a76..5d47544065 100644 --- a/Source/NETworkManager/ViewModels/ListenersViewModel.cs +++ b/Source/NETworkManager/ViewModels/ListenersViewModel.cs @@ -22,10 +22,17 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the listeners view. +/// public class ListenersViewModel : ViewModelBase { #region Contructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public ListenersViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -71,6 +78,9 @@ public ListenersViewModel(IDialogCoordinator instance) #region Events + /// + /// Handles the Tick event of the auto-refresh timer. + /// private async void AutoRefreshTimer_Tick(object sender, EventArgs e) { // Stop timer... @@ -89,13 +99,29 @@ private async void AutoRefreshTimer_Tick(object sender, EventArgs e) private static readonly ILog Log = LogManager.GetLogger(typeof(ListenersViewModel)); + /// + /// The dialog coordinator instance. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Indicates whether the view model is loading. + /// private readonly bool _isLoading; + + /// + /// The timer for auto-refresh. + /// private readonly DispatcherTimer _autoRefreshTimer = new(); + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -112,8 +138,14 @@ public string Search } } + /// + /// Backing field for . + /// private ObservableCollection _results = new(); + /// + /// Gets or sets the collection of listener results. + /// public ObservableCollection Results { get => _results; @@ -127,10 +159,19 @@ public ObservableCollection Results } } + /// + /// Gets the collection view for the listener results. + /// public ICollectionView ResultsView { get; } + /// + /// Backing field for . + /// private ListenerInfo _selectedResult; + /// + /// Gets or sets the currently selected listener result. + /// public ListenerInfo SelectedResult { get => _selectedResult; @@ -144,8 +185,14 @@ public ListenerInfo SelectedResult } } + /// + /// Backing field for . + /// private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of selected listener results. + /// public IList SelectedResults { get => _selectedResults; @@ -159,8 +206,14 @@ public IList SelectedResults } } + /// + /// Backing field for . + /// private bool _autoRefreshEnabled; + /// + /// Gets or sets a value indicating whether auto-refresh is enabled. + /// public bool AutoRefreshEnabled { get => _autoRefreshEnabled; @@ -189,10 +242,19 @@ public bool AutoRefreshEnabled } } + /// + /// Gets the collection view for the auto-refresh times. + /// public ICollectionView AutoRefreshTimes { get; } + /// + /// Backing field for . + /// private AutoRefreshTimeInfo _selectedAutoRefreshTime; + /// + /// Gets or sets the selected auto-refresh time. + /// public AutoRefreshTimeInfo SelectedAutoRefreshTime { get => _selectedAutoRefreshTime; @@ -216,8 +278,14 @@ public AutoRefreshTimeInfo SelectedAutoRefreshTime } } + /// + /// Backing field for . + /// private bool _isRefreshing; + /// + /// Gets or sets a value indicating whether the view model is currently refreshing. + /// public bool IsRefreshing { get => _isRefreshing; @@ -231,8 +299,14 @@ public bool IsRefreshing } } + /// + /// Backing field for . + /// private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -246,8 +320,14 @@ public bool IsStatusMessageDisplayed } } + /// + /// Backing field for . + /// private string _statusMessage; + /// + /// Gets or sets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -265,8 +345,16 @@ public string StatusMessage #region ICommands & Actions + /// + /// Gets the command to refresh the listeners. + /// public ICommand RefreshCommand => new RelayCommand(_ => RefreshAction().ConfigureAwait(false), Refresh_CanExecute); + /// + /// Checks if the refresh command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool Refresh_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -276,6 +364,9 @@ private bool Refresh_CanExecute(object parameter) !AutoRefreshEnabled; } + /// + /// Action to refresh the listeners. + /// private async Task RefreshAction() { IsStatusMessageDisplayed = false; @@ -283,8 +374,14 @@ private async Task RefreshAction() await Refresh(); } + /// + /// Gets the command to export the listeners. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Action to export the listeners. + /// private Task ExportAction() { var childWindow = new ExportChildWindow(); @@ -336,6 +433,10 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, #region Methods + /// + /// Refreshes the listeners. + /// + /// Indicates whether this is the initial refresh. private async Task Refresh(bool init = false) { IsRefreshing = true; @@ -356,6 +457,9 @@ private async Task Refresh(bool init = false) IsRefreshing = false; } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { // Restart timer... @@ -363,6 +467,9 @@ public void OnViewVisible() _autoRefreshTimer.Start(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { // Temporarily stop timer... diff --git a/Source/NETworkManager/ViewModels/LookupHostViewModel.cs b/Source/NETworkManager/ViewModels/LookupHostViewModel.cs index d7e9e5ea5c..895700b961 100644 --- a/Source/NETworkManager/ViewModels/LookupHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/LookupHostViewModel.cs @@ -1,11 +1,20 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the lookup host view. +/// public class LookupHostViewModel : ViewModelBase { + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { } diff --git a/Source/NETworkManager/ViewModels/LookupOUILookupViewModel.cs b/Source/NETworkManager/ViewModels/LookupOUILookupViewModel.cs index 463280f3c6..1b3c31c54e 100644 --- a/Source/NETworkManager/ViewModels/LookupOUILookupViewModel.cs +++ b/Source/NETworkManager/ViewModels/LookupOUILookupViewModel.cs @@ -22,10 +22,17 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the OUI lookup view. +/// public class LookupOUILookupViewModel : ViewModelBase { #region Constructor, Load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public LookupOUILookupViewModel(IDialogCoordinator instance) { _dialogCoordinator = instance; @@ -42,6 +49,10 @@ public LookupOUILookupViewModel(IDialogCoordinator instance) #region Methods + /// + /// Adds the search term to the history. + /// + /// The MAC address or vendor. private void AddSearchToHistory(string macAddressOrVendor) { // Create the new list @@ -60,12 +71,25 @@ private void AddSearchToHistory(string macAddressOrVendor) #endregion #region Variables + + /// + /// The logger. + /// private static readonly ILog Log = LogManager.GetLogger(typeof(LookupOUILookupViewModel)); + /// + /// The dialog coordinator. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search query. + /// public string Search { get => _search; @@ -79,8 +103,14 @@ public string Search } } + /// + /// Backing field for . + /// private bool _hasError; + /// + /// Gets or sets a value indicating whether there is a validation error. + /// public bool HasError { get => _hasError; @@ -94,10 +124,19 @@ public bool HasError } } + /// + /// Gets the search history view. + /// public ICollectionView SearchHistoryView { get; } + /// + /// Backing field for . + /// private bool _isRunning; + /// + /// Gets or sets a value indicating whether the lookup is running. + /// public bool IsRunning { get => _isRunning; @@ -111,8 +150,14 @@ public bool IsRunning } } + /// + /// Backing field for . + /// private ObservableCollection _results = new(); + /// + /// Gets or sets the search results. + /// public ObservableCollection Results { get => _results; @@ -125,10 +170,19 @@ public ObservableCollection Results } } + /// + /// Gets the results view. + /// public ICollectionView ResultsView { get; } + /// + /// Backing field for . + /// private OUIInfo _selectedResult; + /// + /// Gets or sets the selected result. + /// public OUIInfo SelectedResult { get => _selectedResult; @@ -142,8 +196,14 @@ public OUIInfo SelectedResult } } + /// + /// Backing field for . + /// private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of selected results. + /// public IList SelectedResults { get => _selectedResults; @@ -157,8 +217,14 @@ public IList SelectedResults } } + /// + /// Backing field for . + /// private bool _nothingFound; + /// + /// Gets or sets a value indicating whether no results were found. + /// public bool NothingFound { get => _nothingFound; @@ -176,8 +242,16 @@ public bool NothingFound #region ICommands & Actions + /// + /// Gets the command to perform the OUI lookup. + /// public ICommand OUILookupCommand => new RelayCommand(_ => OUILookupAction(), OUILookup_CanExecute); + /// + /// Checks if the OUI lookup command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool OUILookup_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -186,6 +260,9 @@ private bool OUILookup_CanExecute(object parameter) !HasError; } + /// + /// Performs the OUI lookup. + /// private async void OUILookupAction() { IsRunning = true; @@ -232,8 +309,15 @@ private async void OUILookupAction() IsRunning = false; } + /// + /// Gets the command to export the results. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Exports the results. + /// + /// A task representing the asynchronous operation. private Task ExportAction() { var childWindow = new ExportChildWindow(); diff --git a/Source/NETworkManager/ViewModels/LookupPortViewModel.cs b/Source/NETworkManager/ViewModels/LookupPortViewModel.cs index 00c662c1c7..e321e447b0 100644 --- a/Source/NETworkManager/ViewModels/LookupPortViewModel.cs +++ b/Source/NETworkManager/ViewModels/LookupPortViewModel.cs @@ -23,10 +23,17 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the port lookup view. +/// public class LookupPortLookupViewModel : ViewModelBase { #region Constructor, Load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public LookupPortLookupViewModel(IDialogCoordinator instance) { _dialogCoordinator = instance; @@ -39,6 +46,10 @@ public LookupPortLookupViewModel(IDialogCoordinator instance) #region Methods + /// + /// Adds the search term to the history. + /// + /// The port or service. private void AddSearchToHistory(string portOrService) { // Create the new list @@ -56,12 +67,25 @@ private void AddSearchToHistory(string portOrService) #endregion #region Variables + + /// + /// The logger. + /// private static readonly ILog Log = LogManager.GetLogger(typeof(LookupPortLookupViewModel)); + /// + /// The dialog coordinator. + /// private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Backing field for . + /// private string _search; + /// + /// Gets or sets the search query. + /// public string Search { get => _search; @@ -75,8 +99,14 @@ public string Search } } + /// + /// Backing field for . + /// private bool _hasError; + /// + /// Gets or sets a value indicating whether there is a validation error. + /// public bool HasError { get => _hasError; @@ -89,10 +119,19 @@ public bool HasError } } + /// + /// Gets the search history view. + /// public ICollectionView SearchHistoryView { get; } + /// + /// Backing field for . + /// private bool _isRunning; + /// + /// Gets or sets a value indicating whether the lookup is running. + /// public bool IsRunning { get => _isRunning; @@ -106,8 +145,14 @@ public bool IsRunning } } + /// + /// Backing field for . + /// private ObservableCollection _results = new(); + /// + /// Gets or sets the search results. + /// public ObservableCollection Results { get => _results; @@ -121,10 +166,19 @@ public ObservableCollection Results } } + /// + /// Gets the results view. + /// public ICollectionView ResultsView { get; } + /// + /// Backing field for . + /// private PortLookupInfo _selectedResult; + /// + /// Gets or sets the selected result. + /// public PortLookupInfo SelectedResult { get => _selectedResult; @@ -138,8 +192,14 @@ public PortLookupInfo SelectedResult } } + /// + /// Backing field for . + /// private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of selected results. + /// public IList SelectedResults { get => _selectedResults; @@ -154,8 +214,14 @@ public IList SelectedResults } + /// + /// Backing field for . + /// private bool _nothingFound; + /// + /// Gets or sets a value indicating whether no results were found. + /// public bool NothingFound { get => _nothingFound; @@ -173,9 +239,17 @@ public bool NothingFound #region ICommands & Actions + /// + /// Gets the command to perform the port lookup. + /// public ICommand PortLookupCommand => new RelayCommand(_ => PortLookupAction().ConfigureAwait(false), PortLookup_CanExecute); + /// + /// Checks if the port lookup command can be executed. + /// + /// The command parameter. + /// true if the command can be executed; otherwise, false. private bool PortLookup_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -183,6 +257,9 @@ private bool PortLookup_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen && !HasError; } + /// + /// Performs the port lookup. + /// private async Task PortLookupAction() { IsRunning = true; @@ -292,8 +369,15 @@ await PortLookup.LookupByPortAndProtocolAsync( IsRunning = false; } + /// + /// Gets the command to export the results. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Exports the results. + /// + /// A task representing the asynchronous operation. private Task ExportAction() { var childWindow = new ExportChildWindow(); diff --git a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs index 1ba039cc26..50cee9098d 100644 --- a/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkConnectionWidgetViewModel.cs @@ -13,16 +13,29 @@ namespace NETworkManager.ViewModels; +/// +/// View model for the network connection widget. +/// public class NetworkConnectionWidgetViewModel : ViewModelBase { #region Variables + + /// + /// The logger. + /// private static readonly ILog Log = LogManager.GetLogger(typeof(NetworkConnectionWidgetViewModel)); #region Computer + /// + /// Backing field for . + /// private bool _isComputerIPv4Checking; + /// + /// Gets or sets a value indicating whether the computer IPv4 address is being checked. + /// public bool IsComputerIPv4Checking { get => _isComputerIPv4Checking; @@ -36,8 +49,14 @@ public bool IsComputerIPv4Checking } } + /// + /// Backing field for . + /// private string _computerIPv4; + /// + /// Gets or sets the computer IPv4 address. + /// public string ComputerIPv4 { get => _computerIPv4; @@ -51,8 +70,14 @@ public string ComputerIPv4 } } + /// + /// Backing field for . + /// private ConnectionState _computerIPv4State = ConnectionState.None; + /// + /// Gets private or sets the computer IPv4 connection state. + /// public ConnectionState ComputerIPv4State { get => _computerIPv4State; @@ -66,8 +91,14 @@ private set } } + /// + /// Backing field for . + /// private bool _isComputerIPv6Checking; + /// + /// Gets or sets a value indicating whether the computer IPv6 address is being checked. + /// public bool IsComputerIPv6Checking { get => _isComputerIPv6Checking; @@ -81,8 +112,14 @@ public bool IsComputerIPv6Checking } } + /// + /// Backing field for . + /// private string _computerIPv6; + /// + /// Gets or sets the computer IPv6 address. + /// public string ComputerIPv6 { get => _computerIPv6; @@ -96,8 +133,14 @@ public string ComputerIPv6 } } + /// + /// Backing field for . + /// private ConnectionState _computerIPv6State = ConnectionState.None; + /// + /// Gets private or sets the computer IPv6 connection state. + /// public ConnectionState ComputerIPv6State { get => _computerIPv6State; @@ -111,8 +154,14 @@ private set } } + /// + /// Backing field for . + /// private bool _isComputerDNSChecking; + /// + /// Gets or sets a value indicating whether the computer DNS address is being checked. + /// public bool IsComputerDNSChecking { get => _isComputerDNSChecking; @@ -126,8 +175,14 @@ public bool IsComputerDNSChecking } } + /// + /// Backing field for . + /// private string _computerDNS; + /// + /// Gets or sets the computer DNS address. + /// public string ComputerDNS { get => _computerDNS; @@ -141,8 +196,14 @@ public string ComputerDNS } } + /// + /// Backing field for . + /// private ConnectionState _computerDNSState = ConnectionState.None; + /// + /// Gets private or sets the computer DNS connection state. + /// public ConnectionState ComputerDNSState { get => _computerDNSState; @@ -160,8 +221,14 @@ private set #region Router + /// + /// Backing field for . + /// private bool _isRouterIPv4Checking; + /// + /// Gets or sets a value indicating whether the router IPv4 address is being checked. + /// public bool IsRouterIPv4Checking { get => _isRouterIPv4Checking; @@ -175,8 +242,14 @@ public bool IsRouterIPv4Checking } } + /// + /// Backing field for . + /// private string _routerIPv4; + /// + /// Gets or sets the router IPv4 address. + /// public string RouterIPv4 { get => _routerIPv4; @@ -190,8 +263,14 @@ public string RouterIPv4 } } + /// + /// Backing field for . + /// private ConnectionState _routerIPv4State = ConnectionState.None; + /// + /// Gets private or sets the router IPv4 connection state. + /// public ConnectionState RouterIPv4State { get => _routerIPv4State; @@ -205,8 +284,14 @@ private set } } + /// + /// Backing field for . + /// private bool _isRouterIPv6Checking; + /// + /// Gets or sets a value indicating whether the router IPv6 address is being checked. + /// public bool IsRouterIPv6Checking { get => _isRouterIPv6Checking; @@ -220,8 +305,14 @@ public bool IsRouterIPv6Checking } } + /// + /// Backing field for . + /// private string _routerIPv6; + /// + /// Gets or sets the router IPv6 address. + /// public string RouterIPv6 { get => _routerIPv6; @@ -235,8 +326,14 @@ public string RouterIPv6 } } + /// + /// Backing field for . + /// private ConnectionState _routerIPv6State = ConnectionState.None; + /// + /// Gets private or sets the router IPv6 connection state. + /// public ConnectionState RouterIPv6State { get => _routerIPv6State; @@ -250,8 +347,14 @@ private set } } + /// + /// Backing field for . + /// private bool _isRouterDNSChecking; + /// + /// Gets or sets a value indicating whether the router DNS address is being checked. + /// public bool IsRouterDNSChecking { get => _isRouterDNSChecking; @@ -265,8 +368,14 @@ public bool IsRouterDNSChecking } } + /// + /// Backing field for . + /// private string _routerDNS; + /// + /// Gets or sets the router DNS address. + /// public string RouterDNS { get => _routerDNS; @@ -280,8 +389,14 @@ public string RouterDNS } } + /// + /// Backing field for . + /// private ConnectionState _routerDNSState = ConnectionState.None; + /// + /// Gets private or sets the router DNS connection state. + /// public ConnectionState RouterDNSState { get => _routerDNSState; @@ -299,8 +414,14 @@ private set #region Internet + /// + /// Backing field for . + /// private bool _isInternetIPv4Checking; + /// + /// Gets or sets a value indicating whether the internet IPv4 address is being checked. + /// public bool IsInternetIPv4Checking { get => _isInternetIPv4Checking; @@ -314,8 +435,14 @@ public bool IsInternetIPv4Checking } } + /// + /// Backing field for . + /// private string _internetIPv4; + /// + /// Gets or sets the internet IPv4 address. + /// public string InternetIPv4 { get => _internetIPv4; @@ -329,8 +456,14 @@ public string InternetIPv4 } } + /// + /// Backing field for . + /// private ConnectionState _internetIPv4State = ConnectionState.None; + /// + /// Gets private or sets the internet IPv4 connection state. + /// public ConnectionState InternetIPv4State { get => _internetIPv4State; @@ -344,8 +477,14 @@ private set } } + /// + /// Backing field for . + /// private bool _isInternetIPv6Checking; + /// + /// Gets or sets a value indicating whether the internet IPv6 address is being checked. + /// public bool IsInternetIPv6Checking { get => _isInternetIPv6Checking; @@ -359,8 +498,14 @@ public bool IsInternetIPv6Checking } } + /// + /// Backing field for . + /// private string _internetIPv6; + /// + /// Gets or sets the internet IPv6 address. + /// public string InternetIPv6 { get => _internetIPv6; @@ -374,8 +519,14 @@ public string InternetIPv6 } } + /// + /// Backing field for . + /// private ConnectionState _internetIPv6State = ConnectionState.None; + /// + /// Gets private or sets the internet IPv6 connection state. + /// public ConnectionState InternetIPv6State { get => _internetIPv6State; @@ -389,8 +540,14 @@ private set } } + /// + /// Backing field for . + /// private bool _isInternetDNSChecking; + /// + /// Gets or sets a value indicating whether the internet DNS address is being checked. + /// public bool IsInternetDNSChecking { get => _isInternetDNSChecking; @@ -404,8 +561,14 @@ public bool IsInternetDNSChecking } } + /// + /// Backing field for . + /// private string _internetDNS; + /// + /// Gets or sets the internet DNS address. + /// public string InternetDNS { get => _internetDNS; @@ -419,8 +582,14 @@ public string InternetDNS } } + /// + /// Backing field for . + /// private ConnectionState _internetDNSState = ConnectionState.None; + /// + /// Gets private or sets the internet DNS connection state. + /// public ConnectionState InternetDNSState { get => _internetDNSState; @@ -436,17 +605,26 @@ private set #endregion + /// + /// Gets a value indicating whether checking the public IP address is enabled. + /// public bool CheckPublicIPAddressEnabled => SettingsManager.Current.Dashboard_CheckPublicIPAddress; #endregion #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public NetworkConnectionWidgetViewModel() { LoadSettings(); } + /// + /// Loads the settings. + /// private void LoadSettings() { } @@ -455,8 +633,14 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to check connections via hotkey. + /// public ICommand CheckViaHotkeyCommand => new RelayCommand(_ => CheckViaHotkeyAction()); + /// + /// Executes the check via hotkey action. + /// private void CheckViaHotkeyAction() { Check(); @@ -466,14 +650,27 @@ private void CheckViaHotkeyAction() #region Methods + /// + /// Checks the network connections. + /// public void Check() { CheckAsync().ConfigureAwait(false); } - + + /// + /// The cancellation token source. + /// private CancellationTokenSource _cancellationTokenSource; - private Task _checkTask = Task.CompletedTask; + /// + /// The check task. + /// + private Task _checkTask = Task.CompletedTask; + + /// + /// Checks the network connections asynchronously. + /// private async Task CheckAsync() { Log.Info("Checking network connection..."); @@ -517,7 +714,12 @@ private async Task CheckAsync() Log.Info("Network connection check completed."); } } - + + /// + /// Runs the check tasks. + /// + /// The cancellation token. + /// A task representing the asynchronous operation. private async Task RunTask(CancellationToken ct) { await Task.WhenAll( @@ -526,7 +728,12 @@ await Task.WhenAll( CheckConnectionInternetAsync(ct) ); } - + + /// + /// Checks the computer connection. + /// + /// The cancellation token. + /// A task representing the asynchronous operation. private Task CheckConnectionComputerAsync(CancellationToken ct) { return Task.Run(async () => @@ -660,6 +867,11 @@ await NetworkInterface.DetectLocalIPAddressBasedOnRoutingAsync( }, ct); } + /// + /// Checks the router connection asynchronously. + /// + /// The cancellation token. + /// A task representing the asynchronous operation. private Task CheckConnectionRouterAsync(CancellationToken ct) { return Task.Run(async () => diff --git a/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs b/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs index 95c468d5c0..cfbff48e89 100644 --- a/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs +++ b/Source/NETworkManager/ViewModels/NetworkInterfaceViewModel.cs @@ -32,6 +32,9 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the Network Interface feature, allowing management of network adapters. +/// public class NetworkInterfaceViewModel : ViewModelBase, IProfileManager { #region Variables @@ -48,6 +51,9 @@ public class NetworkInterfaceViewModel : ViewModelBase, IProfileManager private bool _isNetworkInterfaceLoading; + /// + /// Gets or sets a value indicating whether network interfaces are currently loading. + /// public bool IsNetworkInterfaceLoading { get => _isNetworkInterfaceLoading; @@ -63,6 +69,9 @@ public bool IsNetworkInterfaceLoading private bool _canConfigure; + /// + /// Gets or sets a value indicating whether configuration is allowed. + /// public bool CanConfigure { get => _canConfigure; @@ -78,6 +87,9 @@ public bool CanConfigure private bool _isConfigurationRunning; + /// + /// Gets or sets a value indicating whether a configuration operation is running. + /// public bool IsConfigurationRunning { get => _isConfigurationRunning; @@ -93,6 +105,9 @@ public bool IsConfigurationRunning private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -108,6 +123,9 @@ public bool IsStatusMessageDisplayed private string _statusMessage; + /// + /// Gets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -125,6 +143,9 @@ private set private ObservableCollection _networkInterfaces = []; + /// + /// Gets the collection of network interfaces. + /// public ObservableCollection NetworkInterfaces { get => _networkInterfaces; @@ -140,6 +161,9 @@ private set private NetworkInterfaceInfo _selectedNetworkInterface; + /// + /// Gets or sets the currently selected network interface. + /// public NetworkInterfaceInfo SelectedNetworkInterface { get => _selectedNetworkInterface; @@ -176,6 +200,9 @@ public NetworkInterfaceInfo SelectedNetworkInterface private long _bandwidthTotalBytesSent; + /// + /// Gets or sets the total bytes sent. + /// public long BandwidthTotalBytesSent { get => _bandwidthTotalBytesSent; @@ -192,6 +219,9 @@ public long BandwidthTotalBytesSent private long _bandwidthTotalBytesReceivedTemp; private long _bandwidthTotalBytesReceived; + /// + /// Gets or sets the total bytes received. + /// public long BandwidthTotalBytesReceived { get => _bandwidthTotalBytesReceived; @@ -207,6 +237,9 @@ public long BandwidthTotalBytesReceived private long _bandwidthDiffBytesSent; + /// + /// Gets or sets the difference in bytes sent. + /// public long BandwidthDiffBytesSent { get => _bandwidthDiffBytesSent; @@ -222,6 +255,9 @@ public long BandwidthDiffBytesSent private long _bandwidthDiffBytesReceived; + /// + /// Gets or sets the difference in bytes received. + /// public long BandwidthDiffBytesReceived { get => _bandwidthDiffBytesReceived; @@ -237,6 +273,9 @@ public long BandwidthDiffBytesReceived private long _bandwidthBytesReceivedSpeed; + /// + /// Gets or sets the speed of bytes received. + /// public long BandwidthBytesReceivedSpeed { get => _bandwidthBytesReceivedSpeed; @@ -252,6 +291,9 @@ public long BandwidthBytesReceivedSpeed private long _bandwidthBytesSentSpeed; + /// + /// Gets or sets the speed of bytes sent. + /// public long BandwidthBytesSentSpeed { get => _bandwidthBytesSentSpeed; @@ -267,6 +309,9 @@ public long BandwidthBytesSentSpeed private DateTime _bandwidthStartTime; + /// + /// Gets or sets the start time of the bandwidth measurement. + /// public DateTime BandwidthStartTime { get => _bandwidthStartTime; @@ -282,6 +327,9 @@ public DateTime BandwidthStartTime private TimeSpan _bandwidthMeasuredTime; + /// + /// Gets or sets the duration of the bandwidth measurement. + /// public TimeSpan BandwidthMeasuredTime { get => _bandwidthMeasuredTime; @@ -301,6 +349,9 @@ public TimeSpan BandwidthMeasuredTime private bool _configEnableDynamicIPAddress = true; + /// + /// Gets or sets a value indicating whether to enable dynamic IP address (DHCP). + /// public bool ConfigEnableDynamicIPAddress { get => _configEnableDynamicIPAddress; @@ -316,6 +367,9 @@ public bool ConfigEnableDynamicIPAddress private bool _configEnableStaticIPAddress; + /// + /// Gets or sets a value indicating whether to enable static IP address. + /// public bool ConfigEnableStaticIPAddress { get => _configEnableStaticIPAddress; @@ -333,6 +387,9 @@ public bool ConfigEnableStaticIPAddress private string _configIPAddress; + /// + /// Gets or sets the static IP address. + /// public string ConfigIPAddress { get => _configIPAddress; @@ -348,6 +405,9 @@ public string ConfigIPAddress private string _configSubnetmask; + /// + /// Gets or sets the subnet mask. + /// public string ConfigSubnetmask { get => _configSubnetmask; @@ -363,6 +423,9 @@ public string ConfigSubnetmask private string _configGateway; + /// + /// Gets or sets the default gateway. + /// public string ConfigGateway { get => _configGateway; @@ -378,6 +441,9 @@ public string ConfigGateway private bool _configEnableDynamicDNS = true; + /// + /// Gets or sets a value indicating whether to enable dynamic DNS (DHCP). + /// public bool ConfigEnableDynamicDNS { get => _configEnableDynamicDNS; @@ -393,6 +459,9 @@ public bool ConfigEnableDynamicDNS private bool _configEnableStaticDNS; + /// + /// Gets or sets a value indicating whether to enable static DNS. + /// public bool ConfigEnableStaticDNS { get => _configEnableStaticDNS; @@ -408,6 +477,9 @@ public bool ConfigEnableStaticDNS private string _configPrimaryDNSServer; + /// + /// Gets or sets the primary DNS server. + /// public string ConfigPrimaryDNSServer { get => _configPrimaryDNSServer; @@ -423,6 +495,9 @@ public string ConfigPrimaryDNSServer private string _configSecondaryDNSServer; + /// + /// Gets or sets the secondary DNS server. + /// public string ConfigSecondaryDNSServer { get => _configSecondaryDNSServer; @@ -442,6 +517,9 @@ public string ConfigSecondaryDNSServer private ICollectionView _profiles; + /// + /// Gets the collection of profiles. + /// public ICollectionView Profiles { get => _profiles; @@ -457,6 +535,9 @@ private set private ProfileInfo _selectedProfile = new(); + /// + /// Gets or sets the selected profile. + /// public ProfileInfo SelectedProfile { get => _selectedProfile; @@ -485,6 +566,9 @@ public ProfileInfo SelectedProfile private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -508,6 +592,9 @@ public string Search private bool _isSearching; + /// + /// Gets or sets a value indicating whether a search is in progress. + /// public bool IsSearching { get => _isSearching; @@ -523,6 +610,9 @@ public bool IsSearching private bool _profileFilterIsOpen; + /// + /// Gets or sets a value indicating whether the profile filter is open. + /// public bool ProfileFilterIsOpen { get => _profileFilterIsOpen; @@ -536,12 +626,21 @@ public bool ProfileFilterIsOpen } } + /// + /// Gets or sets the view for profile filter tags. + /// public ICollectionView ProfileFilterTagsView { get; set; } + /// + /// Gets or sets the collection of profile filter tags. + /// public ObservableCollection ProfileFilterTags { get; set; } = []; private bool _profileFilterTagsMatchAny = GlobalStaticConfiguration.Profile_TagsMatchAny; + /// + /// Gets or sets a value indicating whether to match any profile filter tag. + /// public bool ProfileFilterTagsMatchAny { get => _profileFilterTagsMatchAny; @@ -557,6 +656,9 @@ public bool ProfileFilterTagsMatchAny private bool _profileFilterTagsMatchAll; + /// + /// Gets or sets a value indicating whether to match all profile filter tags. + /// public bool ProfileFilterTagsMatchAll { get => _profileFilterTagsMatchAll; @@ -572,6 +674,9 @@ public bool ProfileFilterTagsMatchAll private bool _isProfileFilterSet; + /// + /// Gets or sets a value indicating whether a profile filter is set. + /// public bool IsProfileFilterSet { get => _isProfileFilterSet; @@ -586,6 +691,10 @@ public bool IsProfileFilterSet } private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + + /// + /// Gets the store for group expander states. + /// public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; @@ -593,6 +702,9 @@ public bool IsProfileFilterSet private bool _expandProfileView; + /// + /// Gets or sets a value indicating whether to expand the profile view. + /// public bool ExpandProfileView { get => _expandProfileView; @@ -615,6 +727,9 @@ public bool ExpandProfileView private GridLength _profileWidth; + /// + /// Gets or sets the width of the profile view. + /// public GridLength ProfileWidth { get => _profileWidth; @@ -642,6 +757,10 @@ public GridLength ProfileWidth #region Constructor, LoadSettings, OnShutdown + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public NetworkInterfaceViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -675,6 +794,9 @@ public NetworkInterfaceViewModel(IDialogCoordinator instance) _isLoading = false; } + /// + /// Initializes the bandwidth chart configuration. + /// private void InitialBandwidthChart() { var dayConfig = Mappers.Xy() @@ -706,6 +828,9 @@ private void InitialBandwidthChart() public Func FormatterSpeed { get; set; } public SeriesCollection Series { get; set; } + /// + /// Loads the network interfaces. + /// private async Task LoadNetworkInterfaces() { IsNetworkInterfaceLoading = true; @@ -725,6 +850,9 @@ private async Task LoadNetworkInterfaces() IsNetworkInterfaceLoading = false; } + /// + /// Loads the settings. + /// private void LoadSettings() { ExpandProfileView = SettingsManager.Current.NetworkInterface_ExpandProfileView; @@ -740,9 +868,15 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to reload the network interfaces. + /// public ICommand ReloadNetworkInterfacesCommand => new RelayCommand(_ => ReloadNetworkInterfacesAction(), ReloadNetworkInterfaces_CanExecute); + /// + /// Determines whether the ReloadNetworkInterfaces command can execute. + /// private bool ReloadNetworkInterfaces_CanExecute(object obj) { return !IsNetworkInterfaceLoading && @@ -751,13 +885,22 @@ private bool ReloadNetworkInterfaces_CanExecute(object obj) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Action to reload the network interfaces. + /// private void ReloadNetworkInterfacesAction() { ReloadNetworkInterfaces(); } + /// + /// Gets the command to export the network interfaces. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction().ConfigureAwait(false)); + /// + /// Action to export the network interfaces. + /// private Task ExportAction() { var childWindow = new ExportChildWindow(); @@ -805,9 +948,15 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, return (Application.Current.MainWindow as MainWindow).ShowChildWindowAsync(childWindow); } + /// + /// Gets the command to apply the network configuration. + /// public ICommand ApplyConfigurationCommand => new RelayCommand(_ => ApplyConfigurationAction(), ApplyConfiguration_CanExecute); + /// + /// Determines whether the ApplyConfiguration command can execute. + /// private bool ApplyConfiguration_CanExecute(object parameter) { return Application.Current.MainWindow != null && @@ -815,11 +964,17 @@ private bool ApplyConfiguration_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Action to apply the network configuration. + /// private void ApplyConfigurationAction() { ApplyConfiguration().ConfigureAwait(false); } + /// + /// Gets the command to apply the profile configuration. + /// public ICommand ApplyProfileConfigCommand => new RelayCommand(_ => ApplyProfileProfileAction()); private void ApplyProfileProfileAction() @@ -827,6 +982,9 @@ private void ApplyProfileProfileAction() ApplyConfigurationFromProfile().ConfigureAwait(false); } + /// + /// Gets the command to add a new profile. + /// public ICommand AddProfileCommand => new RelayCommand(_ => AddProfileAction()); private void AddProfileAction() @@ -841,6 +999,9 @@ private bool ModifyProfile_CanExecute(object obj) return SelectedProfile is { IsDynamic: false }; } + /// + /// Gets the command to edit the selected profile. + /// public ICommand EditProfileCommand => new RelayCommand(_ => EditProfileAction(), ModifyProfile_CanExecute); private void EditProfileAction() @@ -849,6 +1010,9 @@ private void EditProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to copy the selected profile as a new profile. + /// public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute); private void CopyAsProfileAction() @@ -857,6 +1021,9 @@ private void CopyAsProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to delete the selected profile. + /// public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute); private void DeleteProfileAction() @@ -866,6 +1033,9 @@ private void DeleteProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to edit a profile group. + /// public ICommand EditGroupCommand => new RelayCommand(EditGroupAction); private void EditGroupAction(object group) @@ -875,6 +1045,9 @@ private void EditGroupAction(object group) .ConfigureAwait(false); } + /// + /// Gets the command to open the profile filter. + /// public ICommand OpenProfileFilterCommand => new RelayCommand(_ => OpenProfileFilterAction()); private void OpenProfileFilterAction() @@ -882,6 +1055,9 @@ private void OpenProfileFilterAction() ProfileFilterIsOpen = true; } + /// + /// Gets the command to apply the profile filter. + /// public ICommand ApplyProfileFilterCommand => new RelayCommand(_ => ApplyProfileFilterAction()); private void ApplyProfileFilterAction() @@ -891,6 +1067,9 @@ private void ApplyProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to clear the profile filter. + /// public ICommand ClearProfileFilterCommand => new RelayCommand(_ => ClearProfileFilterAction()); private void ClearProfileFilterAction() @@ -908,6 +1087,9 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to expand all profile groups. + /// public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); private void ExpandAllProfileGroupsAction() @@ -915,6 +1097,9 @@ private void ExpandAllProfileGroupsAction() SetIsExpandedForAllProfileGroups(true); } + /// + /// Gets the command to collapse all profile groups. + /// public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); private void CollapseAllProfileGroupsAction() @@ -931,6 +1116,9 @@ private bool AdditionalCommands_CanExecute(object parameter) !ConfigurationManager.Current.IsChildWindowOpen; } + /// + /// Gets the command to open network connections. + /// public ICommand OpenNetworkConnectionsCommand => new RelayCommand(_ => OpenNetworkConnectionsAction(), AdditionalCommands_CanExecute); @@ -939,6 +1127,9 @@ private void OpenNetworkConnectionsAction() OpenNetworkConnectionsAsync().ConfigureAwait(false); } + /// + /// Gets the command to open IP Scanner. + /// public ICommand IPScannerCommand => new RelayCommand(_ => IPScannerAction(), AdditionalCommands_CanExecute); private void IPScannerAction() @@ -953,6 +1144,9 @@ private void IPScannerAction() $"{ipTuple.Item1}/{Subnetmask.ConvertSubnetmaskToCidr(ipTuple.Item2)}"); } + /// + /// Gets the command to flush DNS. + /// public ICommand FlushDNSCommand => new RelayCommand(_ => FlushDNSAction(), AdditionalCommands_CanExecute); private void FlushDNSAction() @@ -960,6 +1154,9 @@ private void FlushDNSAction() FlushDNSAsync().ConfigureAwait(false); } + /// + /// Gets the command to release and renew IP address. + /// public ICommand ReleaseRenewCommand => new RelayCommand(_ => ReleaseRenewAction(), AdditionalCommands_CanExecute); private void ReleaseRenewAction() @@ -967,6 +1164,9 @@ private void ReleaseRenewAction() ReleaseRenewAsync(IPConfigReleaseRenewMode.ReleaseRenew).ConfigureAwait(false); } + /// + /// Gets the command to release IP address. + /// public ICommand ReleaseCommand => new RelayCommand(_ => ReleaseAction(), AdditionalCommands_CanExecute); private void ReleaseAction() @@ -974,6 +1174,9 @@ private void ReleaseAction() ReleaseRenewAsync(IPConfigReleaseRenewMode.Release).ConfigureAwait(false); } + /// + /// Gets the command to renew IP address. + /// public ICommand RenewCommand => new RelayCommand(_ => RenewAction(), AdditionalCommands_CanExecute); private void RenewAction() @@ -981,6 +1184,9 @@ private void RenewAction() ReleaseRenewAsync(IPConfigReleaseRenewMode.Renew).ConfigureAwait(false); } + /// + /// Gets the command to release and renew IPv6 address. + /// public ICommand ReleaseRenew6Command => new RelayCommand(_ => ReleaseRenew6Action(), AdditionalCommands_CanExecute); private void ReleaseRenew6Action() @@ -988,6 +1194,9 @@ private void ReleaseRenew6Action() ReleaseRenewAsync(IPConfigReleaseRenewMode.ReleaseRenew6).ConfigureAwait(false); } + /// + /// Gets the command to release IPv6 address. + /// public ICommand Release6Command => new RelayCommand(_ => Release6Action(), AdditionalCommands_CanExecute); private void Release6Action() @@ -995,6 +1204,9 @@ private void Release6Action() ReleaseRenewAsync(IPConfigReleaseRenewMode.Release6).ConfigureAwait(false); } + /// + /// Gets the command to renew IPv6 address. + /// public ICommand Renew6Command => new RelayCommand(_ => Renew6Action(), AdditionalCommands_CanExecute); private void Renew6Action() @@ -1002,6 +1214,9 @@ private void Renew6Action() ReleaseRenewAsync(IPConfigReleaseRenewMode.Renew).ConfigureAwait(false); } + /// + /// Gets the command to add an IPv4 address. + /// public ICommand AddIPv4AddressCommand => new RelayCommand(_ => AddIPv4AddressAction().ConfigureAwait(false), AdditionalCommands_CanExecute); @@ -1027,6 +1242,9 @@ private async Task AddIPv4AddressAction() await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); } + /// + /// Gets the command to remove an IPv4 address. + /// public ICommand RemoveIPv4AddressCommand => new RelayCommand(_ => RemoveIPv4AddressAction().ConfigureAwait(false), AdditionalCommands_CanExecute); @@ -1437,6 +1655,9 @@ private void StopBandwidthMeter() _bandwidthMeter.Stop(); } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { _isViewActive = true; @@ -1446,6 +1667,9 @@ public void OnViewVisible() ResumeBandwidthMeter(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { StopBandwidthMeter(); diff --git a/Source/NETworkManager/ViewModels/OKCancelMessageViewModel.cs b/Source/NETworkManager/ViewModels/OKCancelMessageViewModel.cs index 63f29342b8..ba61091858 100644 --- a/Source/NETworkManager/ViewModels/OKCancelMessageViewModel.cs +++ b/Source/NETworkManager/ViewModels/OKCancelMessageViewModel.cs @@ -4,8 +4,20 @@ namespace NETworkManager.ViewModels; +/// +/// Represents the ViewModel for a message dialog with OK and Cancel options. +/// public class OKCancelMessageViewModel : ViewModelBase { + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when the OK button is clicked. + /// The action to execute when the Cancel button is clicked. + /// The message to display. + /// The icon to display in the message window. + /// The text for the OK button. + /// The text for the Cancel button. public OKCancelMessageViewModel(Action okCommand, Action cancelHandler, string message, ChildWindowIcon icon = ChildWindowIcon.Info, string okButtonText = null, string cancelButtonText = null) { @@ -18,11 +30,21 @@ public OKCancelMessageViewModel(Action okCommand, CancelButtonText = cancelButtonText ?? Localization.Resources.Strings.Cancel; } + /// + /// Gets the command for the OK button. + /// public ICommand OKCommand { get; } + /// + /// Gets the command for the Cancel button. + /// public ICommand CancelCommand { get; } private readonly string _message; + + /// + /// Gets the message to display. + /// public string Message { get => _message; @@ -37,6 +59,10 @@ private init } private readonly string _okButtonText; + + /// + /// Gets the text for the OK button. + /// public string OKButtonText { get => _okButtonText; @@ -51,6 +77,10 @@ private init } private readonly string _cancelButtonText; + + /// + /// Gets the text for the Cancel button. + /// public string CancelButtonText { get => _cancelButtonText; @@ -65,6 +95,10 @@ private init } private ChildWindowIcon _icon; + + /// + /// Gets the icon to display. + /// public ChildWindowIcon Icon { get => _icon; diff --git a/Source/NETworkManager/ViewModels/OKMessageViewModel.cs b/Source/NETworkManager/ViewModels/OKMessageViewModel.cs index 9044ec66c7..690e177d58 100644 --- a/Source/NETworkManager/ViewModels/OKMessageViewModel.cs +++ b/Source/NETworkManager/ViewModels/OKMessageViewModel.cs @@ -4,8 +4,18 @@ namespace NETworkManager.ViewModels; +/// +/// Represents the ViewModel for a message dialog with an OK option. +/// public class OKMessageViewModel : ViewModelBase { + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when the OK button is clicked. + /// The message to display. + /// The icon to display in the message window. + /// The text for the OK button. public OKMessageViewModel(Action okCommand, string message, ChildWindowIcon icon = ChildWindowIcon.Info, string okButtonText = null) { OKCommand = new RelayCommand(_ => okCommand(this)); @@ -16,9 +26,16 @@ public OKMessageViewModel(Action okCommand, string message, Icon = icon; } + /// + /// Gets the command for the OK button. + /// public ICommand OKCommand { get; } private readonly string _message; + + /// + /// Gets the message to display. + /// public string Message { get => _message; @@ -33,6 +50,10 @@ private init } private readonly string _okButtonText; + + /// + /// Gets the text for the OK button. + /// public string OKButtonText { get => _okButtonText; @@ -47,6 +68,10 @@ private init } private ChildWindowIcon _icon; + + /// + /// Gets the icon to display. + /// public ChildWindowIcon Icon { get => _icon; diff --git a/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs b/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs index 0211001a9c..cd04f600ca 100644 --- a/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PingMonitorHostViewModel.cs @@ -23,6 +23,9 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the Ping Monitor Host view. +/// public class PingMonitorHostViewModel : ViewModelBase, IProfileManager { #region Variables @@ -40,6 +43,9 @@ public class PingMonitorHostViewModel : ViewModelBase, IProfileManager private string _host; + /// + /// Gets or sets the host to ping. + /// public string Host { get => _host; @@ -53,10 +59,16 @@ public string Host } } + /// + /// Gets the view for the host history. + /// public ICollectionView HostHistoryView { get; } private bool _isRunning; + /// + /// Gets or sets a value indicating whether the ping monitor is running. + /// public bool IsRunning { get => _isRunning; @@ -72,6 +84,9 @@ public bool IsRunning private bool _isCanceling; + /// + /// Gets or sets a value indicating whether the ping monitor is canceling. + /// public bool IsCanceling { get => _isCanceling; @@ -87,6 +102,9 @@ public bool IsCanceling private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -102,6 +120,9 @@ public bool IsStatusMessageDisplayed private string _statusMessage; + /// + /// Gets the status message. + /// public string StatusMessage { get => _statusMessage; @@ -117,6 +138,9 @@ private set private ObservableCollection _hosts = []; + /// + /// Gets or sets the list of ping monitor views. + /// public ObservableCollection Hosts { get => _hosts; @@ -129,10 +153,16 @@ public ObservableCollection Hosts } } + /// + /// Gets the view for the hosts. + /// public ICollectionView HostsView { get; } private PingMonitorView _selectedHost; + /// + /// Gets or sets the selected host. + /// public PingMonitorView SelectedHost { get => _selectedHost; @@ -150,6 +180,9 @@ public PingMonitorView SelectedHost private ICollectionView _profiles; + /// + /// Gets the view for the profiles. + /// public ICollectionView Profiles { get => _profiles; @@ -165,6 +198,9 @@ private set private ProfileInfo _selectedProfile; + /// + /// Gets or sets the selected profile. + /// public ProfileInfo SelectedProfile { get => _selectedProfile; @@ -180,6 +216,9 @@ public ProfileInfo SelectedProfile private string _search; + /// + /// Gets or sets the search text. + /// public string Search { get => _search; @@ -203,6 +242,9 @@ public string Search private bool _isSearching; + /// + /// Gets or sets a value indicating whether a search is in progress. + /// public bool IsSearching { get => _isSearching; @@ -218,6 +260,9 @@ public bool IsSearching private bool _profileFilterIsOpen; + /// + /// Gets or sets a value indicating whether the profile filter is open. + /// public bool ProfileFilterIsOpen { get => _profileFilterIsOpen; @@ -231,12 +276,18 @@ public bool ProfileFilterIsOpen } } + /// + /// Gets the view for the profile filter tags. + /// public ICollectionView ProfileFilterTagsView { get; } private ObservableCollection ProfileFilterTags { get; } = []; private bool _profileFilterTagsMatchAny = GlobalStaticConfiguration.Profile_TagsMatchAny; + /// + /// Gets or sets a value indicating whether to match any profile filter tag. + /// public bool ProfileFilterTagsMatchAny { get => _profileFilterTagsMatchAny; @@ -252,6 +303,9 @@ public bool ProfileFilterTagsMatchAny private bool _profileFilterTagsMatchAll; + /// + /// Gets or sets a value indicating whether to match all profile filter tags. + /// public bool ProfileFilterTagsMatchAll { get => _profileFilterTagsMatchAll; @@ -267,6 +321,9 @@ public bool ProfileFilterTagsMatchAll private bool _isProfileFilterSet; + /// + /// Gets or sets a value indicating whether the profile filter is set. + /// public bool IsProfileFilterSet { get => _isProfileFilterSet; @@ -281,6 +338,10 @@ public bool IsProfileFilterSet } private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + + /// + /// Gets the group expander state store. + /// public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; @@ -288,6 +349,9 @@ public bool IsProfileFilterSet private bool _expandProfileView; + /// + /// Gets or sets a value indicating whether the profile view is expanded. + /// public bool ExpandProfileView { get => _expandProfileView; @@ -310,6 +374,9 @@ public bool ExpandProfileView private GridLength _profileWidth; + /// + /// Gets or sets the width of the profile view. + /// public GridLength ProfileWidth { get => _profileWidth; @@ -337,6 +404,10 @@ public GridLength ProfileWidth #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public PingMonitorHostViewModel(IDialogCoordinator instance) { _isLoading = true; @@ -385,6 +456,9 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to start or stop pinging the host. + /// public ICommand PingCommand => new RelayCommand(_ => PingAction(), Ping_CanExecute); private bool Ping_CanExecute(object parameter) @@ -402,6 +476,9 @@ private void PingAction() Start().ConfigureAwait(false); } + /// + /// Gets the command to ping the selected profile. + /// public ICommand PingProfileCommand => new RelayCommand(_ => PingProfileAction(), PingProfile_CanExecute); private bool PingProfile_CanExecute(object obj) @@ -415,6 +492,9 @@ private void PingProfileAction() Start().ConfigureAwait(false); } + /// + /// Gets the command to close a group of hosts. + /// public ICommand CloseGroupCommand => new RelayCommand(CloseGroupAction); private void CloseGroupAction(object group) @@ -422,6 +502,9 @@ private void CloseGroupAction(object group) RemoveGroup(group.ToString()); } + /// + /// Gets the command to export the selected host's data. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction()); private void ExportAction() @@ -429,6 +512,9 @@ private void ExportAction() SelectedHost?.Export(); } + /// + /// Gets the command to add a new profile. + /// public ICommand AddProfileCommand => new RelayCommand(_ => AddProfileAction()); private void AddProfileAction() @@ -443,6 +529,9 @@ private bool ModifyProfile_CanExecute(object obj) return SelectedProfile is { IsDynamic: false }; } + /// + /// Gets the command to edit the selected profile. + /// public ICommand EditProfileCommand => new RelayCommand(_ => EditProfileAction(), ModifyProfile_CanExecute); private void EditProfileAction() @@ -451,6 +540,9 @@ private void EditProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to copy the selected profile as a new profile. + /// public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute); private void CopyAsProfileAction() @@ -459,6 +551,9 @@ private void CopyAsProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to delete the selected profile. + /// public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute); private void DeleteProfileAction() @@ -468,6 +563,9 @@ private void DeleteProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to edit a group. + /// public ICommand EditGroupCommand => new RelayCommand(EditGroupAction); private void EditGroupAction(object group) @@ -477,6 +575,9 @@ private void EditGroupAction(object group) .ConfigureAwait(false); } + /// + /// Gets the command to open the profile filter. + /// public ICommand OpenProfileFilterCommand => new RelayCommand(_ => OpenProfileFilterAction()); private void OpenProfileFilterAction() @@ -484,6 +585,9 @@ private void OpenProfileFilterAction() ProfileFilterIsOpen = true; } + /// + /// Gets the command to apply the profile filter. + /// public ICommand ApplyProfileFilterCommand => new RelayCommand(_ => ApplyProfileFilterAction()); private void ApplyProfileFilterAction() @@ -493,6 +597,9 @@ private void ApplyProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to clear the profile filter. + /// public ICommand ClearProfileFilterCommand => new RelayCommand(_ => ClearProfileFilterAction()); private void ClearProfileFilterAction() @@ -510,6 +617,9 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to expand all profile groups. + /// public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); private void ExpandAllProfileGroupsAction() @@ -517,6 +627,9 @@ private void ExpandAllProfileGroupsAction() SetIsExpandedForAllProfileGroups(true); } + /// + /// Gets the command to collapse all profile groups. + /// public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); private void CollapseAllProfileGroupsAction() @@ -552,6 +665,9 @@ public bool SetHost(string host, string group = null) return true; } + /// + /// Starts the ping monitor. + /// public async Task Start() { IsStatusMessageDisplayed = false; @@ -695,6 +811,9 @@ private void ResizeProfile(bool dueToChangedSize) _canProfileWidthChange = true; } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { _isViewActive = true; @@ -702,6 +821,9 @@ public void OnViewVisible() RefreshProfiles(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { _isViewActive = false; diff --git a/Source/NETworkManager/ViewModels/PingMonitorSettingsViewModel.cs b/Source/NETworkManager/ViewModels/PingMonitorSettingsViewModel.cs index 4ffff9bde7..a8ba9b2ca7 100644 --- a/Source/NETworkManager/ViewModels/PingMonitorSettingsViewModel.cs +++ b/Source/NETworkManager/ViewModels/PingMonitorSettingsViewModel.cs @@ -2,6 +2,9 @@ namespace NETworkManager.ViewModels; +/// +/// Represents the settings for the Ping Monitor. +/// public class PingMonitorSettingsViewModel : ViewModelBase { #region Variables @@ -10,6 +13,9 @@ public class PingMonitorSettingsViewModel : ViewModelBase private int _timeout; + /// + /// Gets or sets the timeout in milliseconds. + /// public int Timeout { get => _timeout; @@ -28,6 +34,9 @@ public int Timeout private int _buffer; + /// + /// Gets or sets the buffer size in bytes. + /// public int Buffer { get => _buffer; @@ -46,6 +55,9 @@ public int Buffer private int _ttl; + /// + /// Gets or sets the time to live (TTL). + /// public int TTL { get => _ttl; @@ -64,6 +76,9 @@ public int TTL private bool _dontFragment; + /// + /// Gets or sets a value indicating whether the Don't Fragment flag is set. + /// public bool DontFragment { get => _dontFragment; @@ -82,6 +97,9 @@ public bool DontFragment private int _waitTime; + /// + /// Gets or sets the wait time between pings in milliseconds. + /// public int WaitTime { get => _waitTime; @@ -100,6 +118,9 @@ public int WaitTime private bool _expandHostView; + /// + /// Gets or sets a value indicating whether the host view is expanded. + /// public bool ExpandHostView { get => _expandHostView; @@ -120,6 +141,9 @@ public bool ExpandHostView #region Contructor, load settings + /// + /// Initializes a new instance of the class. + /// public PingMonitorSettingsViewModel() { _isLoading = true; diff --git a/Source/NETworkManager/ViewModels/PingMonitorViewModel.cs b/Source/NETworkManager/ViewModels/PingMonitorViewModel.cs index 159237e80f..b75affda55 100644 --- a/Source/NETworkManager/ViewModels/PingMonitorViewModel.cs +++ b/Source/NETworkManager/ViewModels/PingMonitorViewModel.cs @@ -24,10 +24,21 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the Ping Monitor feature, representing a single monitored host. +/// public class PingMonitorViewModel : ViewModelBase { #region Contructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. + /// The unique identifier for the host. + /// Action to remove the host by its GUID. + /// Tuple containing the IP address and hostname. + /// The group name the host belongs to. public PingMonitorViewModel(IDialogCoordinator instance, Guid hostId, Action removeHostByGuid, (IPAddress ipAddress, string hostname) host, string group) { @@ -62,6 +73,9 @@ public PingMonitorViewModel(IDialogCoordinator instance, Guid hostId, Action + /// Gets the title of the monitor, typically "Hostname # IP". + /// public string Title { get => _title; @@ -77,6 +91,9 @@ private set private string _hostname; + /// + /// Gets the hostname of the monitored host. + /// public string Hostname { get => _hostname; @@ -92,6 +109,9 @@ private set private readonly IPAddress _ipAddress; + /// + /// Gets the IP address of the monitored host. + /// public IPAddress IPAddress { get => _ipAddress; @@ -107,6 +127,9 @@ private init private string _group; + /// + /// Gets or sets the group the monitored host belongs to. + /// public string Group { get => _group; @@ -122,6 +145,9 @@ public string Group private bool _isRunning; + /// + /// Gets or sets a value indicating whether the ping monitoring is currently running. + /// public bool IsRunning { get => _isRunning; @@ -137,6 +163,9 @@ public bool IsRunning private bool _isReachable; + /// + /// Gets or sets a value indicating whether the host is reachable (responds to ping). + /// public bool IsReachable { get => _isReachable; @@ -152,6 +181,9 @@ public bool IsReachable private DateTime _statusTime; + /// + /// Gets the time of the last status update. + /// public DateTime StatusTime { get => _statusTime; @@ -167,6 +199,9 @@ private set private int _transmitted; + /// + /// Gets or sets the total number of ping packets transmitted. + /// public int Transmitted { get => _transmitted; @@ -182,6 +217,9 @@ public int Transmitted private int _received; + /// + /// Gets the total number of ping packets received. + /// public int Received { get => _received; @@ -197,6 +235,9 @@ private set private int _lost; + /// + /// Gets or sets the total number of ping packets lost. + /// public int Lost { get => _lost; @@ -212,6 +253,9 @@ public int Lost private double _packetLoss; + /// + /// Gets or sets the percentage of packet loss. + /// public double PacketLoss { get => _packetLoss; @@ -227,6 +271,9 @@ public double PacketLoss private long _timeMs; + /// + /// Gets or sets the round-trip time in milliseconds of the last ping. + /// public long TimeMs { get => _timeMs; @@ -240,6 +287,9 @@ public long TimeMs } } + /// + /// Initializes the time chart configuration. + /// private void InitialTimeChart() { var dayConfig = Mappers.Xy() @@ -261,12 +311,26 @@ private void InitialTimeChart() FormatterPingTime = value => $"{value} ms"; } + /// + /// Gets or sets the formatter for the date axis. + /// public Func FormatterDate { get; set; } + + /// + /// Gets or sets the formatter for the ping time axis. + /// public Func FormatterPingTime { get; set; } + + /// + /// Gets or sets the series collection for the chart. + /// public SeriesCollection Series { get; set; } private string _errorMessage; + /// + /// Gets the error message if an error occurs. + /// public string ErrorMessage { get => _errorMessage; @@ -282,6 +346,9 @@ private set private bool _isErrorMessageDisplayed; + /// + /// Gets or sets a value indicating whether the error message is displayed. + /// public bool IsErrorMessageDisplayed { get => _isErrorMessageDisplayed; @@ -297,6 +364,9 @@ public bool IsErrorMessageDisplayed private bool _expandHostView; + /// + /// Gets or sets a value indicating whether the host view is expanded. + /// public bool ExpandHostView { get => _expandHostView; @@ -314,8 +384,14 @@ public bool ExpandHostView #region ICommands & Actions + /// + /// Gets the command to start or stop the ping monitoring. + /// public ICommand PingCommand => new RelayCommand(_ => PingAction()); + /// + /// Action to start or stop the ping monitoring. + /// private void PingAction() { if (IsRunning) @@ -324,6 +400,9 @@ private void PingAction() Start(); } + /// + /// Gets the command to close the monitor and remove the host. + /// public ICommand CloseCommand => new RelayCommand(_ => CloseAction()); private void CloseAction() @@ -335,6 +414,9 @@ private void CloseAction() #region Methods + /// + /// Starts the ping monitoring. + /// public void Start() { IsErrorMessageDisplayed = false; @@ -372,6 +454,9 @@ public void Start() ping.SendAsync(IPAddress, _cancellationTokenSource.Token); } + /// + /// Stops the ping monitoring. + /// public void Stop() { if (!IsRunning) @@ -380,6 +465,9 @@ public void Stop() _cancellationTokenSource?.Cancel(); } + /// + /// Resets the time chart with empty values. + /// private void ResetTimeChart() { if (Series == null) @@ -397,6 +485,10 @@ private void ResetTimeChart() } } + /// + /// Exports the ping monitoring results to a file. + /// + /// A task that represents the asynchronous operation. public Task Export() { var childWindow = new ExportChildWindow(); @@ -448,6 +540,11 @@ await _dialogCoordinator.ShowMessageAsync(this, Strings.Error, #region Events + /// + /// Handles the PingReceived event. Updates statistics and the chart. + /// + /// The source of the event. + /// The instance containing the event data. private void Ping_PingReceived(object sender, PingReceivedArgs e) { // Calculate statistics @@ -496,11 +593,21 @@ private void Ping_PingReceived(object sender, PingReceivedArgs e) _pingInfoList.Add(e.Args); } + /// + /// Handles the UserHasCanceled event. Stops the monitoring. + /// + /// The source of the event. + /// The instance containing the event data. private void Ping_UserHasCanceled(object sender, EventArgs e) { IsRunning = false; } + /// + /// Handles the HostnameResolved event. Updates the hostname and title if necessary. + /// + /// The source of the event. + /// The instance containing the event data. private void Ping_HostnameResolved(object sender, HostnameArgs e) { // Update title if name was not set in the constructor @@ -510,6 +617,11 @@ private void Ping_HostnameResolved(object sender, HostnameArgs e) Hostname = e.Hostname; } + /// + /// Handles the PingException event. Stops the monitoring and displays the error. + /// + /// The source of the event. + /// The instance containing the event data. private void Ping_PingException(object sender, PingExceptionArgs e) { IsRunning = false; diff --git a/Source/NETworkManager/ViewModels/PortProfileViewModel.cs b/Source/NETworkManager/ViewModels/PortProfileViewModel.cs index fb1e1cbe77..21c046c319 100644 --- a/Source/NETworkManager/ViewModels/PortProfileViewModel.cs +++ b/Source/NETworkManager/ViewModels/PortProfileViewModel.cs @@ -5,6 +5,9 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for managing a port profile. +/// public class PortProfileViewModel : ViewModelBase { private readonly PortProfileInfo _info; @@ -20,6 +23,13 @@ public class PortProfileViewModel : ViewModelBase private string _ports; + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when saving. + /// The action to execute when cancelling. + /// Indicates whether the profile is being edited. + /// The port profile information. public PortProfileViewModel(Action saveCommand, Action cancelHandler, bool isEdited = false, PortProfileInfo info = null) { @@ -43,10 +53,19 @@ public PortProfileViewModel(Action saveCommand, Action + /// Gets the command to save the profile. + /// public ICommand SaveCommand { get; } + /// + /// Gets the command to cancel the operation. + /// public ICommand CancelCommand { get; } + /// + /// Gets or sets the name of the profile. + /// public string Name { get => _name; @@ -64,6 +83,9 @@ public string Name } } + /// + /// Gets or sets the ports associated with the profile. + /// public string Ports { get => _ports; @@ -81,6 +103,9 @@ public string Ports } } + /// + /// Gets or sets a value indicating whether the profile information has changed. + /// public bool InfoChanged { get => _infoChanged; @@ -94,6 +119,9 @@ public bool InfoChanged } } + /// + /// Gets or sets a value indicating whether the profile is being edited. + /// public bool IsEdited { get => _isEdited; diff --git a/Source/NETworkManager/ViewModels/PortProfilesViewModel.cs b/Source/NETworkManager/ViewModels/PortProfilesViewModel.cs index 03dde8eac0..7e62978bde 100644 --- a/Source/NETworkManager/ViewModels/PortProfilesViewModel.cs +++ b/Source/NETworkManager/ViewModels/PortProfilesViewModel.cs @@ -11,12 +11,20 @@ namespace NETworkManager.ViewModels; +/// +/// Represents the view model for managing port profiles. +/// public class PortProfilesViewModel : ViewModelBase { private string _search; private IList _selectedPortProfiles = new ArrayList(); + /// + /// Initializes a new instance of the class. + /// + /// The action to execute when the OK command is invoked. + /// The action to execute when the Cancel command is invoked. public PortProfilesViewModel(Action okCommand, Action cancelHandler) { OKCommand = new RelayCommand(_ => okCommand(this)); @@ -41,10 +49,19 @@ public PortProfilesViewModel(Action okCommand, Action + /// Gets the command to confirm the selection. + /// public ICommand OKCommand { get; } + /// + /// Gets the command to cancel the operation. + /// public ICommand CancelCommand { get; } + /// + /// Gets or sets the search text to filter the port profiles. + /// public string Search { get => _search; @@ -61,8 +78,14 @@ public string Search } } + /// + /// Gets the collection of port profiles. + /// public ICollectionView PortProfiles { get; } + /// + /// Gets or sets the list of selected port profiles. + /// public IList SelectedPortProfiles { get => _selectedPortProfiles; @@ -76,6 +99,10 @@ public IList SelectedPortProfiles } } + /// + /// Gets the selected port profiles as a typed collection. + /// + /// A collection of selected . public IEnumerable GetSelectedPortProfiles() { return new List(SelectedPortProfiles.Cast()); diff --git a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs index 42b405525f..07dc2fafdf 100644 --- a/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs +++ b/Source/NETworkManager/ViewModels/PortScannerHostViewModel.cs @@ -18,6 +18,9 @@ namespace NETworkManager.ViewModels; +/// +/// The view model for the Port Scanner host, managing tabs and profiles. +/// public class PortScannerHostViewModel : ViewModelBase, IProfileManager { #region Variables @@ -25,10 +28,16 @@ public class PortScannerHostViewModel : ViewModelBase, IProfileManager private readonly DispatcherTimer _searchDispatcherTimer = new(); private bool _searchDisabled; + /// + /// Gets the InterTabClient for Dragablz. + /// public IInterTabClient InterTabClient { get; } private string _interTabPartition; + /// + /// Gets or sets the InterTab partition identifier. + /// public string InterTabPartition { get => _interTabPartition; @@ -42,6 +51,9 @@ public string InterTabPartition } } + /// + /// Gets the collection of tab items. + /// public ObservableCollection TabItems { get; } private readonly bool _isLoading; @@ -49,6 +61,9 @@ public string InterTabPartition private int _selectedTabIndex; + /// + /// Gets or sets the index of the selected tab. + /// public int SelectedTabIndex { get => _selectedTabIndex; @@ -66,6 +81,9 @@ public int SelectedTabIndex private ICollectionView _profiles; + /// + /// Gets the collection of filtered profiles. + /// public ICollectionView Profiles { get => _profiles; @@ -81,6 +99,9 @@ private set private ProfileInfo _selectedProfile = new(); + /// + /// Gets or sets the selected profile. + /// public ProfileInfo SelectedProfile { get => _selectedProfile; @@ -96,6 +117,9 @@ public ProfileInfo SelectedProfile private string _search; + /// + /// Gets or sets the search query for filtering profiles. + /// public string Search { get => _search; @@ -119,6 +143,9 @@ public string Search private bool _isSearching; + /// + /// Gets or sets a value indicating whether a search is currently active. + /// public bool IsSearching { get => _isSearching; @@ -134,6 +161,9 @@ public bool IsSearching private bool _profileFilterIsOpen; + /// + /// Gets or sets a value indicating whether the profile filter flyout is open. + /// public bool ProfileFilterIsOpen { get => _profileFilterIsOpen; @@ -147,12 +177,18 @@ public bool ProfileFilterIsOpen } } + /// + /// Gets the collection view for profile filter tags. + /// public ICollectionView ProfileFilterTagsView { get; } private ObservableCollection ProfileFilterTags { get; } = []; private bool _profileFilterTagsMatchAny = GlobalStaticConfiguration.Profile_TagsMatchAny; + /// + /// Gets or sets a value indicating whether to match any selected tag in the filter. + /// public bool ProfileFilterTagsMatchAny { get => _profileFilterTagsMatchAny; @@ -168,6 +204,9 @@ public bool ProfileFilterTagsMatchAny private bool _profileFilterTagsMatchAll; + /// + /// Gets or sets a value indicating whether to match all selected tags in the filter. + /// public bool ProfileFilterTagsMatchAll { get => _profileFilterTagsMatchAll; @@ -183,6 +222,9 @@ public bool ProfileFilterTagsMatchAll private bool _isProfileFilterSet; + /// + /// Gets or sets a value indicating whether a profile filter is currently applied. + /// public bool IsProfileFilterSet { get => _isProfileFilterSet; @@ -197,6 +239,10 @@ public bool IsProfileFilterSet } private readonly GroupExpanderStateStore _groupExpanderStateStore = new(); + + /// + /// Gets the store for group expander states. + /// public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore; private bool _canProfileWidthChange = true; @@ -204,6 +250,9 @@ public bool IsProfileFilterSet private bool _expandProfileView; + /// + /// Gets or sets a value indicating whether the profile view is expanded. + /// public bool ExpandProfileView { get => _expandProfileView; @@ -226,6 +275,9 @@ public bool ExpandProfileView private GridLength _profileWidth; + /// + /// Gets or sets the width of the profile view. + /// public GridLength ProfileWidth { get => _profileWidth; @@ -253,6 +305,9 @@ public GridLength ProfileWidth #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public PortScannerHostViewModel() { _isLoading = true; @@ -301,6 +356,9 @@ private void LoadSettings() #region ICommand & Actions + /// + /// Gets the command to add a new tab. + /// public ICommand AddTabCommand => new RelayCommand(_ => AddTabAction()); private void AddTabAction() @@ -308,6 +366,9 @@ private void AddTabAction() AddTab(); } + /// + /// Gets the command to scan the selected profile. + /// public ICommand ScanProfileCommand => new RelayCommand(_ => ScanProfileAction(), ScanProfile_CanExecute); private bool ScanProfile_CanExecute(object obj) @@ -320,6 +381,9 @@ private void ScanProfileAction() AddTab(SelectedProfile); } + /// + /// Gets the command to add a new profile. + /// public ICommand AddProfileCommand => new RelayCommand(_ => AddProfileAction()); private void AddProfileAction() @@ -334,6 +398,9 @@ private bool ModifyProfile_CanExecute(object obj) return SelectedProfile is { IsDynamic: false }; } + /// + /// Gets the command to edit the selected profile. + /// public ICommand EditProfileCommand => new RelayCommand(_ => EditProfileAction(), ModifyProfile_CanExecute); private void EditProfileAction() @@ -342,6 +409,9 @@ private void EditProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to copy the selected profile. + /// public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute); private void CopyAsProfileAction() @@ -350,6 +420,9 @@ private void CopyAsProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to delete the selected profile. + /// public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute); private void DeleteProfileAction() @@ -359,6 +432,9 @@ private void DeleteProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to edit a profile group. + /// public ICommand EditGroupCommand => new RelayCommand(EditGroupAction); private void EditGroupAction(object group) @@ -368,6 +444,9 @@ private void EditGroupAction(object group) .ConfigureAwait(false); } + /// + /// Gets the command to open the profile filter. + /// public ICommand OpenProfileFilterCommand => new RelayCommand(_ => OpenProfileFilterAction()); private void OpenProfileFilterAction() @@ -375,6 +454,9 @@ private void OpenProfileFilterAction() ProfileFilterIsOpen = true; } + /// + /// Gets the command to apply the profile filter. + /// public ICommand ApplyProfileFilterCommand => new RelayCommand(_ => ApplyProfileFilterAction()); private void ApplyProfileFilterAction() @@ -384,6 +466,9 @@ private void ApplyProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to clear the profile filter. + /// public ICommand ClearProfileFilterCommand => new RelayCommand(_ => ClearProfileFilterAction()); private void ClearProfileFilterAction() @@ -401,6 +486,9 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to expand all profile groups. + /// public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); private void ExpandAllProfileGroupsAction() @@ -408,13 +496,19 @@ private void ExpandAllProfileGroupsAction() SetIsExpandedForAllProfileGroups(true); } + /// + /// Gets the command to collapse all profile groups. + /// public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); private void CollapseAllProfileGroupsAction() { SetIsExpandedForAllProfileGroups(false); } - + + /// + /// Gets the callback for closing a tab item. + /// public ItemActionCallback CloseItemCommand => CloseItemAction; private static void CloseItemAction(ItemActionCallbackArgs args) @@ -461,6 +555,11 @@ private void ResizeProfile(bool dueToChangedSize) _canProfileWidthChange = true; } + /// + /// Adds a new tab with the specified host and ports. + /// + /// The host to scan. + /// The ports to scan. public void AddTab(string host = null, string ports = null) { var tabId = Guid.NewGuid(); @@ -476,6 +575,9 @@ private void AddTab(ProfileInfo profile) AddTab(profile.PortScanner_Host, profile.PortScanner_Ports); } + /// + /// Called when the view becomes visible. + /// public void OnViewVisible() { _isViewActive = true; @@ -483,6 +585,9 @@ public void OnViewVisible() RefreshProfiles(); } + /// + /// Called when the view is hidden. + /// public void OnViewHide() { _isViewActive = false; diff --git a/Source/NETworkManager/ViewModels/PortScannerSettingsViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerSettingsViewModel.cs index d3b10a7ada..8869701c0e 100644 --- a/Source/NETworkManager/ViewModels/PortScannerSettingsViewModel.cs +++ b/Source/NETworkManager/ViewModels/PortScannerSettingsViewModel.cs @@ -14,6 +14,9 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the Port Scanner settings. +/// public class PortScannerSettingsViewModel : ViewModelBase { #region Variables @@ -22,10 +25,16 @@ public class PortScannerSettingsViewModel : ViewModelBase private readonly IDialogCoordinator _dialogCoordinator; + /// + /// Gets the collection view of port profiles. + /// public ICollectionView PortProfiles { get; } private PortProfileInfo _selectedPortProfile = new(); + /// + /// Gets or sets the selected port profile. + /// public PortProfileInfo SelectedPortProfile { get => _selectedPortProfile; @@ -41,6 +50,9 @@ public PortProfileInfo SelectedPortProfile private bool _showAllResults; + /// + /// Gets or sets a value indicating whether to show all results (open and closed ports). + /// public bool ShowAllResults { get => _showAllResults; @@ -59,6 +71,9 @@ public bool ShowAllResults private int _timeout; + /// + /// Gets or sets the timeout for port scanning in milliseconds. + /// public int Timeout { get => _timeout; @@ -77,6 +92,9 @@ public int Timeout private bool _resolveHostname; + /// + /// Gets or sets a value indicating whether to resolve hostnames. + /// public bool ResolveHostname { get => _resolveHostname; @@ -95,6 +113,9 @@ public bool ResolveHostname private int _maxHostThreads; + /// + /// Gets or sets the maximum number of threads for scanning hosts. + /// public int MaxHostThreads { get => _maxHostThreads; @@ -113,6 +134,9 @@ public int MaxHostThreads private int _maxPortThreads; + /// + /// Gets or sets the maximum number of threads for scanning ports. + /// public int MaxPortThreads { get => _maxPortThreads; @@ -133,6 +157,10 @@ public int MaxPortThreads #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. public PortScannerSettingsViewModel(IDialogCoordinator instance) { _isLoading = true; diff --git a/Source/NETworkManager/ViewModels/PortScannerViewModel.cs b/Source/NETworkManager/ViewModels/PortScannerViewModel.cs index b257f5f1b0..8a73c5ac6f 100644 --- a/Source/NETworkManager/ViewModels/PortScannerViewModel.cs +++ b/Source/NETworkManager/ViewModels/PortScannerViewModel.cs @@ -25,6 +25,9 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the Port Scanner feature. +/// public class PortScannerViewModel : ViewModelBase { #region Variables @@ -40,6 +43,9 @@ public class PortScannerViewModel : ViewModelBase private string _host; + /// + /// Gets or sets the host to scan. + /// public string Host { get => _host; @@ -53,10 +59,16 @@ public string Host } } + /// + /// Gets the collection view for the host history. + /// public ICollectionView HostHistoryView { get; } private string _ports; + /// + /// Gets or sets the ports to scan (e.g., "80, 443, 1-100"). + /// public string Ports { get => _ports; @@ -70,10 +82,16 @@ public string Ports } } + /// + /// Gets the collection view for the ports history. + /// public ICollectionView PortsHistoryView { get; } private bool _isRunning; + /// + /// Gets or sets a value indicating whether the scan is currently running. + /// public bool IsRunning { get => _isRunning; @@ -90,6 +108,9 @@ public bool IsRunning private bool _isCanceling; + /// + /// Gets or sets a value indicating whether the scan is being canceled. + /// public bool IsCanceling { get => _isCanceling; @@ -105,6 +126,9 @@ public bool IsCanceling private ObservableCollection _results = []; + /// + /// Gets or sets the collection of scan results. + /// public ObservableCollection Results { get => _results; @@ -117,10 +141,16 @@ public ObservableCollection Results } } + /// + /// Gets the collection view for the scan results. + /// public ICollectionView ResultsView { get; } private PortScannerPortInfo _selectedResult; + /// + /// Gets or sets the currently selected scan result. + /// public PortScannerPortInfo SelectedResult { get => _selectedResult; @@ -136,6 +166,9 @@ public PortScannerPortInfo SelectedResult private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of currently selected scan results (for multi-selection). + /// public IList SelectedResults { get => _selectedResults; @@ -151,6 +184,9 @@ public IList SelectedResults private int _portsToScan; + /// + /// Gets or sets the total number of ports to scan. + /// public int PortsToScan { get => _portsToScan; @@ -166,6 +202,9 @@ public int PortsToScan private int _portsScanned; + /// + /// Gets or sets the number of ports already scanned. + /// public int PortsScanned { get => _portsScanned; @@ -181,6 +220,9 @@ public int PortsScanned private bool _preparingScan; + /// + /// Gets or sets a value indicating whether the scan is being prepared. + /// public bool PreparingScan { get => _preparingScan; @@ -196,6 +238,9 @@ public bool PreparingScan private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -211,6 +256,9 @@ public bool IsStatusMessageDisplayed private string _statusMessage; + /// + /// Gets the status message to display. + /// public string StatusMessage { get => _statusMessage; @@ -228,6 +276,13 @@ private set #region Constructor, load settings, shutdown + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. + /// The unique identifier for the tab. + /// The initial host to scan. + /// The initial ports to scan. public PortScannerViewModel(IDialogCoordinator instance, Guid tabId, string host, string port) { _dialogCoordinator = instance; diff --git a/Source/NETworkManager/ViewModels/TracerouteViewModel.cs b/Source/NETworkManager/ViewModels/TracerouteViewModel.cs index 1f31094884..b0f4a1f0b7 100644 --- a/Source/NETworkManager/ViewModels/TracerouteViewModel.cs +++ b/Source/NETworkManager/ViewModels/TracerouteViewModel.cs @@ -26,6 +26,9 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the Traceroute feature. +/// public class TracerouteViewModel : ViewModelBase { #region Variables @@ -40,6 +43,9 @@ public class TracerouteViewModel : ViewModelBase private string _host; + /// + /// Gets or sets the host address or hostname to trace. + /// public string Host { get => _host; @@ -53,10 +59,16 @@ public string Host } } + /// + /// Gets the collection view for the host history. + /// public ICollectionView HostHistoryView { get; } private bool _isRunning; + /// + /// Gets or sets a value indicating whether a traceroute is currently running. + /// public bool IsRunning { get => _isRunning; @@ -72,6 +84,9 @@ public bool IsRunning private bool _cancelTrace; + /// + /// Gets or sets a value indicating whether the trace should be cancelled. + /// public bool CancelTrace { get => _cancelTrace; @@ -87,6 +102,9 @@ public bool CancelTrace private ObservableCollection _results = new(); + /// + /// Gets or sets the collection of traceroute hop results. + /// public ObservableCollection Results { get => _results; @@ -99,10 +117,16 @@ public ObservableCollection Results } } + /// + /// Gets the collection view for the traceroute results. + /// public ICollectionView ResultsView { get; } private TracerouteHopInfo _selectedResult; + /// + /// Gets or sets the currently selected traceroute result hop. + /// public TracerouteHopInfo SelectedResult { get => _selectedResult; @@ -118,6 +142,9 @@ public TracerouteHopInfo SelectedResult private IList _selectedResults = new ArrayList(); + /// + /// Gets or sets the list of currently selected traceroute result hops (for multi-selection). + /// public IList SelectedResults { get => _selectedResults; @@ -135,6 +162,9 @@ public IList SelectedResults private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -150,6 +180,9 @@ public bool IsStatusMessageDisplayed private string _statusMessage; + /// + /// Gets the status message to display. + /// public string StatusMessage { get => _statusMessage; @@ -167,6 +200,12 @@ private set #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// + /// The dialog coordinator instance. + /// The unique identifier for the tab. + /// The initial host to trace. public TracerouteViewModel(IDialogCoordinator instance, Guid tabId, string host) { _dialogCoordinator = instance; @@ -187,6 +226,9 @@ public TracerouteViewModel(IDialogCoordinator instance, Guid tabId, string host) LoadSettings(); } + /// + /// Called when the view is loaded. Starts the trace if it's the first load and a host is specified. + /// public void OnLoaded() { if (!_firstLoad) @@ -206,6 +248,9 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to start or stop the traceroute. + /// public ICommand TraceCommand => new RelayCommand(_ => TraceAction(), Trace_CanExecute); private bool Trace_CanExecute(object parameter) @@ -223,6 +268,9 @@ private void TraceAction() StartTrace().ConfigureAwait(false); } + /// + /// Gets the command to redirect the selected result's data to another application. + /// public ICommand RedirectDataToApplicationCommand => new RelayCommand(RedirectDataToApplicationAction); private void RedirectDataToApplicationAction(object name) @@ -237,6 +285,9 @@ private void RedirectDataToApplicationAction(object name) EventSystem.RedirectToApplication(applicationName, host); } + /// + /// Gets the command to perform a DNS lookup for the selected hop. + /// public ICommand PerformDNSLookupCommand => new RelayCommand(PerformDNSLookupAction); private void PerformDNSLookupAction(object data) @@ -244,6 +295,9 @@ private void PerformDNSLookupAction(object data) EventSystem.RedirectToApplication(ApplicationName.DNSLookup, data.ToString()); } + /// + /// Gets the command to copy the round-trip time to the clipboard. + /// public ICommand CopyTimeToClipboardCommand => new RelayCommand(CopyTimeToClipboardAction); private void CopyTimeToClipboardAction(object timeIdentifier) @@ -259,6 +313,9 @@ private void CopyTimeToClipboardAction(object timeIdentifier) ClipboardHelper.SetClipboard(time); } + /// + /// Gets the command to export the traceroute results. + /// public ICommand ExportCommand => new RelayCommand(_ => ExportAction()); private void ExportAction() diff --git a/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs b/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs index 9b5c61c1a6..33fb857215 100644 --- a/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs +++ b/Source/NETworkManager/ViewModels/WakeOnLANViewModel.cs @@ -21,6 +21,9 @@ namespace NETworkManager.ViewModels; +/// +/// ViewModel for the Wake on LAN feature. +/// public class WakeOnLANViewModel : ViewModelBase, IProfileManager { #region Variables @@ -33,6 +36,9 @@ public class WakeOnLANViewModel : ViewModelBase, IProfileManager private bool _isRunning; + /// + /// Gets or sets a value indicating whether the Wake on LAN operation is running. + /// public bool IsRunning { get => _isRunning; @@ -46,10 +52,16 @@ public bool IsRunning } } + /// + /// Gets the collection view for the MAC address history. + /// public ICollectionView MACAddressHistoryView { get; } private string _macAddress; + /// + /// Gets or sets the MAC address to wake up. + /// public string MACAddress { get => _macAddress; @@ -63,10 +75,16 @@ public string MACAddress } } + /// + /// Gets the collection view for the broadcast address history. + /// public ICollectionView BroadcastHistoryView { get; } private string _broadcast; + /// + /// Gets or sets the broadcast address. + /// public string Broadcast { get => _broadcast; @@ -82,6 +100,9 @@ public string Broadcast private bool _isStatusMessageDisplayed; + /// + /// Gets or sets a value indicating whether the status message is displayed. + /// public bool IsStatusMessageDisplayed { get => _isStatusMessageDisplayed; @@ -97,6 +118,9 @@ public bool IsStatusMessageDisplayed private string _statusMessage; + /// + /// Gets the status message to display. + /// public string StatusMessage { get => _statusMessage; @@ -114,6 +138,9 @@ private set private ICollectionView _profiles; + /// + /// Gets the collection view for the profiles. + /// public ICollectionView Profiles { get => _profiles; @@ -129,6 +156,9 @@ private set private ProfileInfo _selectedProfile = new(); + /// + /// Gets or sets the currently selected profile. + /// public ProfileInfo SelectedProfile { get => _selectedProfile; @@ -150,6 +180,9 @@ public ProfileInfo SelectedProfile private string _search; + /// + /// Gets or sets the search text for filtering profiles. + /// public string Search { get => _search; @@ -173,6 +206,9 @@ public string Search private bool _isSearching; + /// + /// Gets or sets a value indicating whether a search operation is in progress. + /// public bool IsSearching { get => _isSearching; @@ -188,6 +224,9 @@ public bool IsSearching private bool _profileFilterIsOpen; + /// + /// Gets or sets a value indicating whether the profile filter flyout is open. + /// public bool ProfileFilterIsOpen { get => _profileFilterIsOpen; @@ -201,6 +240,9 @@ public bool ProfileFilterIsOpen } } + /// + /// Gets the collection view for the profile filter tags. + /// public ICollectionView ProfileFilterTagsView { get; } private ObservableCollection ProfileFilterTags { get; } = []; @@ -307,6 +349,9 @@ public GridLength ProfileWidth #region Constructor, load settings + /// + /// Initializes a new instance of the class. + /// public WakeOnLANViewModel() { _isLoading = true; @@ -349,6 +394,9 @@ private void LoadSettings() #region ICommands & Actions + /// + /// Gets the command to wake up the target. + /// public ICommand WakeUpCommand => new RelayCommand(_ => WakeUpAction(), WakeUpAction_CanExecute); private bool WakeUpAction_CanExecute(object parameter) @@ -373,6 +421,9 @@ private void WakeUpAction() WakeUp(info).ConfigureAwait(false); } + /// + /// Gets the command to wake up the selected profile. + /// public ICommand WakeUpProfileCommand => new RelayCommand(_ => WakeUpProfileAction()); private void WakeUpProfileAction() @@ -380,6 +431,9 @@ private void WakeUpProfileAction() WakeUp(NETworkManager.Profiles.Application.WakeOnLAN.CreateInfo(SelectedProfile)).ConfigureAwait(false); } + /// + /// Gets the command to add a new profile. + /// public ICommand AddProfileCommand => new RelayCommand(_ => AddProfileAction()); private void AddProfileAction() @@ -394,6 +448,9 @@ private bool ModifyProfile_CanExecute(object obj) return SelectedProfile is { IsDynamic: false }; } + /// + /// Gets the command to edit the selected profile. + /// public ICommand EditProfileCommand => new RelayCommand(_ => EditProfileAction(), ModifyProfile_CanExecute); private void EditProfileAction() @@ -402,6 +459,9 @@ private void EditProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to copy the selected profile as a new profile. + /// public ICommand CopyAsProfileCommand => new RelayCommand(_ => CopyAsProfileAction(), ModifyProfile_CanExecute); private void CopyAsProfileAction() @@ -410,6 +470,9 @@ private void CopyAsProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to delete the selected profile. + /// public ICommand DeleteProfileCommand => new RelayCommand(_ => DeleteProfileAction(), ModifyProfile_CanExecute); private void DeleteProfileAction() @@ -419,6 +482,9 @@ private void DeleteProfileAction() .ConfigureAwait(false); } + /// + /// Gets the command to edit a profile group. + /// public ICommand EditGroupCommand => new RelayCommand(EditGroupAction); private void EditGroupAction(object group) @@ -428,6 +494,9 @@ private void EditGroupAction(object group) .ConfigureAwait(false); } + /// + /// Gets the command to open the profile filter flyout. + /// public ICommand OpenProfileFilterCommand => new RelayCommand(_ => OpenProfileFilterAction()); private void OpenProfileFilterAction() @@ -435,6 +504,9 @@ private void OpenProfileFilterAction() ProfileFilterIsOpen = true; } + /// + /// Gets the command to apply the profile filter. + /// public ICommand ApplyProfileFilterCommand => new RelayCommand(_ => ApplyProfileFilterAction()); private void ApplyProfileFilterAction() @@ -444,6 +516,9 @@ private void ApplyProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to clear the profile filter. + /// public ICommand ClearProfileFilterCommand => new RelayCommand(_ => ClearProfileFilterAction()); private void ClearProfileFilterAction() @@ -461,6 +536,9 @@ private void ClearProfileFilterAction() ProfileFilterIsOpen = false; } + /// + /// Gets the command to expand all profile groups. + /// public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction()); private void ExpandAllProfileGroupsAction() @@ -468,6 +546,9 @@ private void ExpandAllProfileGroupsAction() SetIsExpandedForAllProfileGroups(true); } + /// + /// Gets the command to collapse all profile groups. + /// public ICommand CollapseAllProfileGroupsCommand => new RelayCommand(_ => CollapseAllProfileGroupsAction()); private void CollapseAllProfileGroupsAction() diff --git a/Website/docs/changelog/next-release.md b/Website/docs/changelog/next-release.md index 9fddaa0f27..d4006b60c3 100644 --- a/Website/docs/changelog/next-release.md +++ b/Website/docs/changelog/next-release.md @@ -80,4 +80,5 @@ Release date: **xx.xx.2025** - Migrated existing credential and profile dialogs to use DialogHelper, improving usability, accessibility and maintainability across the app. [#3231](https://github.com/BornToBeRoot/NETworkManager/pull/3231) - Language files updated via [#transifex](https://github.com/BornToBeRoot/NETworkManager/pulls?q=author%3Aapp%2Ftransifex-integration) - Dependencies updated via [#dependabot](https://github.com/BornToBeRoot/NETworkManager/pulls?q=author%3Aapp%2Fdependabot) +- Add Junie/Gemini 3 generated XML documentation headers for roughly half of the ViewModels. This might help with readability. [#3251](https://github.com/BornToBeRoot/NETworkManager/pull/3251) - Generate project guidelines for Rider's coding agent Junie using itself as generator. [#3250](https://github.com/BornToBeRoot/NETworkManager/pull/3250)