public async void Setup(FilterPreset preset, bool isSubViewModel) { this.settingUp = true; this.Title = isSubViewModel ? preset.Title : preset.ExtendedTitle ?? preset.Title; this.FilterPreset = preset; this.Filter = preset.Filter; await this.SetIsSubscribed(preset); var filter = preset.Filter.Clone(); filter.Paging = new Paging {Limit = 5}; this.Articles = Mvx.IocConstruct<FilteredArticlesViewModel>(); var topFilter = filter.Clone(); topFilter.IsTopStory = true; topFilter.Paging = new Paging {Limit = 5}; this.TopArticles = Mvx.IocConstruct<FilteredArticlesViewModel>(); this.IsLoading = true; try { await this.TopArticles.Setup(topFilter); this.IsLoading = false; await Task.Delay(200); await this.Articles.Setup(filter); } finally { this.IsLoading = false; this.settingUp = false; } }
/// <summary> /// Loads the given FilterPreset on this BaseFilterView /// </summary> /// <param name="preset">A filter preset that contains data about filters to load on this BaseFilterView</param> public void LoadFilterPreset(FilterPreset preset) { RemoveAllFilterControls(false); cb_filterPresets.Text = preset.Name; LoadFilters(preset.MakeFilterControls()); }
private async void DeleteFilterAction(FilterPreset obj) { if (!this.Filters.Contains(obj)) { return; } this.Filters.Remove(obj); await this.setting.SetValueAsync(this.Filters.ToList()); MessageBus.Current.SendMessage(new FeedSubscribedChangedMessage(false, obj)); }
public void TestEqualityUnordered() { TransparencyFilter filter1 = new TransparencyFilter { Transparency = 1.0f }; TransparencyFilter filter2 = new TransparencyFilter { Transparency = 0.0f }; FilterPreset preset1 = new FilterPreset("Preset 1", new IFilter[] { filter1, filter2 }); FilterPreset preset2 = new FilterPreset("Preset 2", new IFilter[] { filter2, filter1 }); Assert.IsTrue(preset1.Equals(preset2)); }
/// <summary> /// Loads the filter preset currently selected on the presets combo box /// </summary> private void LoadSelectedFilterPreset() { if (cb_filterPresets.Text.Trim() == "") { return; } FilterPreset preset = FilterStore.Instance.GetFilterPresetByName(cb_filterPresets.Text); if (preset == null) { return; } LoadFilterPreset(preset); }
private async void CreateFilterAction(object o) { var preset = new FilterPreset(); preset.Filter = new Filter(); if (!string.IsNullOrWhiteSpace(this.FilterName)) { preset.Title = this.FilterName; } else { var titleParts = this.selectViewModels.OfType<SelectViewModel>() .Select(svm => (svm.SelectedItem as IdEntity)?.Name) .Where(p => p != null); preset.Title = string.Join(" - ", titleParts); } if (this.CategorySelect.SelectedItem != null) { preset.Filter.Category = this.CategorySelect.SelectedItem; } if (this.DistrictSelect.SelectedItem != null) { preset.Filter.District = this.DistrictSelect.SelectedItem; } this.IsLoading = true; try { await this.userSettings.UserFiltersSetting.AddItemAndSave(preset); this.Close(this); await this.notificator.Notify(ToastNotificationType.Success, "Filter erstellt", $"Neuer Filter {preset.Title} erfolgreich erstellt.", TimeSpan.FromSeconds(3)); } finally { this.IsLoading = false; } }
/// <summary> /// Adds a new filter preset to this filters controller /// </summary> /// <param name="preset">The filter preset to save</param> public void AddFilterPreset(FilterPreset preset) { var matching = MatchingPreset(preset); if (matching != null) { int index = _presets.IndexOf(matching); _presets.Insert(index, preset); _presets.Remove(matching); return; } while (_presets.Count > MaxPresets) { _presets.RemoveAt(_presets.Count - 1); } _presets.Insert(0, preset); FiltersChanged?.Invoke(this, new EventArgs()); }
protected override void InitFromBundle(IMvxBundle parameters) { base.InitFromBundle(parameters); this.FilterPreset = JsonConvert.DeserializeObject<FilterPreset>(parameters.Data["preset"]); this.Setup(this.FilterPreset, false); }
private async Task SetIsSubscribed(FilterPreset preset) { var userFilters = await this.userFilterSetting.GetValueAsync(); this.IsSubscribed = userFilters.Any(f => f.Filter.Equals(preset.Filter)); }
public FeedSubscribedChangedMessage(bool isSubscribed, FilterPreset preset) { this.IsSubscribed = isSubscribed; this.Preset = preset; this.Preset.Title = preset.ExtendedTitle ?? preset.Title; }
/// <summary> /// Initializes a new instance of the BaseFilterView class /// </summary> /// <param name="preset">A FilterPreset that contains data about filters to load on this BaseFilterView</param> /// <param name="animation">The animation to apply the filter to</param> public AnimationFilterView(FilterPreset preset, Animation animation) : this(animation) { fs_filters.LoadFilterPreset(preset); }
private async Task<IReadOnlyCollection<Tuple<bool, FilterPreset>>> GetUserFeedFilters() { var filters = await this.userSettings.UserFiltersSetting.GetValueAsync(); var selectedDistrict = await this.userSettings.DistrictSetting.GetValueAsync(); var districtFilter = new FilterPreset(selectedDistrict.Name, new Filter {District = selectedDistrict}); return new[] {new Tuple<bool, FilterPreset>(false, districtFilter)}.Concat(filters.Select(f => new Tuple<bool, FilterPreset>(true, f))).ToList(); }
private FeedViewModel CreateFeedViewModel(int i, FilterPreset preset, bool canUserChangeSubscription) { var feedViewModel = Mvx.IocConstruct<FeedViewModel>(); Task.Delay(100*i) .ContinueWith(t => { feedViewModel.Setup(preset, true); feedViewModel.CanChangeSubscription = canUserChangeSubscription; }, TaskScheduler.FromCurrentSynchronizationContext()); return feedViewModel; }
/// <summary> /// Returns the first filter preset that matches the given preset. /// Returns null, if none are found /// </summary> /// <param name="preset">The filter preset to search using the .Equals(FilterPreset) method</param> /// <returns>A FilterPreset matching the given preset by using the .Equals(FilterPreset) method, or null, if none are found</returns> public FilterPreset MatchingPreset(FilterPreset preset) { return(_presets.FirstOrDefault(preset.Equals)); }
/// <summary> /// Initializes a new instance of the BaseFilterView class /// </summary> /// <param name="preset">A FilterPreset that contains data about filters to load on this BaseFilterView</param> /// <param name="bitmap">A bitmap to apply the filter to</param> public ImageFilterView(FilterPreset preset, Bitmap bitmap) : this(bitmap) { fs_filters.LoadFilterPreset(preset); }