private void UpdateForm_Load(object sender, EventArgs e) { st.Interval = 100; st.Enabled = true; st.Elapsed += St_Elapsed; customHxjdt.Size = new Size(250, 250); customHxjdt.Location = new Point((lbc.Width - 250) / 2, 0); customHxjdt.Value = 0; customHxjdt.Lcp = System.Drawing.Drawing2D.LineCap.Round; customHxjdt.CircularWidth = 25; customHxjdt.BackColor = Color.Transparent; customHxjdt.MainColor = pes.BackColor; lbc.DUIControls.Add(customHxjdt); this.BackColor = Color.FromArgb(185, pes.BackColor); foreach (DuiBaseControl item in lbc.DUIControls) { if (item is DuiTextBox) { DuiTextBox gxnr = item as DuiTextBox; gxnr.Text = pes.VerNo + "\r\n" + pes.UpdateContent.Replace("---", "\r\n"); } } HttpDldFile fileDownload = new HttpDldFile(); Thread thread = new Thread(() => fileDownload.Download(pes.DownloadUrl, AppDomain.CurrentDomain.BaseDirectory + @"\" + pes.MainApplicationName + ".exe", customHxjdt)); thread.Start(); }
public void DownloadFace() { string url = "http://q1.qlogo.cn/headimg_dl?dst_uin=" + inputUrl.value + "&spec=100"; string path = "texture/face/" + faceName + ".jpg"; //开始下载 HttpDldFile df = new HttpDldFile(); if (inputUrl.value.StartsWith("http")) { url = inputUrl.value; df.Download(url, path); //使用自定义Url } else { df.Download(url, path); //使用QQ头像 } //刷新头像 if (File.Exists(path)) { Texture2D Face = UIHelper.getTexture2D(path); UIHelper.faces.Remove(faceName);//防止bug,先删除再添加 UIHelper.faces.Add(faceName, Face); UIHelper.getByName <UITexture>(currentMSwindow_Face, "face_").mainTexture = Face; } }
internal static Texture2D getFace(string name) { Texture2D re = null; if (faces.TryGetValue(name, out re)) { if (re != null) { return(re); } } else if (name.Length > 0 && !(Application.internetReachability == NetworkReachability.NotReachable) && Program.I().setting.autoPicDownload) { HttpDldFile httpDldFile = new HttpDldFile(); httpDldFile.Download("https://raw.githubusercontent.com/szefo09/face/master/" + name + ".png", "texture/face/" + name + ".png"); if (File.Exists("texture/face/" + name + ".png")) { Texture2D face = UIHelper.getTexture2D("texture/face/" + name + ".png"); faces.Add(name, face); return(face); } } byte[] buffer = System.Text.Encoding.UTF8.GetBytes(name); int sum = 0; for (int i = 0; i < buffer.Length; i++) { sum += buffer[i]; } sum = sum % 100; faces.Add(name, Program.I().face.faces[sum]); return(Program.I().face.faces[sum]); }
static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.DarkBlue; Console.ForegroundColor = ConsoleColor.White; Console.Clear(); IntPtr hWnd = Process.GetCurrentProcess().MainWindowHandle; SetWindowPos(hWnd, new IntPtr(HWND_TOPMOST), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND); Console.Title = "CSO2自动升级附属程序正在运行..."; Console.WindowWidth = 65; //设置窗体宽度 Console.BufferWidth = 65; //设置缓存宽度 Console.WindowHeight = 15; //设置窗体高度 Console.BufferHeight = 15; //设置缓存高度 Console.WindowWidth = 65; //重新设置窗体宽度 System.Int32 dwflag = new int(); if (!InternetGetConnectedState(ref dwflag, 0)) { Console.WriteLine("当前上网设备出现异常!请检查网络环境后再试!"); Thread.Sleep(10000); Environment.Exit(0); } System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //创建安全通道 HttpDldFile df = new HttpDldFile(); if (File.Exists(System.IO.Path.GetTempPath() + "CSOL2魔改地图系列自动更新程序.exe")) { File.Delete(System.IO.Path.GetTempPath() + "CSOL2魔改地图系列自动更新程序.exe"); } Console.WriteLine("正在下载主程序文件..."); if (File.Exists(System.IO.Path.GetTempPath() + "updateexe.zip")) { File.Delete(System.IO.Path.GetTempPath() + "updateexe.zip"); } df.Download("https://godwhite001.github.io/updateexe.zip", System.IO.Path.GetTempPath() + "updateexe.zip"); Thread.Sleep(1000); if (File.Exists(System.IO.Path.GetTempPath() + "updateexe.zip")) { Console.WriteLine("下载完成!"); } if (File.Exists(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "CSOL2魔改地图系列自动更新程序.exe")) { File.Delete(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "CSOL2魔改地图系列自动更新程序.exe"); } ZipFile.ExtractToDirectory(System.IO.Path.GetTempPath() + "updateexe.zip", System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase); Console.WriteLine("更新完成!"); long size = GetFileSize("CSOL2魔改地图系列自动更新程序.exe"); string realsize = CountSize(size); Console.WriteLine("最新客户端文件大小:" + realsize); FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "CSOL2魔改地图系列自动更新程序.exe"); Console.WriteLine("最新客户端程序开发者:" + myFileVersionInfo.CompanyName); Console.WriteLine("最新客户端文件版本信息:" + myFileVersionInfo.FileVersion); Console.WriteLine("当前客户端MD5:" + GetMD5HashFromFile("CSOL2魔改地图系列自动更新程序.exe")); if (File.Exists(System.IO.Path.GetTempPath() + "updateexemd5.txt")) { File.Delete(System.IO.Path.GetTempPath() + "updateexemd5.txt"); } HttpDldFile df1 = new HttpDldFile(); df1.Download("https://godwhite001.github.io/updateexemd5.txt", System.IO.Path.GetTempPath() + "updateexemd5.txt"); string str; string txt; StreamReader sr = new StreamReader(System.IO.Path.GetTempPath() + "updateexemd5.txt", false); str = sr.ReadLine().ToString(); txt = str; sr.Close(); if (txt != GetMD5HashFromFile("CSOL2魔改地图系列自动更新程序.exe")) { Console.WriteLine("当前下载的客户端与服务器上的MD5不匹配!警告!服务端已被入侵,即将通知网警介入!正在退出更新程序..."); // 开发者正在进行自救,如成功则所有服务恢复正常! Thread.Sleep(10000); Process.Start("http://www.cyberpolice.cn/wfjb/"); if (File.Exists(System.IO.Path.GetTempPath() + "updateexemd5.txt")) { File.Delete(System.IO.Path.GetTempPath() + "updateexemd5.txt"); } Environment.Exit(0); } else { Console.WriteLine("所有信息效验完毕..." + '\n' + "请稍等...即将开启最新客户端!"); Thread.Sleep(10000); Process.Start("CSOL2魔改地图系列自动更新程序.exe"); if (File.Exists(System.IO.Path.GetTempPath() + "updateexemd5.txt")) { File.Delete(System.IO.Path.GetTempPath() + "updateexemd5.txt"); } Environment.Exit(0); Console.ReadLine(); } }
private void UpdateClient() { if (UIHelper.fromStringToBool(Config.Get("autoUpdateDownload_", "1"))) { try { WWW w = new WWW("https://api.github.com/repos/szefo09/ygopro-dm/contents/expansions"); while (!w.isDone) { if (Application.internetReachability == NetworkReachability.NotReachable || !string.IsNullOrEmpty(w.error)) { throw new Exception("No Internet connection!"); } } List <ApiFile> toDownload = new List <ApiFile>(); List <ApiFile> apiFromGit = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <List <ApiFile> >(w.text); if (!File.Exists("updates/SHAs.txt")) { Directory.CreateDirectory("updates"); toDownload.AddRange(apiFromGit); } if (File.Exists("updates/SHAs.txt")) { List <ApiFile> local = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <List <ApiFile> >(File.ReadAllText("updates/SHAs.txt")); foreach (ApiFile file in apiFromGit) { if (local.FirstOrDefault(x => x.name == file.name) == null || file.sha != local.FirstOrDefault(x => x.name == file.name).sha) { toDownload.Add(file); } } foreach (ApiFile f in local) { if (apiFromGit.FirstOrDefault(x => x.name == f.name) == null || f.name != apiFromGit.FirstOrDefault(x => x.name == f.name).name) { if (File.Exists("cdb/" + f.name)) { File.Delete("cdb/" + f.name); } if (File.Exists("config/" + f.name)) { File.Delete("config/" + f.name); } } } } HttpDldFile httpDldFile = new HttpDldFile(); foreach (var dl in toDownload) { if (Path.GetExtension(dl.name) == ".cdb" && !(Application.internetReachability == NetworkReachability.NotReachable)) { httpDldFile.Download(dl.download_url, Path.Combine("cdb/", dl.name)); } if (Path.GetExtension(dl.name) == ".conf" && !(Application.internetReachability == NetworkReachability.NotReachable)) { httpDldFile.Download(dl.download_url, Path.Combine("config/", dl.name)); } } File.WriteAllText("updates/SHAs.txt", w.text); } catch (Exception e) { File.Delete("updates/SHAs.txt"); } } }