ソースを参照

完成流量监控工具

yuzhengyang 8 年 前
コミット
983d88021e

+ 3 - 3
Fork.Net/Oreo.PCMonitor/App.config

@@ -1,6 +1,6 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
 <configuration>
     <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
     </startup>
-</configuration>
+</configuration>

+ 8 - 2
Fork.Net/Oreo.PCMonitor/Commons/P.cs

@@ -5,21 +5,27 @@ using System.Text;
 using System.Threading.Tasks;
 using Y.Utils.IOUtils.LogUtils;
 
-namespace Oreo.NetMonitor.Commons
+namespace Oreo.PCMonitor.Commons
 {
     public static class P
     {
         public static void Init()
         {
             InitLog();
+            InitNFS();
         }
 
         static void InitLog()
         {
             R.Log = new Log();
-            R.Log.SetWriteFile(true, "Oreo.NetMonitor.Log");
+            R.Log.SetWriteFile(true, "Oreo.PCMonitor.Log");
             R.Log.LogLevel = LogLevel.All;
             Log.AllocConsole();
         }
+        static void InitNFS()
+        {
+            R.NFS = new Services.NetFlowService();
+            R.NFS.Start();
+        }
     }
 }

+ 5 - 13
Fork.Net/Oreo.PCMonitor/Commons/R.cs

@@ -1,27 +1,19 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Oreo.PCMonitor.Services;
+using System;
 using Y.Utils.IOUtils.LogUtils;
 
-namespace Oreo.NetMonitor.Commons
+namespace Oreo.PCMonitor.Commons
 {
     public static class R
     {
         public static Log Log { get; set; }
+        public static NetFlowService NFS { get; set; }
+
         public static class Files { }
         public static class Paths
         {
             public static string BasePath = AppDomain.CurrentDomain.BaseDirectory;
         }
-        public static class Settings
-        {
-            public static double FlowThreshold { get; set; }
-            public static int ThresholdTime { get; set; }
-            public static int MaxProConnect { get; set; }
-            public static int RecProConnect { get; set; }
-        }
         public static class Servers
         {
             public static string ConfigIP = "192.168.3.52";

+ 16 - 0
Fork.Net/Oreo.PCMonitor/Commons/Settings.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Oreo.PCMonitor.Commons
+{
+    public class Settings
+    {
+        internal static void Init()
+        {
+            throw new NotImplementedException();
+        }
+    }
+}

+ 1 - 1
Fork.Net/Oreo.PCMonitor/Helpers/SendHelper.cs

@@ -4,7 +4,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace Oreo.NetMonitor.Helpers
+namespace Oreo.PCMonitor.Helpers
 {
     public class SendHelper
     {

+ 19 - 0
Fork.Net/Oreo.PCMonitor/Models/NetConnectionInfo.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Oreo.PCMonitor.Models
+{
+    public class NetConnectionInfo
+    {
+        public string ProcessName { get; set; }
+        public string ProtocolName { get; set; }
+        public string LocalIP { get; set; }
+        public int LocalPort { get; set; }
+        public string RemoteIP { get; set; }
+        public int RemotePort { get; set; }
+        public string Status { get; set; }
+    }
+}

+ 2 - 4
Fork.Net/Oreo.PCMonitor/Models/ProcessPacket.cs

@@ -4,13 +4,11 @@ using System.Drawing;
 using System.Linq;
 using System.Text;
 
-namespace Oreo.NetMonitor.Models
+namespace Oreo.PCMonitor.Models
 {
-    public class ProcessPacket
+    public class NetProcessInfo
     {
         public string ProcessName { get; set; }
-        public string ProcessFile { get; set; }
-        public int ProcessID { get; set; }
         public Icon ProcessIcon { get; set; }
         public DateTime LastUpdateTime { get; set; }
         public int UploadData { get; set; }

+ 12 - 5
Fork.Net/Oreo.PCMonitor/Oreo.PCMonitor.csproj

@@ -9,11 +9,12 @@
     <AppDesignerFolder>Properties</AppDesignerFolder>
     <RootNamespace>Oreo.PCMonitor</RootNamespace>
     <AssemblyName>Oreo.PCMonitor</AssemblyName>
-    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
     <NuGetPackageImportStamp>
     </NuGetPackageImportStamp>
+    <TargetFrameworkProfile />
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -50,8 +51,10 @@
   <ItemGroup>
     <Compile Include="Commons\P.cs" />
     <Compile Include="Commons\R.cs" />
+    <Compile Include="Commons\Settings.cs" />
     <Compile Include="Helpers\SendHelper.cs" />
-    <Compile Include="Models\ProcessPacket.cs" />
+    <Compile Include="Models\NetConnectionInfo.cs" />
+    <Compile Include="Models\NetProcessInfo.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Services\NetFlowService.cs" />
@@ -81,6 +84,7 @@
     <Compile Include="Properties\Resources.Designer.cs">
       <AutoGen>True</AutoGen>
       <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
     </Compile>
     <EmbeddedResource Include="Views\MainForm.resx">
       <DependentUpon>MainForm.cs</DependentUpon>
@@ -88,6 +92,9 @@
     <EmbeddedResource Include="Views\NetDetailForm.resx">
       <DependentUpon>NetDetailForm.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="Views\WelcomeForm.resx">
+      <DependentUpon>WelcomeForm.cs</DependentUpon>
+    </EmbeddedResource>
     <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>
@@ -103,6 +110,9 @@
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="FodyWeavers.xml" />
+  </ItemGroup>
+  <ItemGroup>
     <ProjectReference Include="..\Y.Skin\Y.Skin.csproj">
       <Project>{e9a97673-3e27-4a49-90bc-8806411a2f57}</Project>
       <Name>Y.Skin</Name>
@@ -112,9 +122,6 @@
       <Name>Y.Utils</Name>
     </ProjectReference>
   </ItemGroup>
-  <ItemGroup>
-    <None Include="FodyWeavers.xml" />
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="..\packages\Fody.2.0.9\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.2.0.9\build\dotnet\Fody.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

+ 11 - 7
Fork.Net/Oreo.PCMonitor/Program.cs

@@ -1,9 +1,8 @@
-using Oreo.NetMonitor.Views;
+using Oreo.PCMonitor.Commons;
+using Oreo.PCMonitor.Views;
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 using System.Windows.Forms;
+using Y.Utils.AppUtils;
 
 namespace Oreo.PCMonitor
 {
@@ -15,9 +14,14 @@ namespace Oreo.PCMonitor
         [STAThread]
         static void Main()
         {
-            Application.EnableVisualStyles();
-            Application.SetCompatibleTextRenderingDefault(false);
-            Application.Run(new MainForm());
+            if (AppUnique.IsUnique("Oreo.PCMonitor"))
+            {
+                //Settings.Init();
+                P.Init();
+                Application.EnableVisualStyles();
+                Application.SetCompatibleTextRenderingDefault(false);
+                Application.Run(new MainForm());
+            } 
         }
     }
 }

+ 25 - 33
Fork.Net/Oreo.PCMonitor/Properties/Resources.Designer.cs

@@ -1,69 +1,61 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     此代码由工具生成。
-//     运行时版本: 4.0.30319.42000
+//     运行时版本:4.0.30319.42000
 //
-//     对此文件的更改可能导致不正确的行为,如果
-//     重新生成代码,则所做更改将丢失。
+//     对此文件的更改可能导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace Oreo.PCMonitor.Properties
-{
-
-
+namespace Oreo.PCMonitor.Properties {
+    using System;
+    
+    
     /// <summary>
-    ///   强类型资源类,用于查找本地化字符串等。
+    ///   一个强类型资源类,用于查找本地化字符串等。
     /// </summary>
     // 此类是由 StronglyTypedResourceBuilder
     // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
-    // 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // 若要添加或除成员,请编辑 .ResX 文件,然后重新运行 ResGen
     // (以 /str 作为命令选项),或重新生成 VS 项目。
     [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources
-    {
-
+    internal class Resources {
+        
         private static global::System.Resources.ResourceManager resourceMan;
-
+        
         private static global::System.Globalization.CultureInfo resourceCulture;
-
+        
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources()
-        {
+        internal Resources() {
         }
-
+        
         /// <summary>
-        ///   返回此类使用的缓存 ResourceManager 实例。
+        ///   返回此类使用的缓存 ResourceManager 实例。
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager
-        {
-            get
-            {
-                if ((resourceMan == null))
-                {
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Oreo.PCMonitor.Properties.Resources", typeof(Resources).Assembly);
                     resourceMan = temp;
                 }
                 return resourceMan;
             }
         }
-
+        
         /// <summary>
-        ///   覆盖当前线程的 CurrentUICulture 属性
-        ///   使用此强类型的资源类的资源查找
+        ///   使用此强类型资源类,为所有资源查找
+        ///   重写当前线程的 CurrentUICulture 属性
         /// </summary>
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture
-        {
-            get
-            {
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
                 return resourceCulture;
             }
-            set
-            {
+            set {
                 resourceCulture = value;
             }
         }

+ 13 - 17
Fork.Net/Oreo.PCMonitor/Properties/Settings.Designer.cs

@@ -1,28 +1,24 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
-//     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
+//     此代码由工具生成。
+//     运行时版本:4.0.30319.42000
 //
-//     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
+//     对此文件的更改可能会导致不正确的行为,并且如果
+//     重新生成代码,这些更改将会丢失。
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace Oreo.PCMonitor.Properties
-{
-
-
+namespace Oreo.PCMonitor.Properties {
+    
+    
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
-    {
-
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
-        public static Settings Default
-        {
-            get
-            {
+        
+        public static Settings Default {
+            get {
                 return defaultInstance;
             }
         }

+ 169 - 25
Fork.Net/Oreo.PCMonitor/Services/NetFlowService.cs

@@ -1,16 +1,16 @@
-using Oreo.NetMonitor.Commons;
-using Oreo.NetMonitor.Models;
+using Oreo.PCMonitor.Commons;
+using Oreo.PCMonitor.Models;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using System.Net;
-using System.Text;
 using Y.Utils.AppUtils;
 using Y.Utils.DataUtils.Collections;
-using Y.Utils.DataUtils.UnitConvertUtils;
 using Y.Utils.NetUtils.NetInfoUtils;
+using Y.Utils.WindowsUtils.ProcessUtils;
 
-namespace Oreo.NetMonitor.Services
+namespace Oreo.PCMonitor.Services
 {
     public class NetFlowService
     {
@@ -19,19 +19,20 @@ namespace Oreo.NetMonitor.Services
         public bool IsNetPacketRun { get { return _IsNetPacketRun; } }
         private bool _IsNetPacketRun = false;
 
-        List<ProcessPacket> ProcessPacketList = new List<ProcessPacket>();
-        NetFlowTool NetFlow = new NetFlowTool();
+        public List<NetProcessInfo> NetProcessInfoList = new List<NetProcessInfo>();
+        public List<NetConnectionInfo> NetConnectionInfoList = new List<NetConnectionInfo>();
+
+        public NetFlowTool NetFlow = new NetFlowTool();
         List<NetPacketTool> NetPacketList = new List<NetPacketTool>();
 
         NetProcessTool.TcpRow[] TcpConnection;
         NetProcessTool.UdpRow[] UdpConnection;
+        Process[] NowProcess;
 
-        private long LostPacketCount { get; set; }
+        public long LostPacketCount { get; set; }
 
         public void Start()
         {
-            GetConnection();
-
             #region 启动系统性能计数器统计
             try
             {
@@ -78,47 +79,190 @@ namespace Oreo.NetMonitor.Services
 
         public void DataMonitorEvent(NetFlowTool n)
         {
-            //GetConnection();
+            NowProcess = Process.GetProcesses();
+            GetConnection();
+            SetNetProcess();
+            CalcNetProcessInfo();
+
             //#region 统计
             //p.Protocol == Protocol.Tcp
             //#endregion
         }
-        private void NewPacketEvent(NetPacketTool pm, Packet p)
+        private void NewPacketEvent(NetPacketTool tool, Packet packet)
         {
             // 给数据包归类,并添加至列表
             bool isGather = false;
-            lock (TcpConnection)
+            #region 整理TCP包
+            if (packet.Protocol == Protocol.Tcp && ListTool.HasElements(TcpConnection) && ListTool.HasElements(NowProcess))
             {
-                if (ListTool.HasElements(TcpConnection))
+                lock (TcpConnection)
                 {
-                    var tr = TcpConnection.First(x => x.LocalIP == p.SourceAddress && x.LocalPort == p.SourcePort);
-                    //if (tr != null)
+                    // tcp 上传
+                    if (TcpConnection.Any(x => x.LocalIP.ToString() == packet.SourceAddress.ToString() && x.LocalPort == packet.SourcePort))
+                    {
+                        var tcUpload = TcpConnection.FirstOrDefault(x => x.LocalIP.ToString() == packet.SourceAddress.ToString() && x.LocalPort == packet.SourcePort);
+                        var process = NowProcess.FirstOrDefault(x => x.Id == tcUpload.ProcessId);
+                        if (process != null)
+                        {
+                            var info = NetProcessInfoList.FirstOrDefault(x => x.ProcessName == process.ProcessName);
+                            if (info != null)
+                            {
+                                isGather = true;
+                                info.UploadBag += packet.TotalLength;
+                            }
+                        }
+                    }
+                    // tcp 下载
+                    if (TcpConnection.Any(x => x.RemoteIP.ToString() == packet.DestinationAddress.ToString() && x.RemotePort == packet.DestinationPort))
                     {
-                        var np = ProcessPacketList.First(x => x.ProcessID == tr.ProcessId);
-                        if (np != null)
+                        var tcpDownload = TcpConnection.FirstOrDefault(x => x.RemoteIP.ToString() == packet.DestinationAddress.ToString() && x.RemotePort == packet.DestinationPort);
+                        var process = NowProcess.FirstOrDefault(x => x.Id == tcpDownload.ProcessId);
+                        if (process != null)
                         {
-                            np.UploadBag += p.TotalLength;
+                            var info = NetProcessInfoList.FirstOrDefault(x => x.ProcessName == process.ProcessName);
+                            if (info != null)
+                            {
+                                isGather = true;
+                                info.DownloadBag += packet.TotalLength;
+                            }
                         }
                     }
                 }
             }
-            lock (UdpConnection)
+            #endregion
+            #region 整理UDP包
+            if (packet.Protocol == Protocol.Udp && ListTool.HasElements(UdpConnection) && ListTool.HasElements(NowProcess))
             {
-                if (ListTool.HasElements(UdpConnection))
+                lock (UdpConnection)
                 {
-                    NetProcessTool.UdpRow ur = UdpConnection.First(x => x.LocalIP == p.SourceAddress && x.LocalPort == p.SourcePort);
-
+                    // udp 上传
+                    if (UdpConnection.Any(x => x.LocalIP.ToString() == packet.SourceAddress.ToString() && x.LocalPort == packet.SourcePort))
+                    {
+                        var ucUpload = UdpConnection.FirstOrDefault(x => x.LocalIP.ToString() == packet.SourceAddress.ToString() && x.LocalPort == packet.SourcePort);
+                        var process = NowProcess.FirstOrDefault(x => x.Id == ucUpload.ProcessId);
+                        if (process != null)
+                        {
+                            var info = NetProcessInfoList.FirstOrDefault(x => x.ProcessName == process.ProcessName);
+                            if (info != null)
+                            {
+                                isGather = true;
+                                info.UploadBag += packet.TotalLength;
+                            }
+                        }
+                    }
+                    // tcp 下载
+                    if (UdpConnection.Any(x => x.LocalIP.ToString() == packet.DestinationAddress.ToString() && x.LocalPort == packet.DestinationPort))
+                    {
+                        var udpDownload = UdpConnection.FirstOrDefault(x => x.LocalIP.ToString() == packet.DestinationAddress.ToString() && x.LocalPort == packet.DestinationPort);
+                        var process = NowProcess.FirstOrDefault(x => x.Id == udpDownload.ProcessId);
+                        if (process != null)
+                        {
+                            var info = NetProcessInfoList.FirstOrDefault(x => x.ProcessName == process.ProcessName);
+                            if (info != null)
+                            {
+                                isGather = true;
+                                info.DownloadBag += packet.TotalLength;
+                            }
+                        }
+                    }
                 }
             }
+            #endregion
             if (!isGather) LostPacketCount++;
         }
 
-        #region 获取当前连接
-        public void GetConnection()
+        #region 获取当前程序的所有连接
+        void GetConnection()
         {
             TcpConnection = NetProcessTool.GetTcpConnection();
             UdpConnection = NetProcessTool.GetUdpConnection();
         }
         #endregion
+        #region 设置程序流量及连接数统计列表
+        void SetNetProcess()
+        {
+            // 清空已有连接数
+            if (ListTool.HasElements(NetProcessInfoList))
+                NetProcessInfoList.ForEach(x =>
+                {
+                    x.ConnectCount = 0;
+                });
+
+            // 统计TCP连接数
+            if (ListTool.HasElements(TcpConnection))
+            {
+                foreach (var t in TcpConnection)
+                {
+                    SetNetProcessConnection(t.ProcessId);
+                }
+            }
+            // 统计UDP连接数
+            if (ListTool.HasElements(UdpConnection))
+            {
+                foreach (var u in UdpConnection)
+                {
+                    SetNetProcessConnection(u.ProcessId);
+                }
+            }
+        }
+        void SetNetProcessConnection(int pid)
+        {
+            try
+            {
+                Process p = NowProcess.FirstOrDefault(x => x.Id == pid);
+                if (p != null)
+                {
+                    var ppl = NetProcessInfoList.FirstOrDefault(x => x.ProcessName == p.ProcessName);
+                    if (ppl == null)
+                    {
+                        NetProcessInfoList.Add(
+                            new NetProcessInfo()
+                            {
+                                ProcessIcon = ProcessInfoTool.GetIcon(p, false),
+                                ProcessName = p.ProcessName,
+                                ConnectCount = 1,
+                                LastUpdateTime = DateTime.Now,
+                            });
+                    }
+                    else
+                    {
+                        ppl.ConnectCount++;
+                        ppl.LastUpdateTime = DateTime.Now;
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                R.Log.e("对程序列表和网络连接列表整理时发生错误");
+                R.Log.e(e.Message);
+            }
+        }
+        #endregion
+        #region 整理程序流量汇总信息
+        void CalcNetProcessInfo()
+        {
+            if (ListTool.HasElements(NetProcessInfoList))
+            {
+                NetProcessInfoList.ForEach(p =>
+                {
+                    p.UploadDataCount += p.UploadData;
+                    p.DownloadDataCount += p.DownloadData;
+                });
+
+                NetProcessInfoList.ForEach(p =>
+                {
+                    p.LastUpdateTime = DateTime.Now;
+                    p.UploadData = (int)((float)p.UploadBag / (NetProcessInfoList.Sum(x => x.UploadBag) + 0.01) * NetFlow.UploadData);
+                    p.DownloadData = (int)((float)p.DownloadBag / (NetProcessInfoList.Sum(x => x.DownloadBag + 0.01)) * NetFlow.DownloadData);
+
+                    p.UploadBagCount += p.UploadBag;
+                    p.DownloadBagCount += p.DownloadBag;
+
+                    p.UploadBag = 0;
+                    p.DownloadBag = 0;
+                });
+            }
+        }
+        #endregion
     }
 }

+ 14 - 1
Fork.Net/Oreo.PCMonitor/Views/MainForm.Designer.cs

@@ -1,4 +1,4 @@
-namespace Oreo.NetMonitor.Views
+namespace Oreo.PCMonitor.Views
 {
     partial class MainForm
     {
@@ -28,13 +28,24 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.button1 = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(69, 73);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.TabIndex = 0;
+            this.button1.Text = "button1";
+            this.button1.UseVisualStyleBackColor = true;
+            // 
             // MainForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(658, 433);
+            this.Controls.Add(this.button1);
             this.Name = "MainForm";
             this.Text = "MainForm";
             this.Load += new System.EventHandler(this.MainForm_Load);
@@ -43,5 +54,7 @@
         }
 
         #endregion
+
+        private System.Windows.Forms.Button button1;
     }
 }

+ 2 - 1
Fork.Net/Oreo.PCMonitor/Views/MainForm.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Windows.Forms;
 
-namespace Oreo.NetMonitor.Views
+namespace Oreo.PCMonitor.Views
 {
     public partial class MainForm : Form
     {
@@ -11,6 +11,7 @@ namespace Oreo.NetMonitor.Views
         }
         private void MainForm_Load(object sender, EventArgs e)
         {
+            new NetDetailForm().Show();
         }
     }
 }

+ 140 - 95
Fork.Net/Oreo.PCMonitor/Views/NetDetailForm.Designer.cs

@@ -1,4 +1,4 @@
-namespace Oreo.NetMonitor.Views
+namespace Oreo.PCMonitor.Views
 {
     partial class NetDetailForm
     {
@@ -28,124 +28,169 @@
         /// </summary>
         private void InitializeComponent()
         {
-            this.dataGridView1 = new System.Windows.Forms.DataGridView();
-            this.Column1 = new System.Windows.Forms.DataGridViewImageColumn();
-            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
+            this.DgProcessDetail = new System.Windows.Forms.DataGridView();
+            this.CoIcon = new System.Windows.Forms.DataGridViewImageColumn();
+            this.CoName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.CoDownload = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.CoUpload = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.CoDownloadCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.CoUploadCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.CoConnectionCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.status = new System.Windows.Forms.Label();
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
+            this.label1 = new System.Windows.Forms.Label();
+            ((System.ComponentModel.ISupportInitialize)(this.DgProcessDetail)).BeginInit();
             this.SuspendLayout();
             // 
-            // dataGridView1
-            // 
-            this.dataGridView1.AllowUserToAddRows = false;
-            this.dataGridView1.AllowUserToDeleteRows = false;
-            this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
-            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
-            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
-            this.Column1,
-            this.Column2,
-            this.Column3,
-            this.Column4,
-            this.Column7,
-            this.Column5,
-            this.Column8,
-            this.Column6});
-            this.dataGridView1.Location = new System.Drawing.Point(12, 78);
-            this.dataGridView1.Name = "dataGridView1";
-            this.dataGridView1.ReadOnly = true;
-            this.dataGridView1.RowHeadersVisible = false;
-            this.dataGridView1.RowTemplate.Height = 23;
-            this.dataGridView1.Size = new System.Drawing.Size(634, 331);
-            this.dataGridView1.TabIndex = 24;
-            // 
-            // Column1
-            // 
-            this.Column1.HeaderText = "";
-            this.Column1.Name = "Column1";
-            this.Column1.ReadOnly = true;
-            // 
-            // Column2
-            // 
-            this.Column2.HeaderText = "进程名称";
-            this.Column2.Name = "Column2";
-            this.Column2.ReadOnly = true;
-            // 
-            // Column3
-            // 
-            this.Column3.HeaderText = "PID";
-            this.Column3.Name = "Column3";
-            this.Column3.ReadOnly = true;
-            // 
-            // Column4
-            // 
-            this.Column4.HeaderText = "上传速率";
-            this.Column4.Name = "Column4";
-            this.Column4.ReadOnly = true;
-            // 
-            // Column7
-            // 
-            this.Column7.HeaderText = "上传总量";
-            this.Column7.Name = "Column7";
-            this.Column7.ReadOnly = true;
-            // 
-            // Column5
-            // 
-            this.Column5.HeaderText = "下载速率";
-            this.Column5.Name = "Column5";
-            this.Column5.ReadOnly = true;
-            // 
-            // Column8
-            // 
-            this.Column8.HeaderText = "下载总量";
-            this.Column8.Name = "Column8";
-            this.Column8.ReadOnly = true;
-            // 
-            // Column6
-            // 
-            this.Column6.HeaderText = "总计流量";
-            this.Column6.Name = "Column6";
-            this.Column6.ReadOnly = true;
+            // DgProcessDetail
+            // 
+            this.DgProcessDetail.AllowUserToAddRows = false;
+            this.DgProcessDetail.AllowUserToDeleteRows = false;
+            this.DgProcessDetail.AllowUserToResizeColumns = false;
+            this.DgProcessDetail.AllowUserToResizeRows = false;
+            this.DgProcessDetail.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
+            this.DgProcessDetail.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
+            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
+            dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.DgProcessDetail.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
+            this.DgProcessDetail.ColumnHeadersHeight = 40;
+            this.DgProcessDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
+            this.DgProcessDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.CoIcon,
+            this.CoName,
+            this.CoDownload,
+            this.CoUpload,
+            this.CoDownloadCount,
+            this.CoUploadCount,
+            this.CoConnectionCount});
+            dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Window;
+            dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.GradientActiveCaption;
+            dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.Black;
+            dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+            this.DgProcessDetail.DefaultCellStyle = dataGridViewCellStyle8;
+            this.DgProcessDetail.Location = new System.Drawing.Point(11, 81);
+            this.DgProcessDetail.Name = "DgProcessDetail";
+            this.DgProcessDetail.ReadOnly = true;
+            this.DgProcessDetail.RowHeadersVisible = false;
+            this.DgProcessDetail.RowTemplate.Height = 40;
+            this.DgProcessDetail.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+            this.DgProcessDetail.Size = new System.Drawing.Size(811, 406);
+            this.DgProcessDetail.TabIndex = 24;
+            // 
+            // CoIcon
+            // 
+            this.CoIcon.HeaderText = "名称";
+            this.CoIcon.Name = "CoIcon";
+            this.CoIcon.ReadOnly = true;
+            // 
+            // CoName
+            // 
+            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            this.CoName.DefaultCellStyle = dataGridViewCellStyle2;
+            this.CoName.HeaderText = "";
+            this.CoName.Name = "CoName";
+            this.CoName.ReadOnly = true;
+            // 
+            // CoDownload
+            // 
+            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+            this.CoDownload.DefaultCellStyle = dataGridViewCellStyle3;
+            this.CoDownload.HeaderText = "下载速度";
+            this.CoDownload.Name = "CoDownload";
+            this.CoDownload.ReadOnly = true;
+            // 
+            // CoUpload
+            // 
+            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+            this.CoUpload.DefaultCellStyle = dataGridViewCellStyle4;
+            this.CoUpload.HeaderText = "上传速度";
+            this.CoUpload.Name = "CoUpload";
+            this.CoUpload.ReadOnly = true;
+            // 
+            // CoDownloadCount
+            // 
+            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+            this.CoDownloadCount.DefaultCellStyle = dataGridViewCellStyle5;
+            this.CoDownloadCount.HeaderText = "已下载流量";
+            this.CoDownloadCount.Name = "CoDownloadCount";
+            this.CoDownloadCount.ReadOnly = true;
+            // 
+            // CoUploadCount
+            // 
+            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+            this.CoUploadCount.DefaultCellStyle = dataGridViewCellStyle6;
+            this.CoUploadCount.HeaderText = "已上传流量";
+            this.CoUploadCount.Name = "CoUploadCount";
+            this.CoUploadCount.ReadOnly = true;
+            // 
+            // CoConnectionCount
+            // 
+            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            this.CoConnectionCount.DefaultCellStyle = dataGridViewCellStyle7;
+            this.CoConnectionCount.HeaderText = "连接数";
+            this.CoConnectionCount.Name = "CoConnectionCount";
+            this.CoConnectionCount.ReadOnly = true;
             // 
             // status
             // 
-            this.status.Location = new System.Drawing.Point(9, 424);
+            this.status.Location = new System.Drawing.Point(14, 506);
             this.status.Name = "status";
-            this.status.Size = new System.Drawing.Size(636, 49);
+            this.status.Size = new System.Drawing.Size(534, 42);
             this.status.TabIndex = 25;
             this.status.Text = "信息";
             // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(720, 40);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(41, 12);
+            this.label1.TabIndex = 26;
+            this.label1.Text = "label1";
+            // 
             // NetDetailForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(657, 481);
-            this.Controls.Add(this.dataGridView1);
+            this.ClientSize = new System.Drawing.Size(834, 561);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.DgProcessDetail);
             this.Controls.Add(this.status);
             this.Name = "NetDetailForm";
             this.Text = "NetDetailForm";
             this.Load += new System.EventHandler(this.NetDetailForm_Load);
-            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.DgProcessDetail)).EndInit();
             this.ResumeLayout(false);
+            this.PerformLayout();
 
         }
 
         #endregion
 
-        private System.Windows.Forms.DataGridView dataGridView1;
-        private System.Windows.Forms.DataGridViewImageColumn Column1;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column8;
-        private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
+        private System.Windows.Forms.DataGridView DgProcessDetail;
         private System.Windows.Forms.Label status;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.DataGridViewImageColumn CoIcon;
+        private System.Windows.Forms.DataGridViewTextBoxColumn CoName;
+        private System.Windows.Forms.DataGridViewTextBoxColumn CoDownload;
+        private System.Windows.Forms.DataGridViewTextBoxColumn CoUpload;
+        private System.Windows.Forms.DataGridViewTextBoxColumn CoDownloadCount;
+        private System.Windows.Forms.DataGridViewTextBoxColumn CoUploadCount;
+        private System.Windows.Forms.DataGridViewTextBoxColumn CoConnectionCount;
     }
 }

+ 55 - 2
Fork.Net/Oreo.PCMonitor/Views/NetDetailForm.cs

@@ -1,4 +1,5 @@
-using System;
+using Oreo.PCMonitor.Commons;
+using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Linq;
@@ -6,9 +7,10 @@ using System.Net;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using Y.Utils.DataUtils.Collections;
 using Y.Utils.DataUtils.UnitConvertUtils;
 
-namespace Oreo.NetMonitor.Views
+namespace Oreo.PCMonitor.Views
 {
     public partial class NetDetailForm : Form
     {
@@ -18,6 +20,57 @@ namespace Oreo.NetMonitor.Views
         }
         private void NetDetailForm_Load(object sender, EventArgs e)
         {
+            Task.Factory.StartNew(() =>
+            {
+                Thread.Sleep(3000);
+                while (true)
+                {
+                    if (R.NFS.IsNetFlowRun || R.NFS.IsNetPacketRun)
+                    {
+                        R.Log.v("IsNetFlowRun: " + R.NFS.IsNetFlowRun + " IsNetPacketRun: " + R.NFS.IsNetPacketRun +
+                            " Upload: " + R.NFS.NetFlow.UploadData + " Download: " + R.NFS.NetFlow.DownloadData);
+                        UIDgProcessDetailUpdate();
+                    }
+                    Thread.Sleep(10000);
+                }
+            });
+        }
+
+        private void UIDgProcessDetailUpdate()
+        {
+            if (IsDisposed) return;
+
+            BeginInvoke(new Action(() =>
+            {
+                if (R.NFS != null && ListTool.HasElements(R.NFS.NetProcessInfoList))
+                {
+                    label1.Text = "丢包数:" + R.NFS.LostPacketCount;
+                    R.NFS.NetProcessInfoList.ForEach(p =>
+                    {
+                        bool isUpdate = false;
+                        foreach (DataGridViewRow r in DgProcessDetail.Rows)
+                        {
+                            if (r.Cells["CoName"].Value.ToString() == p.ProcessName)
+                            {
+                                isUpdate = true;
+                                r.Cells["CoDownload"].Value = ByteConvertTool.Fmt(p.DownloadData);
+                                r.Cells["CoUpload"].Value = ByteConvertTool.Fmt(p.UploadData);
+                                r.Cells["CoDownloadCount"].Value = ByteConvertTool.Fmt(p.DownloadDataCount);
+                                r.Cells["CoUploadCount"].Value = ByteConvertTool.Fmt(p.UploadDataCount);
+                                r.Cells["CoConnectionCount"].Value = p.ConnectCount;
+                            }
+                        }
+                        if (!isUpdate)
+                        {
+                            DgProcessDetail.Rows.Add(new object[] {
+                                p.ProcessIcon,p.ProcessName,
+                                ByteConvertTool.Fmt(p.DownloadData),ByteConvertTool.Fmt(p.UploadData),
+                                ByteConvertTool.Fmt(p.DownloadDataCount),ByteConvertTool.Fmt(p.UploadDataCount),
+                                p.ConnectCount});
+                        }
+                    });
+                }
+            }));
         }
     }
 }

+ 7 - 10
Fork.Net/Oreo.PCMonitor/Views/NetDetailForm.resx

@@ -117,28 +117,25 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="CoIcon.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="CoName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="CoDownload.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="CoUpload.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="CoDownloadCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="CoUploadCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="Column8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="CoConnectionCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
 </root>

+ 11 - 2
Fork.Net/Oreo.PCMonitor/Views/WelcomeForm.Designer.cs

@@ -1,4 +1,4 @@
-namespace Oreo.NetMonitor.Views
+namespace Oreo.PCMonitor.Views
 {
     partial class WelcomeForm
     {
@@ -28,9 +28,18 @@
         /// </summary>
         private void InitializeComponent()
         {
-            this.components = new System.ComponentModel.Container();
+            this.SuspendLayout();
+            // 
+            // WelcomeForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(284, 261);
+            this.Name = "WelcomeForm";
             this.Text = "WelcomeForm";
+            this.Load += new System.EventHandler(this.WelcomeForm_Load);
+            this.ResumeLayout(false);
+
         }
 
         #endregion

+ 6 - 1
Fork.Net/Oreo.PCMonitor/Views/WelcomeForm.cs

@@ -8,7 +8,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
-namespace Oreo.NetMonitor.Views
+namespace Oreo.PCMonitor.Views
 {
     public partial class WelcomeForm : Form
     {
@@ -16,5 +16,10 @@ namespace Oreo.NetMonitor.Views
         {
             InitializeComponent();
         }
+
+        private void WelcomeForm_Load(object sender, EventArgs e)
+        {
+
+        }
     }
 }

+ 120 - 0
Fork.Net/Oreo.PCMonitor/Views/WelcomeForm.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 2 - 2
Fork.Net/Oreo.PCMonitor/packages.config

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
-  <package id="Costura.Fody" version="1.5.0" targetFramework="net452" developmentDependency="true" />
-  <package id="Fody" version="2.0.9" targetFramework="net452" developmentDependency="true" />
+  <package id="Costura.Fody" version="1.5.0" targetFramework="net45" developmentDependency="true" />
+  <package id="Fody" version="2.0.9" targetFramework="net45" developmentDependency="true" />
 </packages>

+ 4 - 1
Fork.Net/Y.Utils/NetUtils/NetInfoUtils/NetPacketTool.cs

@@ -91,7 +91,10 @@ namespace Y.Utils.NetUtils.NetInfoUtils
                         OnNewPacket(new Packet(packet));
                     }
                 }
-                catch { } // invalid packet; ignore
+                catch (Exception e)
+                {
+                    // invalid packet; ignore
+                }
                 m_Monitor.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(this.OnReceive), null);
             }
             catch

+ 1 - 1
Fork.Net/Y.Utils/NetUtils/NetInfoUtils/NetflowTool.cs

@@ -84,6 +84,7 @@ namespace Y.Utils.NetUtils.NetInfoUtils
                 {
                     while (DataMonitorSwitch)
                     {
+                        DataMonitorEvent?.Invoke(this);
                         try
                         {
                             _UploadDataCount += _UploadData;
@@ -100,7 +101,6 @@ namespace Y.Utils.NetUtils.NetInfoUtils
                             }
                         }
                         catch { }
-                        DataMonitorEvent?.Invoke(this);
                         Thread.Sleep(DataCounterInterval);
                     }
                 });

+ 8 - 1
Fork.Net/Y.Utils/WindowsUtils/ProcessUtils/ProcessInfoTool.cs

@@ -65,7 +65,13 @@ namespace Y.Utils.WindowsUtils.ProcessUtils
         }
         public static Icon GetIcon(Process p, bool small)
         {
-            return GetIcon(p.MainModule.FileName, small);
+            try
+            {
+                string fileName = p.MainModule.FileName;
+                return GetIcon(fileName, small);
+            }
+            catch { }
+            return null;
         }
         [Obsolete]
         public static Icon GetIcon(int pid, bool small)
@@ -81,6 +87,7 @@ namespace Y.Utils.WindowsUtils.ProcessUtils
             {
                 Process processById = Process.GetProcessById(pid);
                 result = processById.ProcessName;
+                processById.Close();
             }
             catch (Exception ex) { }
             return result.Trim();