private void UpdateModInfo(GUIMod gui_module) { CkanModule module = gui_module.ToModule(); Util.Invoke(MetadataModuleNameLabel, () => MetadataModuleNameLabel.Text = gui_module.Name); Util.Invoke(MetadataModuleVersionLabel, () => MetadataModuleVersionLabel.Text = gui_module.LatestVersion.ToString()); Util.Invoke(MetadataModuleLicenseLabel, () => MetadataModuleLicenseLabel.Text = string.Join(", ",module.license)); Util.Invoke(MetadataModuleAuthorLabel, () => MetadataModuleAuthorLabel.Text = gui_module.Authors); Util.Invoke(MetadataModuleAbstractLabel, () => MetadataModuleAbstractLabel.Text = module.@abstract); Util.Invoke(MetadataIdentifierLabel, () => MetadataIdentifierLabel.Text = module.identifier); // If we have homepage provided use that, otherwise use the kerbalstuff page or the github repo so that users have somewhere to get more info than just the abstract. Util.Invoke(MetadataModuleHomePageLinkLabel, () => MetadataModuleHomePageLinkLabel.Text = gui_module.Homepage.ToString()); if (module.resources != null && module.resources.repository != null) { Util.Invoke(MetadataModuleGitHubLinkLabel, () => MetadataModuleGitHubLinkLabel.Text = module.resources.repository.ToString()); } else { Util.Invoke(MetadataModuleGitHubLinkLabel, () => MetadataModuleGitHubLinkLabel.Text = "N/A"); } if (module.release_status != null) { Util.Invoke(MetadataModuleReleaseStatusLabel, () => MetadataModuleReleaseStatusLabel.Text = module.release_status.ToString()); } Util.Invoke(MetadataModuleKSPCompatibilityLabel, () => MetadataModuleKSPCompatibilityLabel.Text = gui_module.KSPCompatibilityLong); }
public void NewGuiModsAreNotSelectedForUpgrade() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager(new NullUser(), new FakeWin32Registry(tidy.KSP)){CurrentInstance = tidy.KSP}; var registry = Registry.Empty(); var ckan_mod = TestData.kOS_014_module(); registry.AddAvailable(ckan_mod); var mod = new GUIMod(ckan_mod, registry, manager.CurrentInstance.Version()); Assert.False(mod.IsUpgradeChecked); } }
public ModChange(GUIMod mod, GUIModChangeType changeType, SelectionReason reason) { Mod = mod; ChangeType = changeType; Reason = reason; if (Reason == null) { // Hey, we don't have a Reason // Most likely the user wanted to install it Reason = new SelectionReason.UserRequested(); } }
public void HasUpdateReturnsTrueWhenUpdateAvailible() { using (var tidy = new DisposableKSP()) { var generatror = new RandomModuleGenerator(new Random(0451)); var old_version = generatror.GeneratorRandomModule(version: new Version("0.24"), ksp_version: tidy.KSP.Version()); var new_version = generatror.GeneratorRandomModule(version: new Version("0.25"), ksp_version: tidy.KSP.Version(), identifier:old_version.identifier); var registry = Registry.Empty(); registry.RegisterModule(old_version, Enumerable.Empty<string>(), null); registry.AddAvailable(new_version); var mod = new GUIMod(old_version, registry, tidy.KSP.Version()); Assert.True(mod.HasUpdate); } }
public async Task ComputeChangeSetFromModList_WithConflictingMods_ThrowsInconsistentKraken() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager(new NullUser(), new FakeWin32Registry(tidy.KSP)) { CurrentInstance = tidy.KSP }; var registry = Registry.Empty(); var module = TestData.FireSpitterModule(); module.conflicts = new List<RelationshipDescriptor> { new RelationshipDescriptor { name = "kOS" } }; registry.AddAvailable(TestData.FireSpitterModule()); registry.AddAvailable(TestData.kOS_014_module()); registry.RegisterModule(module, Enumerable.Empty<string>(), tidy.KSP); var main_mod_list = new MainModList(null, null); var mod = new GUIMod(TestData.FireSpitterModule(), registry, manager.CurrentInstance.Version()); var mod2 = new GUIMod(TestData.kOS_014_module(), registry, manager.CurrentInstance.Version()); mod.IsInstallChecked = true; mod2.IsInstallChecked = true; var compute_change_set_from_mod_list = main_mod_list.ComputeChangeSetFromModList(registry, main_mod_list.ComputeUserChangeSet(), null, tidy.KSP.Version()); await UtilStatic.Throws<InconsistentKraken>(async ()=> { await compute_change_set_from_mod_list; }); } }
public async Task ComputeChangeSetFromModList_WithConflictingMods_ThrowsInconsistentKraken() { using (var tidy = new DisposableKSP()) { var registry = Registry.Empty(); var module = TestData.FireSpitterModule(); module.conflicts = new List<RelationshipDescriptor> { new RelationshipDescriptor { name = "kOS" } }; registry.AddAvailable(module); registry.AddAvailable(TestData.kOS_014_module()); registry.RegisterModule(module, Enumerable.Empty<string>(), tidy.KSP); var mainList = new MainModList(null, null, new GUIUser()); var mod = new GUIMod(module, registry, tidy.KSP.VersionCriteria()); var mod2 = new GUIMod(TestData.kOS_014_module(), registry, tidy.KSP.VersionCriteria()); var mods = new List<GUIMod>() { mod, mod2 }; mainList.ConstructModList(mods, true); mainList.Modules = new ReadOnlyCollection<GUIMod>(mods); mod2.IsInstallChecked = true; var computeTask = mainList.ComputeChangeSetFromModList(registry, mainList.ComputeUserChangeSet(), null, tidy.KSP.VersionCriteria()); await UtilStatic.Throws<InconsistentKraken>(() => computeTask); } }
private bool MatchesAuthor(GUIMod mod) { return(string.IsNullOrWhiteSpace(Author) || mod.SearchableAuthors.Any(author => author.IndexOf(Author, StringComparison.InvariantCultureIgnoreCase) != -1)); }
private bool IsAuthorInauthorFilter(GUIMod mod) { return mod.Authors.IndexOf(ModAuthorFilter, StringComparison.InvariantCultureIgnoreCase) != -1; }
public bool IsVisible(GUIMod mod) { var nameMatchesFilter = IsNameInNameFilter(mod); var authorMatchesFilter = IsAuthorInauthorFilter(mod); var modMatchesType = IsModInFilter(mod); var isVisible = nameMatchesFilter && modMatchesType && authorMatchesFilter; return isVisible; }
private bool MatchesDescription(GUIMod mod) { return(string.IsNullOrWhiteSpace(Description) || mod.SearchableAbstract.IndexOf(Description, StringComparison.InvariantCultureIgnoreCase) != -1 || mod.SearchableDescription.IndexOf(Description, StringComparison.InvariantCultureIgnoreCase) != -1); }
protected bool Equals(GUIMod other) { return Equals(Name, other.Name); }
private bool IsNameInNameFilter(GUIMod mod) { return(mod.Name.IndexOf(ModNameFilter, StringComparison.InvariantCultureIgnoreCase) != -1 || mod.Abbrevation.IndexOf(ModNameFilter, StringComparison.InvariantCultureIgnoreCase) != -1 || mod.Identifier.IndexOf(ModNameFilter, StringComparison.InvariantCultureIgnoreCase) != -1); }
private bool IsModInFilter(GUIModFilter filter, ModuleTag tag, ModuleLabel label, GUIMod m) { switch (filter) { case GUIModFilter.Compatible: return(!m.IsIncompatible); case GUIModFilter.Installed: return(m.IsInstalled); case GUIModFilter.InstalledUpdateAvailable: return(m.IsInstalled && m.HasUpdate); case GUIModFilter.Cached: return(m.IsCached); case GUIModFilter.Uncached: return(!m.IsCached); case GUIModFilter.NewInRepository: return(m.IsNew); case GUIModFilter.NotInstalled: return(!m.IsInstalled); case GUIModFilter.Incompatible: return(m.IsIncompatible); case GUIModFilter.Replaceable: return(m.IsInstalled && m.HasReplacement); case GUIModFilter.All: return(true); case GUIModFilter.Tag: return(tag?.ModuleIdentifiers.Contains(m.Identifier) ?? ModuleTags.Untagged.Contains(m.Identifier)); case GUIModFilter.CustomLabel: return(label?.ModuleIdentifiers?.Contains(m.Identifier) ?? false); default: throw new Kraken(string.Format(Properties.Resources.MainModListUnknownFilter, filter)); } }
private bool HiddenByTagsOrLabels(GUIModFilter filter, ModuleTag tag, ModuleLabel label, GUIMod m, string instanceName) { if (filter != GUIModFilter.CustomLabel) { // "Hide" labels apply to all non-custom filters if (ModuleLabels?.LabelsFor(instanceName) .Where(l => l != label && l.Hide) .Any(l => l.ModuleIdentifiers.Contains(m.Identifier)) ?? false) { return(true); } if (ModuleTags?.Tags?.Values .Where(t => t != tag && t.Visible == false) .Any(t => t.ModuleIdentifiers.Contains(m.Identifier)) ?? false) { return(true); } } return(false); }
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); }
public bool IsVisible(GUIMod mod, string instanceName) { return((activeSearch?.Matches(mod) ?? true) && IsModInFilter(ModFilter, TagFilter, CustomLabelFilter, mod) && !HiddenByTagsOrLabels(ModFilter, TagFilter, CustomLabelFilter, mod, instanceName)); }
private void UpdateModInfo(GUIMod gui_module) { CkanModule module = gui_module.ToModule(); Util.Invoke(MetadataModuleNameTextBox, () => MetadataModuleNameTextBox.Text = module.name); UpdateTagsAndLabels(module); Util.Invoke(MetadataModuleAbstractLabel, () => MetadataModuleAbstractLabel.Text = module.@abstract); Util.Invoke(MetadataModuleDescriptionTextBox, () => { MetadataModuleDescriptionTextBox.Text = module.description ?.Replace("\r\n", "\n").Replace("\n", Environment.NewLine); MetadataModuleDescriptionTextBox.ScrollBars = string.IsNullOrWhiteSpace(module.description) ? ScrollBars.None : ScrollBars.Vertical; }); Util.Invoke(MetadataModuleVersionTextBox, () => MetadataModuleVersionTextBox.Text = gui_module.LatestVersion.ToString()); Util.Invoke(MetadataModuleLicenseTextBox, () => MetadataModuleLicenseTextBox.Text = string.Join(", ", module.license)); Util.Invoke(MetadataModuleAuthorTextBox, () => MetadataModuleAuthorTextBox.Text = gui_module.Authors); Util.Invoke(MetadataIdentifierTextBox, () => MetadataIdentifierTextBox.Text = module.identifier); Util.Invoke(MetadataModuleReleaseStatusTextBox, () => { if (module.release_status == null) { ReleaseLabel.Visible = false; MetadataModuleReleaseStatusTextBox.Visible = false; MetaDataLowerLayoutPanel.LayoutSettings.RowStyles[3].Height = 0; } else { ReleaseLabel.Visible = true; MetadataModuleReleaseStatusTextBox.Visible = true; MetaDataLowerLayoutPanel.LayoutSettings.RowStyles[3].Height = 30; MetadataModuleReleaseStatusTextBox.Text = module.release_status.ToString(); } }); Util.Invoke(MetadataModuleGameCompatibilityTextBox, () => MetadataModuleGameCompatibilityTextBox.Text = gui_module.GameCompatibilityLong); Util.Invoke(ModInfoTabControl, () => { // Mono doesn't draw TabPage.ImageIndex, so fake it const string fakeStopSign = "<!> "; ComponentResourceManager resources = new SingleAssemblyComponentResourceManager(typeof(ModInfo)); resources.ApplyResources(RelationshipTabPage, "RelationshipTabPage"); resources.ApplyResources(AllModVersionsTabPage, "AllModVersionsTabPage"); if (gui_module.IsIncompatible) { if (!module.IsCompatibleKSP(manager.CurrentInstance.VersionCriteria())) { AllModVersionsTabPage.Text = fakeStopSign + AllModVersionsTabPage.Text; } else { RelationshipTabPage.Text = fakeStopSign + RelationshipTabPage.Text; } } }); Util.Invoke(ReplacementTextBox, () => { if (module.replaced_by == null) { ReplacementLabel.Visible = false; ReplacementTextBox.Visible = false; MetaDataLowerLayoutPanel.LayoutSettings.RowStyles[6].Height = 0; } else { ReplacementLabel.Visible = true; ReplacementTextBox.Visible = true; MetaDataLowerLayoutPanel.LayoutSettings.RowStyles[6].Height = 30; ReplacementTextBox.Text = module.replaced_by.ToString(); } }); Util.Invoke(MetaDataLowerLayoutPanel, () => { ClearResourceLinks(); var res = module.resources; if (res != null) { AddResourceLink(Properties.Resources.ModInfoHomepageLabel, res.homepage); AddResourceLink(Properties.Resources.ModInfoSpaceDockLabel, res.spacedock); AddResourceLink(Properties.Resources.ModInfoCurseLabel, res.curse); AddResourceLink(Properties.Resources.ModInfoRepositoryLabel, res.repository); AddResourceLink(Properties.Resources.ModInfoBugTrackerLabel, res.bugtracker); AddResourceLink(Properties.Resources.ModInfoContinuousIntegrationLabel, res.ci); AddResourceLink(Properties.Resources.ModInfoLicenseLabel, res.license); AddResourceLink(Properties.Resources.ModInfoManualLabel, res.manual); AddResourceLink(Properties.Resources.ModInfoMetanetkanLabel, res.metanetkan); AddResourceLink(Properties.Resources.ModInfoRemoteAvcLabel, res.remoteAvc); AddResourceLink(Properties.Resources.ModInfoStoreLabel, res.store); AddResourceLink(Properties.Resources.ModInfoSteamStoreLabel, res.steamstore); } }); }
private bool MatchesConflicts(GUIMod mod) { return(RelationshipMatch(mod.ToModule().conflicts, ConflictsWith)); }
private bool MatchesSuggests(GUIMod mod) { return(RelationshipMatch(mod.ToModule().suggests, Suggests)); }
private void ModInfo_OnDownloadClick(GUIMod gmod) { StartDownload(gmod); }
private bool IsAbstractInDescriptionFilter(GUIMod mod) { return(mod.Abstract.IndexOf(ModDescriptionFilter, StringComparison.InvariantCultureIgnoreCase) != -1); }
private bool IsAuthorInAuthorFilter(GUIMod mod) { string sanitisedModAuthorFilter = CkanModule.nonAlphaNums.Replace(ModAuthorFilter, ""); return(mod.SearchableAuthors.Any((author) => author.IndexOf(sanitisedModAuthorFilter, StringComparison.InvariantCultureIgnoreCase) != -1)); }
private void ManageMods_OnSelectedModuleChanged(GUIMod m) { ActiveModInfo = m; }
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.Equals(mod)); 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); }
private bool IsAuthorInauthorFilter(GUIMod mod) { return(mod.Authors.IndexOf(ModAuthorFilter, StringComparison.InvariantCultureIgnoreCase) != -1); }
private bool Equals(GUIMod other) { return(Equals(Identifier, other.Identifier)); }
private bool IsNameInNameFilter(GUIMod mod) { string abbrevation = new string(mod.Name.Split(' '). Where(s => s.Length > 0).Select(s => s[0]).ToArray()); return mod.Name.IndexOf(ModNameFilter, StringComparison.InvariantCultureIgnoreCase) != -1 || abbrevation.IndexOf(ModNameFilter, StringComparison.InvariantCultureIgnoreCase) != -1; }
private bool Equals(GUIMod other) { return(Equals(Name, other.Name)); }
private bool Equals(GUIMod other) { return Equals(Name, other.Name); }
private bool MatchesDepends(GUIMod mod) { return(RelationshipMatch(mod.ToModule().depends, DependsOn)); }
private bool IsNameInNameFilter(GUIMod mod) { return mod.Name.IndexOf(ModNameFilter, StringComparison.InvariantCultureIgnoreCase) != -1; }
void NavGoToMod(GUIMod module) { // focussing on a mod also causes navigation, but we don't // want this to affect the history. so we switch to read-only // mode. navHistory.IsReadOnly = true; FocusMod(module.Name, true); navHistory.IsReadOnly = false; }
private bool IsModInFilter(GUIMod m) { switch (ModFilter) { case GUIModFilter.Compatible: return !m.IsIncompatible; case GUIModFilter.Installed: return m.IsInstalled; case GUIModFilter.InstalledUpdateAvailable: return m.IsInstalled && m.HasUpdate; case GUIModFilter.NewInRepository: return m.IsNew; case GUIModFilter.NotInstalled: return !m.IsInstalled; case GUIModFilter.Incompatible: return m.IsIncompatible; case GUIModFilter.All: return true; } throw new Kraken("Unknown filter type in IsModInFilter"); }
public bool IsVisible(GUIMod mod, string instanceName) { return((activeSearches?.Any(s => s?.Matches(mod) ?? true) ?? true) && !HiddenByTagsOrLabels(mod, instanceName)); }
private void FocusMod(string key, bool exactMatch, bool showAsFirst = false) { DataGridViewRow current_row = ModList.CurrentRow; int currentIndex = current_row?.Index ?? 0; DataGridViewRow first_match = null; var does_name_begin_with_key = new Func <DataGridViewRow, bool>(row => { GUIMod mod = row.Tag as GUIMod; bool row_match; if (exactMatch) { row_match = mod.Name == key || mod.Identifier == key; } else { row_match = mod.Name.StartsWith(key, StringComparison.OrdinalIgnoreCase) || mod.Abbrevation.StartsWith(key, StringComparison.OrdinalIgnoreCase) || mod.Identifier.StartsWith(key, StringComparison.OrdinalIgnoreCase); } if (row_match && first_match == null) { // Remember the first match to allow cycling back to it if necessary. first_match = row; } if (key.Length == 1 && row_match && row.Index <= currentIndex) { // Keep going forward if it's a single key match and not ahead of the current row. return(false); } return(row_match); }); ModList.ClearSelection(); var rows = ModList.Rows.Cast <DataGridViewRow>().Where(row => row.Visible); DataGridViewRow match = rows.FirstOrDefault(does_name_begin_with_key); if (match == null && first_match != null) { // If there were no matches after the first match, cycle over to the beginning. match = first_match; } if (match != null) { match.Selected = true; // Setting this to the 'Name' cell prevents the checkbox from being toggled // by pressing 'Space' while the row is not indicated as active. ModList.CurrentCell = match.Cells[2]; if (showAsFirst) { ModList.FirstDisplayedScrollingRowIndex = match.Index; } } else { AddStatusMessage("Not found."); } }
private bool MatchesRecommends(GUIMod mod) { return(RelationshipMatch(mod.ToModule().recommends, Recommends)); }
void NavSelectMod(GUIMod module) { navHistory.AddToHistory(module); }
private void NavSelectMod(GUIMod module) { navHistory.AddToHistory(module); }
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 ? "AD" : "-" }; var updating = mod.IsInstallable() && mod.HasUpdate ? (DataGridViewCell) new DataGridViewCheckBoxCell() { Value = myChange == null ? false : myChange.ChangeType == GUIModChangeType.Update ? 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 compat = new DataGridViewTextBoxCell() { Value = mod.KSPCompatibility }; var size = new DataGridViewTextBoxCell() { Value = mod.DownloadSize }; var installDate = new DataGridViewTextBoxCell() { Value = mod.InstallDate }; var downloadCount = new DataGridViewTextBoxCell() { Value = mod.DownloadCount }; var desc = new DataGridViewTextBoxCell() { Value = mod.Abstract }; item.Cells.AddRange(selecting, updating, name, author, installVersion, latestVersion, compat, size, installDate, downloadCount, desc); selecting.ReadOnly = selecting is DataGridViewTextBoxCell; updating.ReadOnly = updating is DataGridViewTextBoxCell; return(item); }
public static bool IsInstallable(this GUIMod mod) { return(!(mod == null || mod.IsAutodetected || mod.IsIncompatible)); }