Esempio n. 1
0
    public void SetChampList(IEnumerable<MyChampDto> champions) {
      var groups = new Dictionary<string, List<object>>();

      champs = champions.ToList();
      var save = new List<int>();
      var filter = SearchBox.Text;
      if (filter.Equals("Search")) filter = "";
      foreach (var item in champions.OrderBy(c => c.name).Where(c => Regex.IsMatch(c.name, filter, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace))) {
        save.Add(item.key);
        if (!groups.ContainsKey(item.tags[0]))
          groups[item.tags[0]] = new List<object>();
        groups[item.tags[0]].Add(new { Image = DataDragon.GetChampIconImage(item).Load(), Name = item.name, Data = item });
      }
      if (last != null && save.SequenceEqual(last)) return;
      last = save;

      GroupsList.Children.Clear();
      foreach (var group in groups) {
        var grid = new Grid();
        grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
        grid.RowDefinitions.Add(new RowDefinition());

        var label = new Label { Content = group.Key, FontSize = 18 };
        grid.Children.Add(label);

        var items = new ItemsControl { ItemsSource = group.Value };
        grid.Children.Add(items);

        Grid.SetRow(items, 1);
        GroupsList.Children.Add(grid);
      }

      ChampSelect.Visibility = Visibility.Visible;
      SkinSelect.Visibility = Visibility.Collapsed;
    }
        public void Reinitialize(List<FilterOption> filters, List<ColumnOption> columns, ColumnOptionsMode columnOptionsMode, List<OrderOption> orders, Pagination pagination)
        {
            try
            {
                avoidPaginationChange = true;

                ColumnOptions.Clear();
                ColumnOptions.AddRange(columns);
                ColumnOption.SetColumnTokens(ColumnOptions, Description);
                ColumnOptionsMode = columnOptionsMode;
                GenerateListViewColumns();

                if (!filters.SequenceEqual(FilterOptions))
                {
                    if (SimpleFilterBuilder != null)
                        SimpleFilterBuilder = null;

                    FilterOptions.Clear();
                    FilterOption.SetFilterTokens(filters, Description);
                    FilterOptions.AddRange(filters);
                }

                OrderOptions.Clear();
                OrderOptions.AddRange(orders);
                OrderOption.SetOrderTokens(OrderOptions, Description);
                SortGridViewColumnHeader.SetColumnAdorners(gvResults, OrderOptions);

                UpdateMultiplyMessage(true);

                Pagination = pagination;
            }
            finally
            {
                avoidPaginationChange = false;
            }
        }