Exemplo n.º 1
0
        private void UpdateSearchResults(IList <SearchCriteria> searches)
        {
            if (searches == null || searches.Count == 0)
            {
                ListResults.Clear();
            }
            else
            {
                // Find dinos that match the given searches
                var found       = new List <Dino>();
                var sourceDinos = ShowTames ? arkReader.TamedDinos : arkReader.WildDinos;
                var total       = 0;
                foreach (var search in searches)
                {
                    if (String.IsNullOrWhiteSpace(search.Species))
                    {
                        foreach (var speciesDinos in sourceDinos.Values)
                        {
                            found.AddRange(speciesDinos);
                            total += speciesDinos.Count;
                        }
                    }
                    else
                    {
                        if (sourceDinos.ContainsKey(search.Species))
                        {
                            var dinoList = sourceDinos[search.Species];
                            found.AddRange(dinoList.Where(d => search.Matches(d)));
                            total += dinoList.Count;
                        }
                    }
                }

                ListResults.Clear();
                foreach (var result in found)
                {
                    ListResults.Add(result);
                }

                ShowCounts          = true;
                ResultTotalCount    = ShowTames ? sourceDinos.Sum(species => species.Value.Count()) : total;
                ResultMatchingCount = ListResults.Count;
            }

            ((CollectionViewSource)Resources["OrderedResults"]).View.Refresh();

            TriggerNameSearch(true);
        }
Exemplo n.º 2
0
        private void Dev_DummyData_Click(object sender, MouseButtonEventArgs e)
        {
            ListResults.Clear();

            var dummyData = new Dino[] {
                new Dino {
                    Location = new Position {
                        Lat = 10, Lon = 10
                    }, Type = "Testificate", Name = "10,10"
                },
                new Dino {
                    Location = new Position {
                        Lat = 90, Lon = 10
                    }, Type = "Testificate", Name = "90,10"
                },
                new Dino {
                    Location = new Position {
                        Lat = 10, Lon = 90
                    }, Type = "Testificate", Name = "10,90"
                },
                new Dino {
                    Location = new Position {
                        Lat = 90, Lon = 90
                    }, Type = "Testificate", Name = "90,90"
                },
                new Dino {
                    Location = new Position {
                        Lat = 50, Lon = 50
                    }, Type = "Testificate", Name = "50,50"
                },
            };

            var rnd = new Random();

            foreach (var result in dummyData)
            {
                result.Id = (ulong)rnd.Next();
                DinoViewModel vm = new DinoViewModel(result)
                {
                    Color = Colors.Green
                };
                ListResults.Add(vm);
            }

            var cv = (CollectionView)CollectionViewSource.GetDefaultView(ListResults);

            cv.Refresh();
        }
Exemplo n.º 3
0
        private void UpdateSearchResults(IList <SearchCriteria> searches)
        {
            if (searches == null || searches.Count == 0)
            {
                ListResults.Clear();
            }
            else
            {
                // Find dinos that match the given searches
                var found  = new List <Dino>();
                var reader = ShowTames ? arkReaderTamed : arkReaderWild;
                foreach (var search in searches)
                {
                    if (String.IsNullOrWhiteSpace(search.Species))
                    {
                        foreach (var speciesDinos in reader.FoundDinos.Values)
                        {
                            found.AddRange(speciesDinos);
                        }
                    }
                    else
                    {
                        if (reader.FoundDinos.ContainsKey(search.Species))
                        {
                            var dinoList = reader.FoundDinos[search.Species];
                            found.AddRange(dinoList.Where(d => search.Matches(d)));
                        }
                    }
                }

                ListResults.Clear();
                foreach (var result in found)
                {
                    ListResults.Add(result);
                }
            }

            ((CollectionViewSource)Resources["OrderedResults"]).View.Refresh();

            TriggerNameSearch(true);
        }