Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/NETworkManager/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NETworkManager.Helpers;
using NETworkManager.Utilities;
using NETworkManager.Models.Settings;
using System;
using System.Diagnostics;
Expand Down Expand Up @@ -54,7 +54,7 @@ private void Application_Startup(object sender, StartupEventArgs e)

if (CommandLineManager.Current.Help)
{
StartupUri = new Uri("/Views/Help/HelpCommandLineWindow.xaml", UriKind.Relative);
StartupUri = new Uri("/Views/CommandLineHelpWindow.xaml", UriKind.Relative);
return;
}

Expand All @@ -73,7 +73,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
else
{
// Bring the already running application into the foreground
SingleInstanceHelper.PostMessage((IntPtr)SingleInstanceHelper.HWND_BROADCAST, SingleInstanceHelper.WM_SHOWME, IntPtr.Zero, IntPtr.Zero);
SingleInstance.PostMessage((IntPtr)SingleInstance.HWND_BROADCAST, SingleInstance.WM_SHOWME, IntPtr.Zero, IntPtr.Zero);

_singleInstanceClose = true;
Shutdown();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using MahApps.Metro.IconPacks;
using System.Windows.Controls;

namespace NETworkManager.Views
namespace NETworkManager
{
public class ApplicationViewInfo
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Windows;

namespace NETworkManager.Views
namespace NETworkManager
{
public static class ApplicationViewManager
{
Expand Down
5 changes: 3 additions & 2 deletions Source/NETworkManager/Controls/DragablzPingTabItem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NETworkManager.ViewModels;
using NETworkManager.Views.Applications;
using NETworkManager.Utilities;
using NETworkManager.ViewModels;
using NETworkManager.Views;

namespace NETworkManager.Controls
{
Expand Down
5 changes: 1 addition & 4 deletions Source/NETworkManager/Controls/DragablzPuTTYTabItem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using NETworkManager.Models.PuTTY;
using NETworkManager.ViewModels;
using System;
using System.Diagnostics;
using NETworkManager.Utilities;

namespace NETworkManager.Controls
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NETworkManager.ViewModels;
using NETworkManager.Utilities;

namespace NETworkManager.Controls
{
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Controls/PuTTYControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System;
using System.Windows.Threading;
using System.Diagnostics;
using NETworkManager.Utils;
using NETworkManager.Utilities;
using NETworkManager.Models.PuTTY;

namespace NETworkManager.Controls
Expand Down
4 changes: 1 addition & 3 deletions Source/NETworkManager/Controls/RemoteDesktopControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using NETworkManager.Models.RemoteDesktop;
using NETworkManager.ViewModels;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System;
using System.Windows.Threading;
using NETworkManager.Helpers;
using System.Diagnostics;
using NETworkManager.Utilities;

namespace NETworkManager.Controls
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Globalization;
using System.Windows.Data;
using NETworkManager.Helpers;
using NETworkManager.Utilities;
using System.Net.NetworkInformation;

namespace NETworkManager.Converters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NETworkManager.Helpers;
using NETworkManager.Models.Network;
using System;
using System.Globalization;
using System.Net;
Expand Down Expand Up @@ -28,15 +28,15 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
if (subnetmaskOrCIDR.Length < 3)
cidr = int.Parse(subnetmaskOrCIDR);
else
cidr = SubnetmaskHelper.ConvertSubnetmaskToCidr(IPAddress.Parse(subnetmaskOrCIDR));
cidr = Subnetmask.ConvertSubnetmaskToCidr(IPAddress.Parse(subnetmaskOrCIDR));

newSubnetmaskOrCIDR = newSubnetmaskOrCIDR.TrimStart('/');
int newCidr;

if (newSubnetmaskOrCIDR.Length < 3)
newCidr = int.Parse(newSubnetmaskOrCIDR);
else
newCidr = SubnetmaskHelper.ConvertSubnetmaskToCidr(IPAddress.Parse(newSubnetmaskOrCIDR));
newCidr = Subnetmask.ConvertSubnetmaskToCidr(IPAddress.Parse(newSubnetmaskOrCIDR));

// Compare
return newCidr > cidr;
Expand Down
28 changes: 0 additions & 28 deletions Source/NETworkManager/Helpers/MagicPacketHelper.cs

This file was deleted.

35 changes: 0 additions & 35 deletions Source/NETworkManager/Helpers/SubnetHelper.cs

This file was deleted.

38 changes: 0 additions & 38 deletions Source/NETworkManager/Helpers/SubnetmaskHelper.cs

This file was deleted.

9 changes: 3 additions & 6 deletions Source/NETworkManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Linq;
using NETworkManager.ViewModels;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using NETworkManager.Views.Applications;
using NETworkManager.Views.Settings;
using NETworkManager.Views;
using NETworkManager.Models.Settings;
using System.Runtime.InteropServices;
using System.Windows.Interop;
using System.Collections.Generic;
using NETworkManager.Views;
using NETworkManager.Helpers;
using NETworkManager.Utilities;
using System.Runtime.CompilerServices;
using System.Windows.Markup;
using NETworkManager.Models.Update;
Expand Down Expand Up @@ -548,7 +545,7 @@ protected override void OnSourceInitialized(EventArgs e)
private IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
// Single instance
if (msg == SingleInstanceHelper.WM_SHOWME)
if (msg == SingleInstance.WM_SHOWME)
{
ShowWindowAction();
handled = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NETworkManager.ViewModels;
using NETworkManager.Utilities;
using NETworkManager.ViewModels;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Models/Network/ARPTable.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Contains code from: https://stackoverflow.com/a/1148861/4986782
// Modified by BornToBeRoot

using NETworkManager.Helpers;
using NETworkManager.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Models/Network/ARPTableInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NETworkManager.Helpers;
using NETworkManager.Utilities;
using System.Net;
using System.Net.NetworkInformation;

Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Models/Network/NetworkInterface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.Win32;
using NETworkManager.Helpers;
using NETworkManager.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Models/Network/PingInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NETworkManager.Helpers;
using NETworkManager.Utilities;
using System;
using System.Net;
using System.Net.NetworkInformation;
Expand Down
40 changes: 34 additions & 6 deletions Source/NETworkManager/Models/Network/Subnet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NETworkManager.Helpers;
using NETworkManager.Utilities;
using System;
using System.Collections.Concurrent;
using System.Net;
Expand All @@ -10,12 +10,40 @@ namespace NETworkManager.Models.Network
public class Subnet
{
#region Static methods
// Source: https://blogs.msdn.microsoft.com/knom/2008/12/31/ip-address-calculations-with-c-subnetmasks-networks/
public static IPAddress GetIPv4NetworkAddress(IPAddress ipv4Address, IPAddress subnetmask)
{
byte[] ipv4AdressBytes = ipv4Address.GetAddressBytes();
byte[] subnetmaskBytes = subnetmask.GetAddressBytes();

byte[] broadcastBytes = new byte[ipv4AdressBytes.Length];

for (int i = 0; i < broadcastBytes.Length; i++)
broadcastBytes[i] = (byte)(ipv4AdressBytes[i] & (subnetmaskBytes[i]));

return new IPAddress(broadcastBytes);
}

// Source: https://blogs.msdn.microsoft.com/knom/2008/12/31/ip-address-calculations-with-c-subnetmasks-networks/
public static IPAddress GetIPv4Broadcast(IPAddress ipv4Address, IPAddress subnetmask)
{
byte[] ipv4AddressBytes = ipv4Address.GetAddressBytes();
byte[] subnetmaskBytes = subnetmask.GetAddressBytes();

byte[] broadcastBytes = new byte[ipv4AddressBytes.Length];

for (int i = 0; i < broadcastBytes.Length; i++)
broadcastBytes[i] = (byte)(ipv4AddressBytes[i] | (subnetmaskBytes[i] ^ 255));

return new IPAddress(broadcastBytes);
}

public static SubnetInfo CalculateIPv4Subnet(IPAddress ipv4Address, IPAddress subnetmask)
{
IPAddress networkAddress = SubnetHelper.GetIPv4NetworkAddress(ipv4Address, subnetmask);
IPAddress broadcast = SubnetHelper.GetIPv4Broadcast(ipv4Address, subnetmask);
int cidr = SubnetmaskHelper.ConvertSubnetmaskToCidr(subnetmask);
long totalIPs = SubnetmaskHelper.GetNumberIPv4Addresses(cidr);
IPAddress networkAddress = GetIPv4NetworkAddress(ipv4Address, subnetmask);
IPAddress broadcast = GetIPv4Broadcast(ipv4Address, subnetmask);
int cidr = Subnetmask.ConvertSubnetmaskToCidr(subnetmask);
long totalIPs = Subnetmask.GetNumberIPv4Addresses(cidr);

// Fix bug when /31 (host first/last can be null)
IPAddress hostFirstIP = null;
Expand Down Expand Up @@ -62,7 +90,7 @@ public static SubnetInfo[] SplitIPv4Subnet(IPAddress ipv4Address, IPAddress subn
// Calculate the current subnet
SubnetInfo subnetInfo = CalculateIPv4Subnet(ipv4Address, subnetmask);

int newCidr = SubnetmaskHelper.ConvertSubnetmaskToCidr(newSubnetmask);
int newCidr = Subnetmask.ConvertSubnetmaskToCidr(newSubnetmask);

// Get new HostBits based on SubnetBits (CIDR) // Hostbits (32 - /24 = 8 -> 00000000000000000000000011111111)
string newHostBits = (new string('1', (32 - newCidr))).PadLeft(32, '0');
Expand Down
2 changes: 1 addition & 1 deletion Source/NETworkManager/Models/Network/SubnetInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NETworkManager.Helpers;
using NETworkManager.Utilities;
using System.Net;

namespace NETworkManager.Models.Network
Expand Down
Loading