public void PerformRepair(main MainfForm) { string ServerManifest = ""; long TotalSize = 0; double counter = 0; string path = System.IO.Path.GetFullPath("./"); string line; try { ServerManifest = wc.DownloadString(NetworkThing.Info.getManifestFileFromUrl()); } catch (WebException e) { Launcher.Properties.Settings.Default.isOffline = true; if (Launcher.Properties.Resources.Debug == "true") { MessageBox.Show(e.ToString()); } ; Application.Exit(); } if (isFileExist(path + NetworkThing.Info.getManifestFile())) { } else { FileStream ss = File.Create(path + NetworkThing.Info.getManifestFile()); ss.Close(); System.IO.File.WriteAllText(path + NetworkThing.Info.getManifestFile(), ServerManifest); } string[] separators = { ":" }; System.IO.StringReader file = new System.IO.StringReader(ServerManifest); int Totalcount = File.ReadAllLines(NetworkThing.Info.getManifestFile()).Length; while ((line = file.ReadLine()) != null) { if (Thread.CurrentThread.IsAlive == false) { return; } string[] converted = line.Split(separators, StringSplitOptions.RemoveEmptyEntries); string FilePath = converted[0]; // path of the file: C/etc string FileHash = converted[1]; // md5 hash of the file if (isFileExist(FilePath) == false) { fileToDownload.Add(FilePath); TotalSize += long.Parse(converted[2]); // size of the file } else { string md5Local = GetMD5HashFromFile(path + FilePath); // here we check if the md5 from the server match with our local file (player modification ?) if (md5Local.Equals(converted[1]) == false) { fileToDownload.Add(FilePath); TotalSize += long.Parse(converted[2]); // size of the file } } counter += 1; if (MainfForm != null && MainfForm.Created) { double value = ((counter / Totalcount)); int final = (int)Math.Truncate(value * 100); MainfForm.Invoke(new Action(() => MainfForm.updateProgressBarValue(final))); } } if (MainfForm != null && MainfForm.Created) { MainfForm.Invoke(new Action(() => MainfForm.updaterCallBack(fileToDownload, TotalSize, true))); } }
public LauncherSettings(main Mainform) { MainView = Mainform; InitializeComponent(); }
public NetworkInterface(main MainView) { MainForm = MainView; InitializeNetworkInterface(); InitializeTimer(); }