private static string FilterName(GUIModFilter filter, ModuleTag tag = null, ModuleLabel label = null) { switch (filter) { case GUIModFilter.Compatible: return(Properties.Resources.MainFilterCompatible); case GUIModFilter.Incompatible: return(Properties.Resources.MainFilterIncompatible); case GUIModFilter.Installed: return(Properties.Resources.MainFilterInstalled); case GUIModFilter.NotInstalled: return(Properties.Resources.MainFilterNotInstalled); case GUIModFilter.InstalledUpdateAvailable: return(Properties.Resources.MainFilterUpgradeable); case GUIModFilter.Replaceable: return(Properties.Resources.MainFilterReplaceable); case GUIModFilter.Cached: return(Properties.Resources.MainFilterCached); case GUIModFilter.Uncached: return(Properties.Resources.MainFilterUncached); case GUIModFilter.NewInRepository: return(Properties.Resources.MainFilterNew); case GUIModFilter.All: return(Properties.Resources.MainFilterAll); case GUIModFilter.CustomLabel: return(string.Format(Properties.Resources.MainFilterLabel, label?.Name ?? "CUSTOM")); case GUIModFilter.Tag: return(tag == null ? Properties.Resources.MainFilterUntagged : string.Format(Properties.Resources.MainFilterTag, tag.Name)); } return(""); }
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)); } }
public void UpdateChangesDialog(List <ModChange> changeset, BackgroundWorker installWorker) { changeSet = changeset; this.installWorker = installWorker; ChangesListView.Items.Clear(); if (changeset == null) { return; } // We're going to split our change-set into two parts: updated/removed mods, // and everything else (which right now is replacing and installing mods, but we may have // other types in the future). changeSet = new List <ModChange>(); changeSet.AddRange(changeset.Where(change => change.ChangeType == GUIModChangeType.Remove)); changeSet.AddRange(changeset.Where(change => change.ChangeType == GUIModChangeType.Update)); IEnumerable <ModChange> leftOver = changeset.Where(change => change.ChangeType != GUIModChangeType.Remove && change.ChangeType != GUIModChangeType.Update); // Now make our list more human-friendly (dependencies for a mod are listed directly // after it.) CreateSortedModList(leftOver); changeset = changeSet; foreach (var change in changeset) { if (change.ChangeType == GUIModChangeType.None) { continue; } CkanModule m = change.Mod; ModuleLabel warnLbl = FindLabelAlertsBeforeInstall(m); ChangesListView.Items.Add(new ListViewItem(new string[] { change.NameAndStatus, change.ChangeType.ToString(), warnLbl != null ? string.Format( Properties.Resources.MainChangesetWarningInstallingModuleWithLabel, warnLbl.Name, change.Description ) : change.Description }) { Tag = m, ForeColor = warnLbl != null ? Color.Red : SystemColors.WindowText }); } }
private void StartEdit(ModuleLabel lbl) { currentlyEditing = lbl; NameTextBox.Text = lbl.Name; ColorButton.BackColor = lbl.Color; InstanceNameComboBox.SelectedItem = lbl.InstanceName; HideFromOtherFiltersCheckBox.Checked = lbl.Hide; NotifyOnChangesCheckBox.Checked = lbl.NotifyOnChange; RemoveOnChangesCheckBox.Checked = lbl.RemoveOnChange; AlertOnInstallCheckBox.Checked = lbl.AlertOnInstall; RemoveOnInstallCheckBox.Checked = lbl.RemoveOnInstall; DeleteButton.Enabled = labels.Labels.Contains(lbl); EditDetailsPanel.Visible = true; EditDetailsPanel.BringToFront(); NameTextBox.Focus(); }
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 ListViewItem makeItem(ModChange change) { CkanModule m = change.Mod; ModuleLabel warnLbl = alertLabels?.FirstOrDefault(l => l.ModuleIdentifiers.Contains(m.identifier)); return(new ListViewItem(new string[] { change.NameAndStatus, change.ChangeType.ToString(), warnLbl != null ? string.Format( Properties.Resources.MainChangesetWarningInstallingModuleWithLabel, warnLbl.Name, change.Description ) : change.Description }) { Tag = m, ForeColor = warnLbl != null ? Color.Red : SystemColors.WindowText }); }
public ModSearch(GUIModFilter filter, ModuleTag tag = null, ModuleLabel label = null) { switch (filter) { case GUIModFilter.Compatible: Compatible = true; break; case GUIModFilter.Incompatible: Compatible = false; break; case GUIModFilter.Installed: Installed = true; break; case GUIModFilter.NotInstalled: Installed = false; break; case GUIModFilter.InstalledUpdateAvailable: Upgradeable = true; break; case GUIModFilter.Replaceable: Replaceable = true; break; case GUIModFilter.Cached: Cached = true; break; case GUIModFilter.Uncached: Cached = false; break; case GUIModFilter.NewInRepository: NewlyCompatible = true; break; case GUIModFilter.Tag: TagNames.Add(tag?.Name); break; case GUIModFilter.CustomLabel: if (label != null) { Labels.Add(label); } break; default: case GUIModFilter.All: break; } Combined = getCombined(); }
private bool LabelInSearches(ModuleLabel label) { return(activeSearches?.Any(s => s?.Labels.Contains(label) ?? false) ?? false); }
public static SavedSearch FilterToSavedSearch(GUIModFilter filter, ModuleTag tag = null, ModuleLabel label = null) { return(new SavedSearch() { Name = FilterName(filter, tag, label), Values = new List <string>() { new ModSearch(filter, tag, label).Combined }, }); }