Exemplo n.º 1
0
 private bool HiddenByTagsOrLabels(GUIMod m, string instanceName)
 {
     // "Hide" labels apply to all non-custom filters
     if (ModuleLabels?.LabelsFor(instanceName)
         .Where(l => !LabelInSearches(l) && l.Hide)
         .Any(l => l.ModuleIdentifiers.Contains(m.Identifier))
         ?? false)
     {
         return(true);
     }
     if (ModuleTags?.Tags?.Values
         .Where(t => !TagInSearches(t) && t.Visible == false)
         .Any(t => t.ModuleIdentifiers.Contains(m.Identifier))
         ?? false)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
        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);
        }