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
4 changes: 4 additions & 0 deletions Source/NETworkManager/ApplicationViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public static List<ApplicationViewInfo> List
new ApplicationViewInfo(Name.HTTPHeaders, new PackIconMaterial() { Kind = PackIconMaterialKind.Web }),
new ApplicationViewInfo(Name.SubnetCalculator, new PackIconModern() { Kind = PackIconModernKind.Calculator }),
new ApplicationViewInfo(Name.Lookup, new PackIconMaterial() { Kind = PackIconMaterialKind.Magnify }),
new ApplicationViewInfo(Name.Connections, new PackIconModern() {Kind = PackIconModernKind.Connect }),
new ApplicationViewInfo(Name.Listeners, new PackIconMaterial() {Kind = PackIconMaterialKind.Wan}),
new ApplicationViewInfo(Name.ARPTable, new PackIconMaterial() { Kind = PackIconMaterialKind.TableOfContents })
};
}
Expand All @@ -52,6 +54,8 @@ public enum Name
HTTPHeaders,
SubnetCalculator,
Lookup,
Connections,
Listeners,
ARPTable
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using NETworkManager.Models.Settings;
using NETworkManager.Utilities;
using System;
using System.Globalization;
using System.Windows.Data;
using static NETworkManager.Utilities.AutoRefreshTime;

namespace NETworkManager.Converters
{
public sealed class AutoRefreshTimeToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
TimeUnit timeUnit = (TimeUnit)value;

string timeUnitTranslated = LocalizationManager.GetStringByKey("String_TimeUnit_" + timeUnit.ToString());

if (string.IsNullOrEmpty(timeUnitTranslated))
return timeUnit.ToString();

return timeUnitTranslated;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
28 changes: 28 additions & 0 deletions Source/NETworkManager/Converters/TcpStateToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using NETworkManager.Models.Settings;
using System;
using System.Globalization;
using System.Net.NetworkInformation;
using System.Windows.Data;

namespace NETworkManager.Converters
{
public sealed class TcpStateToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
TcpState tcpState = (TcpState)value;

string status = LocalizationManager.GetStringByKey("String_TcpState_" + tcpState.ToString());

if (string.IsNullOrEmpty(status))
return tcpState.ToString();

return status;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
4 changes: 2 additions & 2 deletions Source/NETworkManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<MenuItem.Icon>
<Rectangle Width="16" Height="16" Fill="{DynamicResource BlackColorBrush}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform" Visual="{IconPacks:Modern Kind=Settings}" />
<VisualBrush Stretch="Uniform" Visual="{IconPacks:MaterialLight Kind=Cog}" />
</Rectangle.OpacityMask>
</Rectangle>
</MenuItem.Icon>
Expand Down Expand Up @@ -508,7 +508,7 @@
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Width="24" Height="24">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Uniform" Visual="{IconPacks:Modern Kind=Settings}" />
<VisualBrush Stretch="Uniform" Visual="{IconPacks:MaterialLight Kind=Cog}" />
</Rectangle.OpacityMask>
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
Expand Down
20 changes: 15 additions & 5 deletions Source/NETworkManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,13 @@ private async void MetroWindowMain_Closing(object sender, CancelEventArgs e)
SubnetCalculatorHostView subnetCalculatorHostView;
HTTPHeadersHostView httpHeadersHostView;
LookupHostView lookupHostView;
ConnectionsView connectionsView;
ListenersView listenersView;
ARPTableView arpTableView;

private ApplicationViewManager.Name? currentApplicationViewName = null;

private void ChangeApplicationView(ApplicationViewManager.Name name, EventSystemRedirectApplicationArgs args = null)
private void ChangeApplicationView(ApplicationViewManager.Name name)
{
if (currentApplicationViewName == name)
return;
Expand All @@ -448,10 +450,6 @@ private void ChangeApplicationView(ApplicationViewManager.Name name, EventSystem
if (portScannerHostView == null)
portScannerHostView = new PortScannerHostView();

// Create a new tab
if (args != null)
portScannerHostView.AddTab(args.Data);

contentControlApplication.Content = portScannerHostView;
break;
case ApplicationViewManager.Name.Ping:
Expand Down Expand Up @@ -515,6 +513,18 @@ private void ChangeApplicationView(ApplicationViewManager.Name name, EventSystem

contentControlApplication.Content = lookupHostView;
break;
case ApplicationViewManager.Name.Connections:
if (connectionsView == null)
connectionsView = new ConnectionsView();

contentControlApplication.Content = connectionsView;
break;
case ApplicationViewManager.Name.Listeners:
if (listenersView == null)
listenersView = new ListenersView();

contentControlApplication.Content = listenersView;
break;
case ApplicationViewManager.Name.ARPTable:
if (arpTableView == null)
arpTableView = new ARPTableView();
Expand Down
34 changes: 34 additions & 0 deletions Source/NETworkManager/Models/Network/Connection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Collections.Generic;
using System.Net.NetworkInformation;
using System.Threading.Tasks;

namespace NETworkManager.Models.Network
{
public class Connection
{
#region Methods
public static Task<List<ConnectionInfo>> GetActiveTcpConnectionsAsync()
{
return Task.Run(() => GetActiveTcpConnections());
}

public static List<ConnectionInfo> GetActiveTcpConnections()
{
List<ConnectionInfo> list = new List<ConnectionInfo>();

foreach (TcpConnectionInformation tcpInfo in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections())
list.Add(new ConnectionInfo(Protocol.TCP, tcpInfo.LocalEndPoint.Address, tcpInfo.LocalEndPoint.Port, tcpInfo.RemoteEndPoint.Address, tcpInfo.RemoteEndPoint.Port, tcpInfo.State));

return list;
}
#endregion

#region Enum
public enum Protocol
{
TCP
}

#endregion
}
}
42 changes: 42 additions & 0 deletions Source/NETworkManager/Models/Network/ConnectionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using NETworkManager.Utilities;
using System.Net;
using System.Net.NetworkInformation;
using static NETworkManager.Models.Network.Connection;

namespace NETworkManager.Models.Network
{
public class ConnectionInfo
{
public Protocol Protocol { get; set; }
public IPAddress LocalIPAddress { get; set; }
public int LocalPort { get; set; }
public IPAddress RemoteIPAddress { get; set; }
public int RemotePort { get; set; }
public TcpState State { get; set; }

public int LocalIPAddressInt32
{
get { return LocalIPAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ? IPv4AddressHelper.ConvertToInt32(LocalIPAddress) : 0; }
}

public int RemoteIPAddressInt32
{
get { return LocalIPAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ? IPv4AddressHelper.ConvertToInt32(RemoteIPAddress) : 0; }
}

public ConnectionInfo()
{

}

public ConnectionInfo(Protocol protocol, IPAddress localIPAddress, int localPort, IPAddress remoteIPAddress, int remotePort, TcpState state)
{
Protocol = protocol;
LocalIPAddress = localIPAddress;
LocalPort = localPort;
RemoteIPAddress = remoteIPAddress;
RemotePort = remotePort;
State = state;
}
}
}
67 changes: 67 additions & 0 deletions Source/NETworkManager/Models/Network/Listener.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System.Collections.Generic;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading.Tasks;

namespace NETworkManager.Models.Network
{
public class Listener
{
#region Methods
public static Task<List<ListenerInfo>> GetAllActiveListenersAsync()
{
return Task.Run(() => GetAllActiveListeners());

}

public static List<ListenerInfo> GetAllActiveListeners()
{
List<ListenerInfo> list = new List<ListenerInfo>();

list.AddRange(GetActiveTcpListeners());
list.AddRange(GetActiveUdpListeners());

return list;
}

public static Task<List<ListenerInfo>> GetActiveTcpListenersAsync()
{
return Task.Run(() => GetActiveTcpListeners());
}

public static List<ListenerInfo> GetActiveTcpListeners()
{
List<ListenerInfo> list = new List<ListenerInfo>();

foreach (IPEndPoint ipEndPoint in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners())
list.Add(new ListenerInfo(Protocol.TCP, ipEndPoint.Address, ipEndPoint.Port));

return list;
}

public static Task<List<ListenerInfo>> GetActiveUdpListenersAsync()
{
return Task.Run(() => GetActiveUdpListeners());
}

public static List<ListenerInfo> GetActiveUdpListeners()
{
List<ListenerInfo> list = new List<ListenerInfo>();

foreach (IPEndPoint ipEndPoint in IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners())
list.Add(new ListenerInfo(Protocol.UDP, ipEndPoint.Address, ipEndPoint.Port));

return list;
}
#endregion

#region Enum
public enum Protocol
{
TCP,
UDP
}

#endregion
}
}
30 changes: 30 additions & 0 deletions Source/NETworkManager/Models/Network/ListenerInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using NETworkManager.Utilities;
using System.Net;
using static NETworkManager.Models.Network.Listener;

namespace NETworkManager.Models.Network
{
public class ListenerInfo
{
public Protocol Protocol { get; set; }
public IPAddress IPAddress { get; set; }
public int Port { get; set; }

public int IPAddressInt32
{
get { return IPAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ? IPv4AddressHelper.ConvertToInt32(IPAddress) : 0; }
}

public ListenerInfo()
{

}

public ListenerInfo(Protocol protocol, IPAddress ipddress, int port)
{
Protocol = protocol;
IPAddress = ipddress;
Port = port;
}
}
}
Loading