private DataGridViewRow MakeRow(GUIMod mod, List <ModChange> changes, string instanceName, bool hideEpochs = false, bool hideV = false) { DataGridViewRow item = new DataGridViewRow() { Tag = mod }; Color?myColor = ModuleLabels.LabelsFor(instanceName) .FirstOrDefault(l => l.ModuleIdentifiers.Contains(mod.Identifier)) ?.Color; if (myColor.HasValue) { item.DefaultCellStyle.BackColor = myColor.Value; } ModChange myChange = changes?.FindLast((ModChange ch) => ch.Mod.Equals(mod)); var selecting = mod.IsAutodetected ? new DataGridViewTextBoxCell() { Value = Properties.Resources.MainModListAutoDetected } : mod.IsInstallable() ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = myChange == null ? mod.IsInstalled : myChange.ChangeType == GUIModChangeType.Install ? true : myChange.ChangeType == GUIModChangeType.Remove ? false : mod.IsInstalled } : new DataGridViewTextBoxCell() { Value = "-" }; var autoInstalled = mod.IsInstalled && !mod.IsAutodetected ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = mod.IsAutoInstalled } : new DataGridViewTextBoxCell() { Value = "-" }; var updating = mod.IsInstallable() && mod.HasUpdate ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = myChange == null ? false : myChange.ChangeType == GUIModChangeType.Update ? true : false } : new DataGridViewTextBoxCell() { Value = "-" }; var replacing = IsModInFilter(GUIModFilter.Replaceable, null, null, mod) ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = myChange == null ? false : myChange.ChangeType == GUIModChangeType.Replace ? true : false } : new DataGridViewTextBoxCell() { Value = "-" }; var name = new DataGridViewTextBoxCell { Value = mod.Name.Replace("&", "&&") }; var author = new DataGridViewTextBoxCell { Value = mod.Authors.Replace("&", "&&") }; var installVersion = new DataGridViewTextBoxCell() { Value = hideEpochs ? (hideV ? ModuleInstaller.StripEpoch(ModuleInstaller.StripV(mod.InstalledVersion ?? "")) : ModuleInstaller.StripEpoch(mod.InstalledVersion ?? "")) : (hideV ? ModuleInstaller.StripV(mod.InstalledVersion ?? "") : mod.InstalledVersion ?? "") }; var latestVersion = new DataGridViewTextBoxCell() { Value = hideEpochs ? (hideV ? ModuleInstaller.StripEpoch(ModuleInstaller.StripV(mod.LatestVersion)) : ModuleInstaller.StripEpoch(mod.LatestVersion)) : (hideV ? ModuleInstaller.StripV(mod.LatestVersion) : mod.LatestVersion) }; var downloadCount = new DataGridViewTextBoxCell { Value = $"{mod.DownloadCount:N0}" }; var compat = new DataGridViewTextBoxCell { Value = mod.GameCompatibility }; var size = new DataGridViewTextBoxCell { Value = mod.DownloadSize }; var releaseDate = new DataGridViewTextBoxCell { Value = mod.ToModule().release_date }; var installDate = new DataGridViewTextBoxCell { Value = mod.InstallDate }; var desc = new DataGridViewTextBoxCell { Value = mod.Abstract.Replace("&", "&&") }; item.Cells.AddRange(selecting, autoInstalled, updating, replacing, name, author, installVersion, latestVersion, compat, size, releaseDate, installDate, downloadCount, desc); selecting.ReadOnly = selecting is DataGridViewTextBoxCell; autoInstalled.ReadOnly = autoInstalled is DataGridViewTextBoxCell; updating.ReadOnly = updating is DataGridViewTextBoxCell; return(item); }
private DataGridViewRow MakeRow(GUIMod mod, List <ModChange> changes, bool hideEpochs = false, bool hideV = false) { DataGridViewRow item = new DataGridViewRow() { Tag = mod }; ModChange myChange = changes?.FindLast((ModChange ch) => ch.Mod.Identifier == mod.Identifier); var selecting = mod.IsInstallable() ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = myChange == null ? mod.IsInstalled : myChange.ChangeType == GUIModChangeType.Install ? true : myChange.ChangeType == GUIModChangeType.Remove ? false : mod.IsInstalled } : new DataGridViewTextBoxCell() { Value = mod.IsAutodetected ? Properties.Resources.MainModListAutoDetected : "-" }; var autoInstalled = mod.IsInstalled && !mod.IsAutodetected ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = mod.IsAutoInstalled } : new DataGridViewTextBoxCell() { Value = "-" }; var updating = mod.IsInstallable() && mod.HasUpdate ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = myChange == null ? false : myChange.ChangeType == GUIModChangeType.Update ? true : false } : new DataGridViewTextBoxCell() { Value = "-" }; var replacing = IsModInFilter(GUIModFilter.Replaceable, mod) ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = myChange == null ? false : myChange.ChangeType == GUIModChangeType.Replace ? true : false } : new DataGridViewTextBoxCell() { Value = "-" }; var name = new DataGridViewTextBoxCell() { Value = mod.Name }; var author = new DataGridViewTextBoxCell() { Value = mod.Authors }; var installVersion = new DataGridViewTextBoxCell() { Value = hideEpochs ? (hideV ? ModuleInstaller.StripEpoch(ModuleInstaller.StripV(mod.InstalledVersion ?? "")) : ModuleInstaller.StripEpoch(mod.InstalledVersion ?? "")) : (hideV ? ModuleInstaller.StripV(mod.InstalledVersion ?? "") : mod.InstalledVersion ?? "") }; var latestVersion = new DataGridViewTextBoxCell() { Value = hideEpochs ? (hideV ? ModuleInstaller.StripEpoch(ModuleInstaller.StripV(mod.LatestVersion)) : ModuleInstaller.StripEpoch(mod.LatestVersion)) : (hideV ? ModuleInstaller.StripV(mod.LatestVersion) : mod.LatestVersion) }; var downloadCount = new DataGridViewTextBoxCell() { Value = String.Format("{0:N0}", mod.DownloadCount) }; var compat = new DataGridViewTextBoxCell() { Value = mod.KSPCompatibility }; var size = new DataGridViewTextBoxCell() { Value = mod.DownloadSize }; var installDate = new DataGridViewTextBoxCell() { Value = mod.InstallDate }; var desc = new DataGridViewTextBoxCell() { Value = mod.Abstract }; item.Cells.AddRange(selecting, autoInstalled, updating, replacing, name, author, installVersion, latestVersion, compat, size, installDate, downloadCount, desc); selecting.ReadOnly = selecting is DataGridViewTextBoxCell; autoInstalled.ReadOnly = autoInstalled is DataGridViewTextBoxCell; updating.ReadOnly = updating is DataGridViewTextBoxCell; return(item); }