Browse Source

合并窗口管理工具到Azylee.Core中,添加获取计算机开机时间(存在误差),try掉日志调用Console时可能导致的异常(使用时并不关心),try掉NoTitle窗口的UI操作Invoke可能引发的异常(使用时并不关心)。

yuzhengyang 7 years ago
parent
commit
11298b0088

BIN
Azylee.Utils/.vs/Azylee.Utils/v15/Server/sqlite3/storage.ide


+ 4 - 0
Azylee.Utils/Azylee.Core/LogUtils/SimpleLogUtils/Log.cs

@@ -111,6 +111,10 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
             {
                 Console.ForegroundColor = GetColor(type);
                 Console.WriteLine(LOG_FORMAT, DateTime.Now.ToString(TIME_FORMAT), type.ToString(), message);
+            }
+            catch { }
+            try
+            {
                 //取消单独线程输出日志文件(单独线程输出日志必然会有延迟)
                 //if (IsWriteFile) Queue.Enqueue(new LogModel() { Type = type, Message = message, CreateTime = DateTime.Now });
                 if (IsWriteFile) WriteFile(new LogModel() { Type = type, Message = message, CreateTime = DateTime.Now });

+ 6 - 2
Azylee.Utils/Azylee.Core/ProcessUtils/ProcessTool.cs

@@ -82,8 +82,12 @@ namespace Azylee.Core.ProcessUtils
                 Process[] processes = Process.GetProcessesByName(name);
                 foreach (Process p in processes)
                 {
-                    p.Kill();
-                    p.Close();
+                    try
+                    {
+                        p.Kill();
+                        p.Close();
+                    }
+                    catch { }
                 }
             }
             catch (Exception e) { }

+ 1 - 1
Azylee.Utils/Azylee.Core/Properties/AssemblyInfo.cs

@@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
 // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
 //通过使用 "*",如下所示:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.1")]
+[assembly: AssemblyVersion("1.0.0.3")]

+ 10 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/ComputerInfoTool.cs

@@ -376,6 +376,16 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
             return Environment.TickCount;
         }
         /// <summary>
+        ///  获取机器开机时间 
+        /// </summary>
+        /// <returns></returns>
+        public static DateTime StartTime()
+        {
+            DateTime time = DateTime.Now;
+            try { time = time.AddMilliseconds(-Environment.TickCount); } catch { }
+            return time;
+        }
+        /// <summary>
         /// 处理器数
         /// </summary>
         /// <returns></returns>

+ 0 - 7
Azylee.Utils/Azylee.Utils.sln

@@ -17,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.ExeLaunch", "Azylee.
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.Update", "Azylee.Update\Azylee.Update.csproj", "{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.WinformMan", "Azylee.WinformMan\Azylee.WinformMan.csproj", "{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.WinformSkin", "Azylee.WinformSkin\Azylee.WinformSkin.csproj", "{D280C16F-FDE2-4647-BD76-3514F673426D}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.YeahWeb", "Azylee.YeahWeb\Azylee.YeahWeb.csproj", "{CCF7A654-B442-4DB1-BB3B-0F8014C3237F}"
@@ -61,10 +59,6 @@ Global
 		{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91}.Release|Any CPU.Build.0 = Release|Any CPU
-		{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE}.Release|Any CPU.Build.0 = Release|Any CPU
 		{D280C16F-FDE2-4647-BD76-3514F673426D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{D280C16F-FDE2-4647-BD76-3514F673426D}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{D280C16F-FDE2-4647-BD76-3514F673426D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -95,7 +89,6 @@ Global
 		{EF587677-DC59-4C46-B1AB-92904CD3F187} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{1AB11F85-BA96-4F82-8122-BB89E63FCCB1} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91} = {927325CD-24FD-4B85-A982-543D4F58A47C}
-		{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{D280C16F-FDE2-4647-BD76-3514F673426D} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{CCF7A654-B442-4DB1-BB3B-0F8014C3237F} = {927325CD-24FD-4B85-A982-543D4F58A47C}
 		{5FB93D25-8855-4A80-9E08-131BC728B7F4} = {9351FC10-E8D0-41BB-A813-0B5B3EA90605}

+ 0 - 54
Azylee.Utils/Azylee.WinformMan/Azylee.WinformMan.csproj

@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Azylee.WinformMan</RootNamespace>
-    <AssemblyName>Azylee.WinformMan</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>none</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Drawing" />
-    <Reference Include="System.Windows.Forms" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="ManagerUtils\FormManTool.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\Azylee.Core\Azylee.Core.csproj">
-      <Project>{88dc61fa-95f0-41b7-9d7d-ab0f3cbd169c}</Project>
-      <Name>Azylee.Core</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-</Project>

+ 0 - 96
Azylee.Utils/Azylee.WinformMan/ManagerUtils/FormManTool.cs

@@ -1,96 +0,0 @@
-//************************************************************************
-//      https://github.com/yuzhengyang
-//      author:     yuzhengyang
-//      date:       2017.7.31 - 2017.7.31
-//      desc:       窗体管理器
-//      Copyright (c) yuzhengyang. All rights reserved.
-//************************************************************************
-using Azylee.Core.DataUtils.CollectionUtils;
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Windows.Forms;
-
-namespace Azylee.WinformMan.ManagerUtils
-{
-    /// <summary>
-    /// 窗体管理器
-    /// </summary>
-    public class FormManTool
-    {
-        public Color? BackColor = null;
-
-        protected ConcurrentDictionary<Type, Form> UniqueForms = new ConcurrentDictionary<Type, Form>();
-
-        public List<Form> AllForms { get { return _AllForms; } }
-        private List<Form> _AllForms = new List<Form>();
-
-
-        public bool Add<T>(T form) where T : Form
-        {
-            if (BackColor != null) form.BackColor = (Color)BackColor;
-            _AllForms.Add(form);
-            return true;
-        }
-        /// <summary>
-        /// 获取唯一窗体对象
-        /// </summary>
-        /// <typeparam name="T"></typeparam>
-        /// <returns></returns>
-        public T GetUnique<T>() where T : Form, new()
-        {
-            if (UniqueForms.ContainsKey(typeof(T)))
-            {
-                // 字典中有该窗体,则读取窗体对象
-                Form value;
-                if (UniqueForms.TryGetValue(typeof(T), out value))
-                {
-                    if (value != null && !value.IsDisposed)
-                    {
-                        // 窗体对象可用(不为空、没释放),反馈窗体对象
-                        return (T)value;
-                    }
-                    else
-                    {
-                        // 窗体对象不可用,从字典中移除窗体对象
-                        Form temp;
-                        UniqueForms.TryRemove(typeof(T), out temp);
-                    }
-                }
-            }
-
-            // 未能返回正确的窗体,则创建新窗体(使用默认new方法)
-            T form = new T();
-            if (BackColor != null) form.BackColor = (Color)BackColor;
-            if (AddUnique(form)) return form;
-            return null;
-        }
-        private bool AddUnique<T>(T value) where T : Form, new()
-        {
-            if (!UniqueForms.ContainsKey(typeof(T)))
-            {
-                if (UniqueForms.TryAdd(typeof(T), value))
-                {
-                    return true;
-                }
-            }
-            return false;
-        }
-        /// <summary>
-        /// 设置所有窗体的背景色
-        /// </summary>
-        /// <param name="c"></param>
-        public void SetAllBackColor(Color c)
-        {
-            if (ListTool.HasElements(AllForms))
-            {
-                foreach (var form in AllForms)
-                {
-                    if (form != null && !form.IsDisposed)
-                        form.BackColor = c;
-                }
-            }
-        }
-    }
-}

+ 0 - 36
Azylee.Utils/Azylee.WinformMan/Properties/AssemblyInfo.cs

@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的一般信息由以下
-// 控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("Azylee.WinformMan")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Azylee.WinformMan")]
-[assembly: AssemblyCopyright("Copyright ©  2018")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 会使此程序集中的类型
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
-//请将此类型的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("0783d6b7-a0e9-4e3b-b2e8-c72d318f99ce")]
-
-// 程序集的版本信息由下列四个值组成: 
-//
-//      主版本
-//      次版本
-//      生成号
-//      修订号
-//
-// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
-//通过使用 "*",如下所示:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]

+ 25 - 12
Azylee.Utils/Azylee.WinformSkin/FormUI/NoTitle/NoTitleForm.cs

@@ -170,31 +170,44 @@ namespace Azylee.WinformSkin.FormUI.NoTitle
         #region Invoke UI操作
         public void UIEnable(Control ctrl, bool enable = true)
         {
-            Invoke(new Action(() =>
+            try
             {
-                ctrl.Enabled = enable;
-            }));
+                Invoke(new Action(() =>
+                {
+                    ctrl.Enabled = enable;
+                }));
+            }
+            catch { }
         }
         public void UIVisible(Control ctrl, bool enable = true)
         {
-            Invoke(new Action(() =>
+            try
             {
-                ctrl.Visible = enable;
-            }));
+                Invoke(new Action(() =>
+                {
+                    ctrl.Visible = enable;
+                }));
+            }
+            catch { }
         }
         public void UILabel(Label label, string s)
         {
-            Invoke(new Action(() =>
+            try
             {
-                label.Text = s;
-            }));
+                Invoke(new Action(() =>
+                {
+                    label.Text = s;
+                }));
+            }
+            catch { }
         }
         public void UIClose()
         {
-            Invoke(new Action(() =>
+            try
             {
-                try { Close(); } catch { }
-            }));
+                Invoke(new Action(() => { try { Close(); } catch { } }));
+            }
+            catch { }
         }
         #endregion
     }

+ 2 - 5
README.md

@@ -1,4 +1,4 @@
-# Fork
+# Fork
 
 Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,包括各种常用的工具和方法,窗口控件等。
 
@@ -14,8 +14,7 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
 2. Azylee.Core.Plus : 带其他引用的扩展方法
 3. Azylee.Update : 更新工具包
 4. Azylee.YeahWeb : Http 及网络相关工具包
-5. Azylee.WinformMan : Winform 窗体管理
-6. Azylee.WinformSkin : Winform 样式和控件
+5. Azylee.WinformSkin : Winform 样式和控件
 
 ### Azylee.Core 模块:
 
@@ -178,8 +177,6 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
   ┗ HttpToolPlus.cs             // 增强Http工具(如携带Cookie)
 ```
 
-### Azylee.WinformMan
-——暂无
 
 ### Azylee.WinformSkin
 ——暂无