private void GetVersions() { versionsDropDownList.Items.Clear(); versionsDropDownList.Items.Add(_configuration.Localization.UseLatestVersion); List <string> list = new List <string>(); JObject json = JObject.Parse(File.ReadAllText(_configuration.McVersions + @"\versions.json")); foreach (JObject ver in json["versions"]) { string id = ver["id"].ToString(), type = ver["type"].ToString(), text = $"{type} {id}"; list.Add(string.Format("{0} {1}", type, id)); if (IsVersionInstalled(id)) { text += " \u2705"; } RadListDataItem ritem = new RadListDataItem { Text = text, Tag = id }; switch (type) { case "snapshot": if (snapshotsCheckBox.Checked) { versionsDropDownList.Items.Add(ritem); } break; case "old_beta": if (betaCheckBox.Checked) { versionsDropDownList.Items.Add(ritem); } break; case "old_alpha": if (alphaCheckBox.Checked) { versionsDropDownList.Items.Add(ritem); } break; case "release": versionsDropDownList.Items.Add(ritem); break; default: if (otherCheckBox.Checked) { versionsDropDownList.Items.Add(ritem); } break; } } if (otherCheckBox.Checked) { foreach (VersionManifest version in from b in Directory.GetDirectories(_configuration.McVersions) where File.Exists(string.Format(@"{0}\{1}\{1}.json", _configuration.McVersions, new DirectoryInfo(b).Name)) let add = list.All(a => !a.Contains(new DirectoryInfo(b).Name)) where add where VersionManifest.IsValid(new DirectoryInfo(string.Format(@"{0}\{1}\", _configuration.McVersions, new DirectoryInfo(b).Name))) select VersionManifest.ParseVersion( new DirectoryInfo(string.Format(@"{0}\{1}\", _configuration.McVersions, new DirectoryInfo(b).Name)), false)) { versionsDropDownList.Items.Add(new RadListDataItem(version.ReleaseType + " " + version.VersionId) { Tag = version.VersionId }); } } versionsDropDownList.Items[0].Text = string.Format(versionsDropDownList.Items[0].Text, versionsDropDownList.Items[1].Tag); if (IsVersionInstalled(versionsDropDownList.Items[1].Tag.ToString())) { versionsDropDownList.Items[0].Text += " \u2705"; } if (Profile.SelectedVersion != null) { foreach ( RadListDataItem a in versionsDropDownList.Items.Where(a => a.Tag?.ToString() == Profile.SelectedVersion)) { versionsDropDownList.SelectedItem = a; return; } } versionsDropDownList.SelectedIndex = 0; }
public void GetVersions() { jsinit.ClearVersions(); // versionsDropDownList.Items.Add(_configuration.Localization.UseLatestVersion); List <string> list = new List <string>(); JObject json = JObject.Parse(File.ReadAllText(_configuration.McVersions + @"\versions.json")); foreach (JObject ver in json["versions"]) { string id = ver["id"].ToString(), type = ver["type"].ToString(), text = $"{type} {id}"; list.Add(string.Format("{0} {1}", type, id)); switch (type) { case "snapshot": if (_configuration.ApplicationConfiguration.SnapEnable == true) { jsinit.AddVersions(text.Split(' ')[0], id, IsVersionInstalled(id)); } break; case "old_beta": break; case "old_alpha": break; case "release": jsinit.AddVersions(text.Split(' ')[0], id, IsVersionInstalled(id)); break; default: jsinit.AddVersions(text, id, IsVersionInstalled(id)); break; } } foreach (String version in ForgeVersions.versions) { jsinit.AddVersions("Forge", version, IsVersionInstalled(version)); } foreach (VersionManifest version in from b in Directory.GetDirectories(_configuration.McVersions) where File.Exists(string.Format(@"{0}\{1}\{1}.json", _configuration.McVersions, new DirectoryInfo(b).Name)) let add = list.All(a => !a.Contains(new DirectoryInfo(b).Name)) where add where VersionManifest.IsValid(new DirectoryInfo(string.Format(@"{0}\{1}\", _configuration.McVersions, new DirectoryInfo(b).Name))) select VersionManifest.ParseVersion( new DirectoryInfo(string.Format(@"{0}\{1}\", _configuration.McVersions, new DirectoryInfo(b).Name)), false)) { jsinit.AddVersions("Модификация", version.VersionId, true); } if (jsinit.AlreadyInstalled) { jsinit.updateVersions(); } }