コード例 #1
0
 public void FilterList(DigimonFilter digimonFilter)
 {
     _DigimonFilteredList = _DigimonList.Where(
         x => digimonFilter.AntiFilter ? !FilterList(digimonFilter, x) : FilterList(digimonFilter, x))
                            .ToList();
     DigimonLoader.SetNumbers(_DigimonFilteredList);
 }
コード例 #2
0
        private DigimonFilter GetFilter()
        {
            var filter = new DigimonFilter();

            filter.NameFilter       = NameFilter.Text;
            filter.AppearanceFilter = AppearanceFilter.Text;
            filter.LevelFilter      = LevelFilter.Text;
            filter.TypeFilter       = TypeFilter.Text;
            if (Enum.TryParse(AppearanceTypeBox.SelectedValue.ToString(), out Appearance.AppearanceType appearanceTypeFilter))
            {
                filter.AppearanceTypeFilter = appearanceTypeFilter;
            }
            if (int.TryParse(NumberFilter.Text, out int numberFilter))
            {
                filter.NumberFilter = numberFilter;
            }
            if (int.TryParse(YearFilter.Text, out int yearFilter))
            {
                filter.YearFilter = yearFilter;
            }
            if (int.TryParse(YearEndFilter.Text, out int yearEndFilter))
            {
                filter.YearEndFilter = yearEndFilter;
            }

            return(filter);
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var filter = new DigimonFilter();

            filter.AppearanceTypeFilter = Appearance.AppearanceType.Any;
            FilterSet(this, filter);
            Close();
        }
コード例 #4
0
        private void Filter(object sender, DigimonFilter e)
        {
            _digimonList.FilterList(e);
            SetDigimon(_digimonList.DigimonCollection.FirstOrDefault(x => x.Number == 1));
            _filter = e;
            var form = sender as FilterForm;

            if (form != null)
            {
                form.FilterSet -= Filter;
            }
        }
コード例 #5
0
 private bool FilterList(DigimonFilter digimonFilter, Digimon x)
 {
     return((string.IsNullOrWhiteSpace(digimonFilter.AppearanceFilter) ||
             x.Appearances.Any(
                 y => (y.AppearanceCategory == digimonFilter.AppearanceTypeFilter ||
                       digimonFilter.AppearanceTypeFilter == Appearance.AppearanceType.Any) &&
                 Regex.IsMatch(y.AppearanceNameConvert(), digimonFilter.AppearanceFilter, RegexOptions.IgnoreCase))) &&
            (string.IsNullOrWhiteSpace(digimonFilter.LevelFilter) || Regex.IsMatch(x.DubLevel ?? string.Empty, digimonFilter.LevelFilter, RegexOptions.IgnoreCase)) &&
            (string.IsNullOrWhiteSpace(digimonFilter.NameFilter) || Regex.IsMatch(x.Name, digimonFilter.NameFilter, RegexOptions.IgnoreCase) || Regex.IsMatch(x.DisplayName, digimonFilter.NameFilter, RegexOptions.IgnoreCase)) &&
            (string.IsNullOrWhiteSpace(digimonFilter.TypeFilter) || Regex.IsMatch(x.Type ?? string.Empty, digimonFilter.TypeFilter, RegexOptions.IgnoreCase)) &&
            (digimonFilter.NumberFilter <= 0 || x.Number <= digimonFilter.NumberFilter) &&
            (digimonFilter.YearFilter <= 0 || x.DebutYear >= digimonFilter.YearFilter) &&
            (digimonFilter.YearEndFilter <= 0 || x.DebutYear <= digimonFilter.YearEndFilter));
 }
コード例 #6
0
 public FilterForm(DigimonFilter filter)
 {
     InitializeComponent();
     AppearanceTypeBox.DataSource = Enum.GetValues(typeof(Appearance.AppearanceType));
     if (filter != null)
     {
         NameFilter.Text                = filter.NameFilter;
         AppearanceFilter.Text          = filter.AppearanceFilter;
         LevelFilter.Text               = filter.LevelFilter;
         AppearanceTypeBox.SelectedItem = filter.AppearanceTypeFilter;
         if (filter.NumberFilter > 0)
         {
             NumberFilter.Text = filter.NumberFilter.ToString();
         }
         if (filter.YearFilter > 0)
         {
             YearFilter.Text = filter.YearFilter.ToString();
         }
         if (filter.YearEndFilter > 0)
         {
             YearEndFilter.Text = filter.YearEndFilter.ToString();
         }
     }
 }