public Installer(PackBlock packBlock, Windows7ProgressBar progressFile, Windows7ProgressBar progressAll, Label progressText, Label progressDetails, Label progressCurFile, PictureBox launcherButton, String gamePath, String ts3Path, String addonsPath) { this.activeForm = "packBlock"; this.packBlock = packBlock; // construct error report this.reportError = new EmailReporter(); // define controls this.progressFile = progressFile; this.progressAll = progressAll; this.progressText = progressText; this.progressDetails = progressDetails; this.progressCurFile = progressCurFile; this.launcherButton = launcherButton; // define paths gamePathBox = new TextBox(); gamePathBox.Text = gamePath; ts3PathBox = new TextBox(); ts3PathBox.Text = ts3Path; addonsPathBox = new TextBox(); addonsPathBox.Text = addonsPath; // define background worker this.installFiles.DoWork += InstallFiles_DoWork; this.installFiles.RunWorkerCompleted += InstallFiles_RunWorkerCompleted; }
public void Get() { try { gflowpacks.Controls.Clear(); XmlDocument RemoteXmlInfo = new XmlDocument(); RemoteXmlInfo.Load(Properties.GlobalValues.S_VersionXML); XmlNodeList xnl = RemoteXmlInfo.SelectNodes("//arma3Launcher//ModSets//pack"); foreach (XmlNode xn in xnl) { if (Convert.ToBoolean(xn.Attributes["enable"].Value) && (Convert.ToBoolean(xn.Attributes["public"].Value) || Properties.Settings.Default.privateKeys.Split(',').Contains(xn.Attributes["id"].Value))) { title = xn.Attributes["name"].Value; id = xn.Attributes["id"].Value; description = xn.Attributes["description"].Value; cfgUrl = RemoteXmlInfo.SelectSingleNode("//arma3Launcher//ModSetInfo//" + id).Attributes["cfgfile"].Value; addons = ""; XmlNodeList xnl2 = RemoteXmlInfo.SelectNodes("//arma3Launcher//ModSetInfo//" + id + "//mod"); foreach (XmlNode xn2 in xnl2) { if (xn2.Attributes["type"].Value == "mod") { if (xn2.Attributes["name"].Value != "@dummy") { addons = addons + " • " + xn2.Attributes["name"].Value + " (" + xn2.Attributes["version"].Value + ")" + "\n"; } } } PackBlock auxPack = new PackBlock( mainForm, title, id, description, addons, gflowpacks, Convert.ToBoolean(RemoteXmlInfo.SelectSingleNode("//arma3Launcher//ModSetInfo//" + id).Attributes["blastcore"].Value), Convert.ToBoolean(RemoteXmlInfo.SelectSingleNode("//arma3Launcher//ModSetInfo//" + id).Attributes["dragonfyre"].Value), Convert.ToBoolean(RemoteXmlInfo.SelectSingleNode("//arma3Launcher//ModSetInfo//" + id).Attributes["optional"].Value)); auxPack.Tag = string.Format("{0} {1} {2} {3}", id, title, description, addons); if (id == Properties.Settings.Default.lastAddonPack) { PictureBox btnUsePack = auxPack.Controls.Find("btn_useThis", true)[0] as PictureBox; btnUsePack.Enabled = false; btnUsePack.Image = Properties.Resources.useThis_active; mainForm.updateActivePack(title); } gflowpacks.Controls.Add(auxPack); } } Label Maring = new Label() { MaximumSize = new Size(595, 10) }; gflowpacks.Controls.Add(Maring); } catch (Exception ex) { TableLayoutPanel ErrorTable = new TableLayoutPanel(); ErrorTable.Size = new Size(gflowpacks.Size.Width-10, gflowpacks.Size.Height-15); Label ErrorRead = new Label(); ErrorRead.Anchor = AnchorStyles.None; ErrorRead.ForeColor = Color.White; ErrorRead.MinimumSize = new Size(595, 170); ErrorRead.Font = new Font("Calibri", 9, FontStyle.Bold); ErrorRead.TextAlign = ContentAlignment.BottomCenter; ErrorRead.Text = "Unable to read the contents from the server!\n" + ex.Message; ErrorTable.Controls.Add(ErrorRead); gflowpacks.Controls.Add(ErrorTable); } }
/// <summary> /// Constructor for PackBlock /// </summary> /// <param name="packBlock"></param> /// <param name="installerWorker"></param> /// <param name="progressFile"></param> /// <param name="progressAll"></param> /// <param name="progressCurFile"></param> /// <param name="progressText"></param> /// <param name="progressDetails"></param> /// <param name="launcherButton"></param> public Downloader(PackBlock packBlock, Installer installerWorker, Windows7ProgressBar progressFile, Windows7ProgressBar progressAll, Label progressCurFile, Label progressText, Label progressDetails, PictureBox launcherButton) { this.activeForm = "packBlock"; this.packBlock = packBlock; this.installer = installerWorker; this.megaClient = new MegaApiClient(); // construct error report this.reportError = new EmailReporter(); // define controls this.progressCurFile = progressCurFile; this.progressFile = progressFile; this.progressAll = progressAll; this.progressText = progressText; this.progressDetails = progressDetails; this.launcherButton = launcherButton; // define calculate worker this.calculateFiles.DoWork += CalculateFiles_DoWork; this.calculateFiles.RunWorkerCompleted += CalculateFiles_RunWorkerCompleted; this.calculateFiles.WorkerSupportsCancellation = true; // define download worker this.downloadFiles.DoWork += DownloadFiles_DoWork; this.downloadFiles.RunWorkerCompleted += DownloadFiles_RunWorkerCompleted; this.downloadFiles.WorkerSupportsCancellation = true; }