Пример #1
0
 public int CountModsByFilter(GUIModFilter filter)
 {
     if (filter == GUIModFilter.All)
     {
         // Don't check each one
         return(Modules.Count);
     }
     return(Modules.Count(m => IsModInFilter(filter, m)));
 }
Пример #2
0
 public int CountModsByFilter(GUIModFilter filter)
 {
     if (filter == GUIModFilter.All)
     {
         // Don't check each one
         return(Modules.Count);
     }
     // Tags and Labels are not counted here
     return(Modules.Count(m => IsModInFilter(filter, null, null, m)));
 }
Пример #3
0
 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
         },
     });
 }
Пример #4
0
        /// <summary>
        /// Called when the modlist filter (all, compatible, incompatible...) is changed.
        /// </summary>
        /// <param name="filter">Filter.</param>
        private void Filter(GUIModFilter filter)
        {
            // Triggers mainModList.ModFiltersUpdated()
            mainModList.ModFilter = filter;

            // Ask the configuration which columns to show.
            foreach (DataGridViewColumn col in ModList.Columns)
            {
                // Start with the third column, because the first one is always shown
                // and the 2nd/3rd are handled by UpdateModsList().
                if (col.Index > 2)
                {
                    col.Visible = !configuration.HiddenColumnNames.Contains(col.Name);
                }
            }

            switch (filter)
            {
            // Some columns really do / don't make sense to be visible on certain filter settings.
            // Hide / Show them, without writing to config, so once the user changes tab again,
            // they are shown / hidden again, as before.
            case GUIModFilter.All:                      FilterToolButton.Text = "Filter (All)";           break;

            case GUIModFilter.Incompatible:             FilterToolButton.Text = "Filter (Incompatible)";  break;

            case GUIModFilter.Installed:                FilterToolButton.Text = "Filter (Installed)";     break;

            case GUIModFilter.InstalledUpdateAvailable: FilterToolButton.Text = "Filter (Upgradeable)";   break;

            case GUIModFilter.Replaceable:              FilterToolButton.Text = "Filter (Replaceable)";   break;

            case GUIModFilter.Cached:                   FilterToolButton.Text = "Filter (Cached)";        break;

            case GUIModFilter.NewInRepository:          FilterToolButton.Text = "Filter (New)";           break;

            case GUIModFilter.NotInstalled:             FilterToolButton.Text = "Filter (Not installed)";
                ModList.Columns[5].Visible = false;
                ModList.Columns[9].Visible = false;               break;

            default:                                    FilterToolButton.Text = "Filter (Compatible)";    break;
            }
        }
Пример #5
0
        private int CountModsByFilter(GUIModFilter filter)
        {
            Registry          registry = RegistryManager.Instance(KSPManager.CurrentInstance).registry;
            List <CkanModule> modules  = registry.Available();

            int count = modules.Count();

            // filter by left menu selection
            switch (filter)
            {
            case GUIModFilter.All:
                break;

            case GUIModFilter.Installed:
                count -= modules.Count(m => !registry.IsInstalled(m.identifier));
                break;

            case GUIModFilter.InstalledUpdateAvailable:
                count -= modules.Count
                         (
                    m => !(registry.IsInstalled(m.identifier) &&
                           m.version.IsGreaterThan(
                               registry.InstalledVersion(m.identifier)))
                         );
                break;

            case GUIModFilter.NewInRepository:
                break;

            case GUIModFilter.NotInstalled:
                count -= modules.RemoveAll(m => registry.IsInstalled(m.identifier));
                break;

            case GUIModFilter.Incompatible:
                count = registry.Incompatible().Count;
                break;
            }

            return(count);
        }
Пример #6
0
 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);
 }
Пример #7
0
        private void Filter(GUIModFilter filter)
        {
            mainModList.ModFilter = filter;

            if (filter == GUIModFilter.All)
            {
                FilterToolButton.Text = "Filter (All)";
            }
            else if (filter == GUIModFilter.Incompatible)
            {
                FilterToolButton.Text = "Filter (Incompatible)";
            }
            else if (filter == GUIModFilter.Installed)
            {
                FilterToolButton.Text = "Filter (Installed)";
            }
            else if (filter == GUIModFilter.InstalledUpdateAvailable)
            {
                FilterToolButton.Text = "Filter (Upgradeable)";
            }
            else if (filter == GUIModFilter.Cached)
            {
                FilterToolButton.Text = "Filter (Cached)";
            }
            else if (filter == GUIModFilter.NewInRepository)
            {
                FilterToolButton.Text = "Filter (New)";
            }
            else if (filter == GUIModFilter.NotInstalled)
            {
                FilterToolButton.Text = "Filter (Not installed)";
            }
            else
            {
                FilterToolButton.Text = "Filter (Compatible)";
            }
        }
Пример #8
0
        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();
        }
Пример #9
0
        public int CountModsByFilter(GUIModFilter filter)
        {
            switch (filter)
            {
            case GUIModFilter.All:
                return(Modules.Count(m => !m.IsIncompatible));

            case GUIModFilter.Installed:
                return(Modules.Count(m => m.IsInstalled));

            case GUIModFilter.InstalledUpdateAvailable:
                return(Modules.Count(m => m.HasUpdate));

            case GUIModFilter.NewInRepository:
                return(Modules.Count());

            case GUIModFilter.NotInstalled:
                return(Modules.Count(m => !m.IsInstalled));

            case GUIModFilter.Incompatible:
                return(Modules.Count(m => m.IsIncompatible));
            }
            throw new Kraken("Unknown filter type in CountModsByFilter");
        }
Пример #10
0
        private void Filter(GUIModFilter filter)
        {
            mainModList.ModFilter = filter;

            if (filter == GUIModFilter.All)
                FilterToolButton.Text = "Filter (All)";
            else if (filter == GUIModFilter.Incompatible)
                FilterToolButton.Text = "Filter (Incompatible)";
            else if (filter == GUIModFilter.Installed)
                FilterToolButton.Text = "Filter (Installed)";
            else if (filter == GUIModFilter.InstalledUpdateAvailable)
                FilterToolButton.Text = "Filter (Upgradeable)";
            else if (filter == GUIModFilter.Cached)
                FilterToolButton.Text = "Filter (Cached)";
            else if (filter == GUIModFilter.NewInRepository)
                FilterToolButton.Text = "Filter (New)";
            else if (filter == GUIModFilter.NotInstalled)
                FilterToolButton.Text = "Filter (Not installed)";
            else
                FilterToolButton.Text = "Filter (Compatible)";
        }
Пример #11
0
 public int CountModsByFilter(GUIModFilter filter)
 {
     switch (filter)
     {
         case GUIModFilter.Compatible:
             return Modules.Count(m => !m.IsIncompatible);
         case GUIModFilter.Installed:
             return Modules.Count(m => m.IsInstalled);
         case GUIModFilter.InstalledUpdateAvailable:
             return Modules.Count(m => m.HasUpdate);
         case GUIModFilter.NewInRepository:
             return Modules.Count(m => m.IsNew);
         case GUIModFilter.NotInstalled:
             return Modules.Count(m => !m.IsInstalled);
         case GUIModFilter.Incompatible:
             return Modules.Count(m => m.IsIncompatible);
         case GUIModFilter.All:
             return Modules.Count();
     }
     throw new Kraken("Unknown filter type in CountModsByFilter");
 }
Пример #12
0
        public void CountModsByFilter_EmptyModList_ReturnsZero(GUIModFilter filter)
        {
            var item = new ModList(delegate { });

            Assert.That(item.CountModsByFilter(filter), Is.EqualTo(0));
        }