| 
					
				 | 
			
			
				@@ -6,7 +6,6 @@ using System.Collections.Generic; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Globalization; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.IO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Linq; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-using System.Net; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Runtime.Serialization.Json; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Text; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Windows.Forms; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -16,40 +15,64 @@ namespace ContextMenuManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     sealed class Updater 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const string GithubLatest = "https://api.github.com/repos/BluePointLilac/ContextMenuManager/releases/latest"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const string GiteeLatest = "https://gitee.com/api/v5/repos/BluePointLilac/ContextMenuManager/releases/latest"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const string GithubLangs = "https://api.github.com/repos/BluePointLilac/ContextMenuManager/contents/languages"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const string GiteeLangs = "https://gitee.com/api/v5/repos/BluePointLilac/ContextMenuManager/contents/languages"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GithubLatest = "https://github.com/BluePointLilac/ContextMenuManager/releases/latest"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GithubLatestApi = "https://api.github.com/repos/BluePointLilac/ContextMenuManager/releases/latest"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GithubLangsApi = "https://api.github.com/repos/BluePointLilac/ContextMenuManager/contents/languages"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const string GithubTexts = "https://raw.githubusercontent.com/BluePointLilac/ContextMenuManager/master/ContextMenuManager/Properties/Resources/Texts"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GithubDonateRaw = "https://raw.githubusercontent.com/BluePointLilac/ContextMenuManager/master/Donate.md"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GithubDonate = "https://github.com/BluePointLilac/ContextMenuManager/blob/master/Donate.md"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GiteeReleases = "https://gitee.com/BluePointLilac/ContextMenuManager/releases"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GiteeLatestApi = "https://gitee.com/api/v5/repos/BluePointLilac/ContextMenuManager/releases/latest"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GiteeLangsApi = "https://gitee.com/api/v5/repos/BluePointLilac/ContextMenuManager/contents/languages"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const string GiteeTexts = "https://gitee.com/BluePointLilac/ContextMenuManager/raw/master/ContextMenuManager/Properties/Resources/Texts"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const string GithubDonate = "https://raw.githubusercontent.com/BluePointLilac/ContextMenuManager/master/Donate.md"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        const string GiteeDonate = "https://gitee.com/BluePointLilac/ContextMenuManager/raw/master/Donate.md"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GiteeDonateRaw = "https://gitee.com/BluePointLilac/ContextMenuManager/raw/master/Donate.md"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        const string GiteeDonate = "https://gitee.com/BluePointLilac/ContextMenuManager/blob/master/Donate.md"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>定期检查更新</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         public static void PeriodicUpdate() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             int day = AppConfig.UpdateFrequency; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(day == -1) return;//自动检测更新频率为-1则从不自动检查更新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //如果上次检测更新时间加上时间间隔早于今天以前就进行更新操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(AppConfig.LastCheckUpdateTime.AddDays(day) < DateTime.Today) Update(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //如果上次检测更新时间加上时间间隔早于或等于今天以前就进行更新操作 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(AppConfig.LastCheckUpdateTime.AddDays(day) <= DateTime.Today) Update(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        public static bool Update() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>更新程序以及程序字典</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <param name="isManual">是否为手动点击更新</param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public static void Update(bool isManual) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             AppConfig.LastCheckUpdateTime = DateTime.Today; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            UpdateText(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return UpdateApp(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            UpdateText(isManual); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            UpdateApp(isManual); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private static bool UpdateApp() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>更新程序</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <param name="isManual">是否为手动点击更新</param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private static void UpdateApp(bool isManual) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            string url = AppConfig.RequestUseGithub ? GithubLatest : GiteeLatest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            string url = AppConfig.RequestUseGithub ? GithubLatestApi : GiteeLatestApi; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             XmlDocument doc = GetWebJsonToXml(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(doc == null) return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(doc == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(isManual) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    MessageBoxEx.Show(AppString.Message.FailedToReadNetworkFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    url = AppConfig.RequestUseGithub ? GithubLatest : GiteeReleases; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ExternalProgram.OpenUrl(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             XmlNode root = doc.FirstChild; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             XmlElement tagNameXE = (XmlElement)root.SelectSingleNode("tag_name"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Version webVer = new Version(tagNameXE.InnerText); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Version appVer = new Version(Application.ProductVersion); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(webVer > appVer) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //appVer = new Version(0, 0, 0, 0);//测试用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(appVer >= webVer) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(isManual) MessageBoxEx.Show(AppString.Message.VersionIsLatest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 XmlElement bodyXE = (XmlElement)root.SelectSingleNode("body"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 string info = AppString.Message.UpdateInfo.Replace("%v1", appVer.ToString()).Replace("%v2", webVer.ToString()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -77,13 +100,14 @@ namespace ContextMenuManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        private static void UpdateText() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>更新程序字典</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <param name="isManual">是否为手动点击更新</param> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private static void UpdateText(bool isManual) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            bool flag = isManual; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             string url = AppConfig.RequestUseGithub ? GithubTexts : GiteeTexts; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             string[] fileNames = new[] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -95,17 +119,24 @@ namespace ContextMenuManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 string fileUrl = $"{url}/{fileName}"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 string filePath = $@"{AppConfig.WebDicsDir}\{fileName}"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 string contents = GetWebString(fileUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(string.IsNullOrEmpty(contents)) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(string.IsNullOrEmpty(contents)) { flag = false; continue; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 contents = contents.Replace("\n", Environment.NewLine); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 File.WriteAllText(filePath, contents, Encoding.Unicode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(!flag) MessageBoxEx.Show(AppString.Message.FailedToReadNetworkFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>显示语言下载对话框</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <returns>返回值为是否下载了语言文件</returns> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         public static bool ShowLanguageDialog() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            string url = AppConfig.RequestUseGithub ? GithubLangs : GiteeLangs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            string url = AppConfig.RequestUseGithub ? GithubLangsApi : GiteeLangsApi; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             XmlDocument doc = GetWebJsonToXml(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(doc == null) return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(doc == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                MessageBoxEx.Show(AppString.Message.FailedToReadNetworkFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Dictionary<string, string> langs = new Dictionary<string, string>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             foreach(XmlElement itemXE in doc.FirstChild.SelectNodes("item")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -133,12 +164,18 @@ namespace ContextMenuManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>显示捐赠名单对话框</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         public static void ShowDonateDialog() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            string url = AppConfig.RequestUseGithub ? GithubDonate : GiteeDonate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            string url = AppConfig.RequestUseGithub ? GithubDonateRaw : GiteeDonateRaw; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             string contents = GetWebString(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //string contents = File.ReadAllText(@"..\..\..\Donate.md");//用于求和更新Donate.md文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(contents == null) ExternalProgram.OpenUrl(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //contents = File.ReadAllText(@"..\..\..\Donate.md");//用于求和更新Donate.md文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(contents == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                MessageBoxEx.Show(AppString.Message.FailedToReadNetworkFile); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                url = AppConfig.RequestUseGithub ? GithubDonate : GiteeDonate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ExternalProgram.OpenUrl(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 using(DonateListDialog dlg = new DonateListDialog()) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -149,6 +186,7 @@ namespace ContextMenuManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>加工处理更新信息,去掉标题头</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static string MachinedInfo(string info) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             string str = string.Empty; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -169,28 +207,33 @@ namespace ContextMenuManager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return str; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>获取网页文本</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static string GetWebString(string url) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                using(WebResponse response = WebRequest.Create(url).GetResponse()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                using(StreamReader stream = new StreamReader(response.GetResponseStream())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    return stream?.ReadToEnd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                using(UAWebClient client = new UAWebClient()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return client.DownloadString(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             catch { return null; } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /// <summary>获取网页Json文本并加工为Xml</summary> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static XmlDocument GetWebJsonToXml(string url) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                using(WebResponse response = WebRequest.Create(url).GetResponse()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                using(StreamReader stream = new StreamReader(response.GetResponseStream())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                using(XmlReader reader = JsonReaderWriterFactory.CreateJsonReader(stream?.BaseStream, XmlDictionaryReaderQuotas.Max)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                using(UAWebClient client = new UAWebClient()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    XmlDocument doc = new XmlDocument(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    doc.Load(reader); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    return doc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    byte[] bytes = client.DownloadData(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    using(XmlReader xReader = JsonReaderWriterFactory.CreateJsonReader(bytes, XmlDictionaryReaderQuotas.Max)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        XmlDocument doc = new XmlDocument(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        doc.Load(xReader); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        return doc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             catch { return null; } 
			 |