diff --git a/EonaCat.PortMonitor/App.xaml b/EonaCat.PortMonitor/App.xaml new file mode 100644 index 0000000..3d1c648 --- /dev/null +++ b/EonaCat.PortMonitor/App.xaml @@ -0,0 +1,9 @@ + + + + + + diff --git a/EonaCat.PortMonitor/App.xaml.cs b/EonaCat.PortMonitor/App.xaml.cs new file mode 100644 index 0000000..37a270d --- /dev/null +++ b/EonaCat.PortMonitor/App.xaml.cs @@ -0,0 +1,13 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace EonaCat.PortMonitor; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : System.Windows.Application +{ +} + diff --git a/EonaCat.PortMonitor/AssemblyInfo.cs b/EonaCat.PortMonitor/AssemblyInfo.cs new file mode 100644 index 0000000..cc29e7f --- /dev/null +++ b/EonaCat.PortMonitor/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly:ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/EonaCat.PortMonitor/ConnectionDetailsWindow.xaml b/EonaCat.PortMonitor/ConnectionDetailsWindow.xaml new file mode 100644 index 0000000..8d35b5e --- /dev/null +++ b/EonaCat.PortMonitor/ConnectionDetailsWindow.xaml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EonaCat.PortMonitor/ConnectionDetailsWindow.xaml.cs b/EonaCat.PortMonitor/ConnectionDetailsWindow.xaml.cs new file mode 100644 index 0000000..2c1c7f9 --- /dev/null +++ b/EonaCat.PortMonitor/ConnectionDetailsWindow.xaml.cs @@ -0,0 +1,49 @@ +using System.Windows; + +namespace EonaCat.PortMonitor +{ + /// + /// Interaction logic for ConnectionDetailsWindow.xaml + /// + public partial class ConnectionDetailsWindow : Window + { + public ConnectionDetailsWindow(ConnectionInfo conn) + { + InitializeComponent(); + + ProtocolText.Text = conn.Protocol; + LocalAddressText.Text = conn.LocalAddress; + LocalPortText.Text = conn.LocalPort.ToString(); + RemoteAddressText.Text = conn.RemoteAddress; + RemotePortText.Text = conn.RemotePort.ToString(); + + StateText.Text = conn.State; + + // Update the state text every second + System.Windows.Threading.DispatcherTimer stateTimer = new System.Windows.Threading.DispatcherTimer(); + stateTimer.Interval = TimeSpan.FromSeconds(1); + stateTimer.Tick += (sender, e) => UpdateStateText(conn); + stateTimer.Start(); + + ProcessIdText.Text = Convert.ToString(conn.ProcessId); + ProcessNameText.Text = conn.ProcessName; + ConnectionDurationText.Text = Convert.ToString(conn.FormattedConnectionDuration); + + // Update the connection duration text every second + System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); + timer.Interval = TimeSpan.FromSeconds(1); + timer.Tick += (sender, e) => UpdateConnectionDurationText(conn); + timer.Start(); + } + + private void UpdateStateText(ConnectionInfo conn) + { + Dispatcher.Invoke(() => StateText.Text = conn.State); + } + + private void UpdateConnectionDurationText(ConnectionInfo conn) + { + Dispatcher.Invoke(() => ConnectionDurationText.Text = Convert.ToString(conn.FormattedConnectionDuration)); + } + } +} diff --git a/EonaCat.PortMonitor/EonaCat.PortMonitor.csproj b/EonaCat.PortMonitor/EonaCat.PortMonitor.csproj new file mode 100644 index 0000000..a91bab2 --- /dev/null +++ b/EonaCat.PortMonitor/EonaCat.PortMonitor.csproj @@ -0,0 +1,32 @@ + + + + WinExe + net8.0-windows + enable + enable + true + true + icon.ico + + + + + + + + + + + + + + + + + + + + + + diff --git a/EonaCat.PortMonitor/EonaCat.PortMonitor.sln b/EonaCat.PortMonitor/EonaCat.PortMonitor.sln new file mode 100644 index 0000000..e2f5348 --- /dev/null +++ b/EonaCat.PortMonitor/EonaCat.PortMonitor.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35825.156 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EonaCat.PortMonitor", "EonaCat.PortMonitor.csproj", "{4D76BA36-0C8F-4335-A792-3A38D50B502C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4D76BA36-0C8F-4335-A792-3A38D50B502C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4D76BA36-0C8F-4335-A792-3A38D50B502C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4D76BA36-0C8F-4335-A792-3A38D50B502C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4D76BA36-0C8F-4335-A792-3A38D50B502C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FC0B8B1C-7CA4-47E3-88C3-57703E061393} + EndGlobalSection +EndGlobal diff --git a/EonaCat.PortMonitor/MainWindow.xaml b/EonaCat.PortMonitor/MainWindow.xaml new file mode 100644 index 0000000..cf093bc --- /dev/null +++ b/EonaCat.PortMonitor/MainWindow.xaml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +