예제 #1
0
        private void FilterList(string part = null)
        {
            if (_entryList == null)
            {
                return;
            }

            bool noVariantFiltering = VariantSelector.DisabledVariants == null || !VariantSelector.DisabledVariants.Any();

            lvSpeciesList.BeginUpdate();
            lvSpeciesList.Items.Clear();
            var  newItems     = new List <ListViewItem>();
            bool inputIsEmpty = string.IsNullOrWhiteSpace(part);

            foreach (var s in _entryList)
            {
                if ((Properties.Settings.Default.DisplayNonDomesticableSpecies || s.Species.IsDomesticable) &&
                    (inputIsEmpty ||
                     s.SearchName.ToLower().Contains(part.ToLower())
                    ) &&
                    (noVariantFiltering ||
                     (string.IsNullOrEmpty(s.Species.VariantInfo) ? !VariantSelector.DisabledVariants.Contains(string.Empty)
                        : !VariantSelector.DisabledVariants.Intersect(s.Species.variants).Any()))
                    )
                {
                    newItems.Add(new ListViewItem(new[] { s.DisplayName, s.Species.VariantInfo, s.Species.IsDomesticable ? "✓" : string.Empty, s.ModName })
                    {
                        Tag       = s.Species,
                        BackColor = !s.Species.IsDomesticable ? Color.FromArgb(255, 245, 230)
                        : !string.IsNullOrEmpty(s.ModName) ? Color.FromArgb(230, 245, 255)
                        : SystemColors.Window,
                        ToolTipText = s.Species.blueprintPath,
                    });
                }
            }
            lvSpeciesList.Items.AddRange(newItems.ToArray());
            lvSpeciesList.EndUpdate();

            if (!Visible && !inputIsEmpty)
            {
                ToggleVisibility?.Invoke(true);
            }
        }
예제 #2
0
 private void OnToggleVisibility(ToggleVisibilityEventArgs e)
 {
     Execute.OnUIThread(() => {
         ToggleVisibility?.Invoke(this, e);
     });
 }