public async Task FilterMoviesAsync(string search)
        {
            cts?.Cancel();

            if (!string.IsNullOrEmpty(search))
            {
                var innerToken = cts = new CancellationTokenSource();

                var movies = await _getMoviesByTitle.Invoke(search);

                if (!innerToken.IsCancellationRequested)
                {
                    if (search.Equals("Star Wars", StringComparison.CurrentCultureIgnoreCase))
                    {
                        _view.ShowMessage();
                    }

                    FilterApplied?.Invoke(movies);
                }
            }
            else
            {
                FilterApplied?.Invoke(null);
            }
        }
示例#2
0
        public async void Apply()
        {
            var filterArgs = string.Empty;

            // Check that they user has entred something in tags list
            if (!string.IsNullOrEmpty(SearchTags.Text))
            {
                try
                {
                    var tags = SearchTags.Text.Split(',');
                    filterArgs += "&tags=" + string.Join(",", tags);
                }
                catch (Exception)
                {
                    await new MessageDialog("Error: You must seperate each tag with a comma").ShowAsync();
                    return;
                }
            }

            // Get the base content
            var selectedLicense = ((ComboBoxItem)SearchLicense.SelectedItem)?.Content?.ToString();

            if (!string.IsNullOrEmpty(selectedLicense) && selectedLicense.ToLower() != "any")
            {
                selectedLicense = selectedLicense.ToLower().Replace(' ', '-');
                filterArgs     += "&license=" + WebUtility.UrlEncode(selectedLicense);
            }


            var selectedType = ((ComboBoxItem)SearchType?.SelectedItem)?.Content?.ToString();

            if (!string.IsNullOrEmpty(selectedType) && selectedType.ToLower() != "any")
            {
                selectedType = selectedType.ToLower();
                filterArgs  += "&types=" + WebUtility.UrlEncode(selectedType);
            }

            if (!string.IsNullOrEmpty(SearchBpm.Text))
            {
                if (int.Parse(SearchBpm.Text) >= 10)
                {
                    filterArgs += "bpm[from]=" + (int.Parse(SearchBpm.Text) - 10) + "&bpm[to]=" +
                                  (int.Parse(SearchBpm.Text) + 10);
                }
                else
                {
                    filterArgs += "bpm[from]=0&bpm[to]=" + (int.Parse(SearchBpm.Text) + 10);
                }
            }

            // Create the arguments
            var args = new FilterAppliedArgs {
                FilterArgs = filterArgs
            };

            // Call the event handler
            FilterApplied?.Invoke(this, args);
            // Hide the popup
            Hide();
        }
示例#3
0
 private void Hyperlink_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (sender != null)
     {
         var filter = (sender as System.Windows.Documents.Hyperlink).Tag.ToString();
         FilterApplied.Invoke(filter);
     }
 }
        private void ApplyFilters()
        {
            if (BeatmapDetailsLoader.instance.IsLoading)
            {
                Logger.log.Warn("Tried to apply filters while loading beatmap details (this should never happen?)");
                return;
            }

            if (!Tweaks.SongBrowserTweaks.Initialized)
            {
                Logger.log.Debug($"Applying filter, starting with {_beatmapDetails.Count} songs");
            }

            List <BeatmapDetails> filteredLevels = null;

            bool hasApplied;

            if (!Tweaks.SongBrowserTweaks.Initialized)
            {
                filteredLevels = new List <BeatmapDetails>(_beatmapDetails.Values);
                hasApplied     = FilterList.ApplyFilter(ref filteredLevels);
                Logger.log.Debug($"Filter completed, {filteredLevels.Count} songs left");
            }
            else
            {
                foreach (var filter in FilterList.ActiveFilters)
                {
                    filter.ApplyStagingValues();
                }
                hasApplied = FilterList.AnyApplied;
            }

            RefreshUI();

            if (hasApplied)
            {
                if (Tweaks.SongBrowserTweaks.ModLoaded && Tweaks.SongBrowserTweaks.Initialized)
                {
                    _filterMainViewController.ShowInfoText("Filter applied");
                }
                else
                {
                    _filterMainViewController.ShowInfoText($"{filteredLevels.Count} out of {_beatmapDetails.Count} songs found");

                    // SongBrowser will create its own BeatmapLevelPack when it gets our filtered levels via:
                    // ProcessSongList() -> CustomFilterHandler() -> ApplyFiltersForSongBrowser() -> ApplyFilters()
                    // filters are applied once this flow coordinator is dismissed
                    FilterApplied?.Invoke(_beatmapDetails.Where(x => filteredLevels.Contains(x.Value)).Select(x => x.Key).ToArray());
                }
            }
            else
            {
                // default values were applied (no filtering or undo filtering)
                FiltersUnapplied?.Invoke();
            }
        }
        public async Task FilterMoviesAsync(string search)
        {
            cts?.Cancel();

            if (!string.IsNullOrEmpty(search))
            {
                var innerToken   = cts = new CancellationTokenSource();
                var movieService = new MovieService();
                var movies       = await movieService.GetMoviesForSearchAsync(search);

                if (!innerToken.IsCancellationRequested)
                {
                    FilterApplied?.Invoke(movies);
                }
            }
            else
            {
                FilterApplied?.Invoke(null);
            }
        }
示例#6
0
 private void Dashboard_FilterApplied(string filter)
 {
     // event bubble filter applied notification
     FilterApplied?.Invoke(filter);
 }
示例#7
0
 public void FilterQuery(IDictionary <string, string> myQuery)
 {
     myFilterIssues = RequestIssuesFilter.Run(myQuery, myLogin, myPassword);
     FilterApplied.Invoke();
 }