Browse Source

优化获取计算机信息工具类,修改不规则窗体不能在任务栏中隐藏

yuzhengyang 8 years ago
parent
commit
f61d91b7f5

+ 1 - 1
Fork.Net/Test/Y.Test/Views/TestComputerInfoForm.cs

@@ -30,7 +30,7 @@ namespace Y.Test.Views
 
             Tuple<string, string> cpuinfo = ComputerInfoTool.CpuInfo();
             Print("CPU 序列号 " + cpuinfo.Item1 + " 型号 " + cpuinfo.Item2);
-            Print("显卡信息: " + string.Join(",", ComputerInfoTool.GraphicsCardModel()));
+            Print("显卡信息: " + string.Join(",", ComputerInfoTool.GraphicsCardInfo()));
             Print("声卡信息: " + string.Join(",", ComputerInfoTool.SoundCardModel()));
             Print("内存: " + ComputerInfoTool.AvailablePhysicalMemory() + " / " + ComputerInfoTool.TotalPhysicalMemory());
             List<Tuple<string, string>> harddiskinfo = ComputerInfoTool.HardDiskInfo();

+ 20 - 5
Fork.Net/Y.Skin/YoForm/Irregular/IrregularForm.cs

@@ -35,18 +35,33 @@ namespace Y.Skin.YoForm.Irregular
         }
 
         #region 属性
-        private bool _skinmobile = true;
+        private bool _Moveable = true;
         [Category("Skin")]
         [Description("窗体是否可以移动")]
         [DefaultValue(typeof(bool), "true")]
-        public bool SkinMovable
+        public bool Movable
         {
-            get { return _skinmobile; }
+            get { return _Moveable; }
             set
             {
-                if (_skinmobile != value)
+                if (_Moveable != value)
                 {
-                    _skinmobile = value;
+                    _Moveable = value;
+                }
+            }
+        }
+        private bool _InTaskbar = true;
+        [Category("Skin")]
+        [Description("窗体是否显示到任务栏")]
+        [DefaultValue(typeof(bool), "true")]
+        public bool InTaskbar
+        {
+            get { return _InTaskbar; }
+            set
+            {
+                if (_InTaskbar != value)
+                {
+                    _InTaskbar = value;
                 }
             }
         }

+ 1 - 0
Fork.Net/Y.Skin/YoForm/Irregular/IrregularFormSkin.Designer.cs

@@ -40,6 +40,7 @@
             this.MinimumSize = new System.Drawing.Size(1, 1);
             this.Name = "IrregularFormSkin";
             this.Text = "IrregularFormSkin";
+            this.Load += new System.EventHandler(this.IrregularFormSkin_Load);
             this.ResumeLayout(false);
 
         }

+ 9 - 4
Fork.Net/Y.Skin/YoForm/Irregular/IrregularFormSkin.cs

@@ -23,7 +23,7 @@ namespace Y.Skin.YoForm.Irregular
             Icon = main.Icon;//设置图标
             TopMost = main.TopMost;
             FormBorderStyle = FormBorderStyle.None;//设置无边框的窗口样式
-            ShowInTaskbar = true;//使控件层显示到任务栏
+            ShowInTaskbar = main.InTaskbar;//使控件层显示到任务栏
             BackgroundImage = Main.BackgroundImage;//将控件层背景图应用到皮肤层
             BackgroundImageLayout = ImageLayout.Stretch;//自动拉伸背景图以适应窗口
             Size = Main.Size;//统一大小
@@ -129,7 +129,7 @@ namespace Y.Skin.YoForm.Irregular
         /// <param name="e"></param>
         private void Frm_MouseDown(object sender, MouseEventArgs e)
         {
-            if (Main.SkinMovable)
+            if (Main.Movable)
             {
                 int xOffset;
                 int yOffset;
@@ -151,7 +151,7 @@ namespace Y.Skin.YoForm.Irregular
         /// <param name="e"></param>
         private void Frm_MouseMove(object sender, MouseEventArgs e)
         {
-            if (Main.SkinMovable)
+            if (Main.Movable)
             {
                 //将调用此事件的窗口保存下
                 Form frm = (Form)sender;
@@ -181,7 +181,7 @@ namespace Y.Skin.YoForm.Irregular
         /// <param name="e"></param>
         private void Frm_MouseUp(object sender, MouseEventArgs e)
         {
-            if (Main.SkinMovable)
+            if (Main.Movable)
             {
                 // 修改鼠标状态isMouseDown的值
                 // 确保只有鼠标左键按下并移动时,才移动窗体
@@ -224,5 +224,10 @@ namespace Y.Skin.YoForm.Irregular
             FormStyleAPI.ReleaseCapture();
             FormStyleAPI.SendMessage(Handle, FormStyleAPI.WM_NCLBUTTONDOWN, FormStyleAPI.HTCAPTION, 0);
         }
+
+        private void IrregularFormSkin_Load(object sender, EventArgs e)
+        {
+
+        }
     }
 }

+ 14 - 0
Fork.Net/Y.Utils/DataUtils/DateTimeUtils/DateTimeTool.cs

@@ -35,5 +35,19 @@ namespace Y.Utils.DataUtils.DateTimeUtils
             Second = (int)second % 60;
             return new Tuple<int, int>(Minute, Second);
         }
+        public static Tuple<long, long, long> ToHMS(long ms)
+        {
+            long Hour = ms / 1000 / 60 / 60;
+            long Minute = ms / 1000 / 60 % 60;
+            long Second = ms / 1000 % 60;
+            return new Tuple<long, long, long>(Hour, Minute, Second);
+        }
+        public static Tuple<int, int, int> ToHMS(int ms)
+        {
+            int Hour = ms / 1000 / 60 / 60;
+            int Minute = ms / 1000 / 60 % 60;
+            int Second = ms / 1000 % 60;
+            return new Tuple<int, int, int>(Hour, Minute, Second);
+        }
     }
 }

+ 3 - 3
Fork.Net/Y.Utils/NetUtils/NetInfoUtils/NetcardInfoTool.cs

@@ -34,14 +34,14 @@ namespace Y.Utils.NetUtils.NetInfoUtils
                 {
                     if (item.NetworkInterfaceType == NetworkInterfaceType.Ethernet || item.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
                     {
-                        string _name = item.Name;
-                        string _desc = item.Description;
+                        string _name = item.Name.Trim();
+                        string _desc = item.Description.Trim();
                         string _mac = item.GetPhysicalAddress().ToString();
                         string _ip = item.GetIPProperties().UnicastAddresses.Count >= 2 ?
                             item.GetIPProperties().UnicastAddresses[1].Address.ToString() : null;
                         string _gateway = item.GetIPProperties().GatewayAddresses.Count >= 1 ?
                             item.GetIPProperties().GatewayAddresses[0].Address.ToString() : null;
-                        result.Add(new Tuple<string, string, string, string, string>(_name.Trim(), _desc.Trim(), _mac.Trim(), _ip.Trim(), _gateway.Trim()));
+                        result.Add(new Tuple<string, string, string, string, string>(_name, _desc, _mac, _ip, _gateway));
                     }
                 }
                 return result;

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

@@ -77,10 +77,11 @@ namespace Y.Utils.NetUtils.NetInfoUtils
             }
             return false;
         }
-        public bool Start()
+        public bool Start(int interval = 1000)
         {
             if (Init() && !DataMonitorSwitch)
             {
+                DataCounterInterval = interval;
                 DataMonitorSwitch = true;
 
                 Task.Factory.StartNew(() =>
@@ -139,6 +140,9 @@ namespace Y.Utils.NetUtils.NetInfoUtils
                 dc?.Close();
             }
         }
+        /// <summary>
+        /// 终结器
+        /// </summary>
         ~NetFlowTool()
         {
             Stop();

+ 8 - 3
Fork.Net/Y.Utils/WindowsUtils/InfoUtils/ComputerInfoTool.cs

@@ -57,17 +57,22 @@ namespace Y.Utils.WindowsUtils.InfoUtils
         }
         /// <summary>
         /// 显卡型号
+        /// 【型号、RAM】
         /// </summary>
         /// <returns></returns>
-        public static List<string> GraphicsCardModel()
+        public static List<Tuple<string, ulong>> GraphicsCardInfo()
         {
             try
             {
-                List<string> rs = new List<string>();
+                List<Tuple<string, ulong>> rs = new List<Tuple<string, ulong>>();
                 ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from  Win32_VideoController");
                 foreach (ManagementObject item in searcher.Get())
                 {
-                    rs.Add(item["Name"].ToString().Trim());
+                    string name = item["Name"].ToString().Trim();
+                    string ram = item["AdapterRAM"].ToString().Trim();
+                    ulong ramnumber;
+                    ulong.TryParse(ram, out ramnumber);
+                    rs.Add(new Tuple<string, ulong>(name, ramnumber));
                 }
                 return rs;
             }