public void Test_SourceNcc_CollectionChanged_Remove() { // Create ref list with all test items: List <SampleClass> refList = new List <SampleClass>(); for (int e = 0; e < 100; e++) { refList.Add(new SampleClass(e)); } ObservableCollection <SampleClass> col = new ObservableCollection <SampleClass>(); AdvancedCollectionView acv = new AdvancedCollectionView(col, true); // Add all items to collection: foreach (var item in refList) { col.Add(item); } // Remove all items from collection while DeferRefresh() is active: using (acv.DeferRefresh()) { while (col.Count > 0) { col.RemoveAt(0); } } // Check if unsubscribed from all items: foreach (var item in refList) { Assert.IsTrue(item.GetPropertyChangedEventHandlerSubscriberLength() == 0); } }
public FolderListupPageViewModel( BookmarkManager bookmarkManager, ImageCollectionManager imageCollectionManager, SourceStorageItemsRepository sourceStorageItemsRepository, PathReferenceCountManager PathReferenceCountManager, SecondaryTileManager secondaryTileManager, FolderLastIntractItemManager folderLastIntractItemManager, FolderListingSettings folderListingSettings, OpenPageCommand openPageCommand, OpenFolderItemCommand openFolderItemCommand, OpenImageViewerCommand openImageViewerCommand, OpenFolderListupCommand openFolderListupCommand, OpenWithExplorerCommand openWithExplorerCommand, SecondaryTileAddCommand secondaryTileAddCommand, SecondaryTileRemoveCommand secondaryTileRemoveCommand ) { _bookmarkManager = bookmarkManager; _imageCollectionManager = imageCollectionManager; _sourceStorageItemsRepository = sourceStorageItemsRepository; _PathReferenceCountManager = PathReferenceCountManager; SecondaryTileManager = secondaryTileManager; _folderLastIntractItemManager = folderLastIntractItemManager; _folderListingSettings = folderListingSettings; OpenPageCommand = openPageCommand; OpenFolderItemCommand = openFolderItemCommand; OpenImageViewerCommand = openImageViewerCommand; OpenFolderListupCommand = openFolderListupCommand; OpenWithExplorerCommand = openWithExplorerCommand; SecondaryTileAddCommand = secondaryTileAddCommand; SecondaryTileRemoveCommand = secondaryTileRemoveCommand; FolderItems = new ObservableCollection <StorageItemViewModel>(); ArchiveFileItems = new ObservableCollection <StorageItemViewModel>(); EBookFileItems = new ObservableCollection <StorageItemViewModel>(); ImageFileItems = new ObservableCollection <StorageItemViewModel>(); FileItemsView = new AdvancedCollectionView(ImageFileItems); SelectedFileSortType = new ReactivePropertySlim <FileSortType>(FileSortType.TitleAscending); FileDisplayMode = _folderListingSettings.ToReactivePropertyAsSynchronized(x => x.FileDisplayMode); FolderLastIntractItem = new ReactivePropertySlim <StorageItemViewModel>(); ImageLastIntractItem = new ReactivePropertySlim <int>(); /* * _currentQueryOptions = Observable.CombineLatest( * SelectedFolderViewFirstSort, * (queryType, sort) => (queryType, sort) * ) * .Select(_ => * { * var options = new QueryOptions(); * options.FolderDepth = FolderDepth.Shallow; * options.SetPropertyPrefetch(Windows.Storage.FileProperties.PropertyPrefetchOptions.ImageProperties, Enumerable.Empty<string>()); * return options; * }) * .ToReadOnlyReactivePropertySlim(); */ }
protected async Task ResetList() { using (var releaser = await _ItemsUpdateLock.LockAsync()) { HasItem.Value = true; LoadedItemsCount.Value = 0; if (IncrementalLoadingItems != null) { if (IncrementalLoadingItems.Source is HohoemaIncrementalSourceBase <ITEM_VM> ) { (IncrementalLoadingItems.Source as HohoemaIncrementalSourceBase <ITEM_VM>).Error -= HohoemaIncrementalSource_Error; } IncrementalLoadingItems.BeginLoading -= BeginLoadingItems; IncrementalLoadingItems.DoneLoading -= CompleteLoadingItems; // IncrementalLoadingItems.Dispose(); IncrementalLoadingItems = null; RaisePropertyChanged(nameof(IncrementalLoadingItems)); } try { var source = GenerateIncrementalSource(); if (source == null) { HasItem.Value = false; return; } MaxItemsCount.Value = await source.ResetSource(); IncrementalLoadingItems = new IncrementalLoadingCollection <IIncrementalSource <ITEM_VM>, ITEM_VM>(source); RaisePropertyChanged(nameof(IncrementalLoadingItems)); IncrementalLoadingItems.BeginLoading += BeginLoadingItems; IncrementalLoadingItems.DoneLoading += CompleteLoadingItems; if (IncrementalLoadingItems.Source is HohoemaIncrementalSourceBase <ITEM_VM> ) { (IncrementalLoadingItems.Source as HohoemaIncrementalSourceBase <ITEM_VM>).Error += HohoemaIncrementalSource_Error; } ItemsView = new AdvancedCollectionView(IncrementalLoadingItems); RaisePropertyChanged(nameof(ItemsView)); PostResetList(); } catch { IncrementalLoadingItems = null; NowLoading.Value = false; HasError.Value = true; Debug.WriteLine("failed GenerateIncrementalSource."); } } }
public void Test_AdvancedCollectionView_Updating_Filter_Preserves_Order_With_Duplicate() { var l = new ObservableCollection <string> { "lorem", "ipsum", "dolor", "sit", "ipsum", "amet" }; var a = new AdvancedCollectionView(l) { Filter = (x) => x.ToString().Length < 5 }; Assert.AreEqual(2, a.Count); Assert.AreEqual("sit", a[0]); Assert.AreEqual("amet", a[1]); a.Filter = (x) => x.ToString().Length >= 5; Assert.AreEqual(4, a.Count); Assert.AreEqual("lorem", a[0]); Assert.AreEqual("ipsum", a[1]); Assert.AreEqual("dolor", a[2]); Assert.AreEqual("ipsum", a[3]); }
public IllustrationGridViewModel() { SelectedIllustrations = new ObservableCollection <IllustrationViewModel>(); Illustrations = new ObservableCollection <IllustrationViewModel>(); IllustrationsView = new AdvancedCollectionView(Illustrations); _selectionLabel = IllustrationGridCommandBarResources.CancelSelectionButtonDefaultLabel; }
public void Test_AdvancedCollectionView_Filter_Preserves_Order_When_Inserting_After_Items_In_View() { var l = new ObservableCollection <string> { "lorem", "ipsum", "dolor", "sitter", "amet" }; var a = new AdvancedCollectionView(l) { Filter = (x) => x.ToString().Length < 5 }; Assert.AreEqual(1, a.Count); Assert.AreEqual(a[0], "amet"); a.Insert(0, "how"); Assert.AreEqual(2, a.Count); Assert.AreEqual(a[0], "how"); Assert.AreEqual(a[1], "amet"); }
public void Test_AdvancedCollectionView_Filter_Preserves_Order() { var l = new ObservableCollection <string> { "lorem", "ipsum", "dolor", "sit", "amet" }; var a = new AdvancedCollectionView(l) { Filter = (x) => x.ToString().Length < 5 }; Assert.AreEqual(2, a.Count); Assert.AreEqual("sit", a[0]); Assert.AreEqual("amet", a[1]); a.Insert(4, "how"); Assert.AreEqual(3, a.Count); Assert.AreEqual("sit", a[0]); Assert.AreEqual("how", a[1]); Assert.AreEqual("amet", a[2]); }
public ClientPageViewModel() { _allClients = new ObservableCollection <Client>(Services.Services.ClientService.AllItems); AllClients = new AdvancedCollectionView(_allClients); ClientService = Services.Services.ClientService; }
private void UpdataCollectionViews() { if (MusicLibrary is null || MusicLibrary.Sheetmusic is null) { allSheetsCollectionView = null; favouriteSheetsCollectionView = null; }
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\ #region --Constructors-- public EmojiPickerControlDataTemplate() { LoadRecentEmoji(); EMOJI_SMILEYS_FILTERED = new AdvancedCollectionView { Filter = EmojiFilter }; EMOJI_PEOPLE_FILTERED = new AdvancedCollectionView { Filter = EmojiFilter }; EMOJI_FOOD_FILTERED = new AdvancedCollectionView { Filter = EmojiFilter }; EMOJI_OBJECTS_FILTERED = new AdvancedCollectionView { Filter = EmojiFilter }; EMOJI_SYMBOLS_FILTERED = new AdvancedCollectionView { Filter = EmojiFilter }; EMOJI_TRANSPORTATIONS_FILTERED = new AdvancedCollectionView { Filter = EmojiFilter }; IsRecentChecked = true; }
public static void GetTopRang(this AdvancedCollectionView acv, int Range) { do { var LastIndex = acv.Source.Count - 1; acv.Source.RemoveAt(LastIndex); } while (acv.Source.Count > Range); }
public void Test_AdvancedCollectionView_Combined_Using_Shaping_Changing_Properties() { var personLorem = new Person() { Name = "lorem", Age = 4 }; var l = new ObservableCollection <Person> { personLorem, new Person() { Name = "imsum", Age = 8 }, new Person() { Name = "dolor", Age = 15 }, new Person() { Name = "sit", Age = 16 }, new Person() { Name = "amet", Age = 23 }, new Person() { Name = "consectetur", Age = 42 }, }; var a = new AdvancedCollectionView(l, true) { SortDescriptions = { new SortDescription(nameof(Person.Age), SortDirection.Descending) }, Filter = (x) => ((Person)x).Name.Length > 5 }; a.ObserveFilterProperty(nameof(Person.Name)); Assert.AreEqual(42, ((Person)a.First()).Age); Assert.AreEqual(1, a.Count); personLorem.Name = "lorems"; personLorem.Age = 96; Assert.AreEqual(96, ((Person)a.First()).Age); Assert.AreEqual(2, a.Count); }
public AccountViewModel() { Func <ChatHeader, ChatViewModel> viewModelCreator = model => new ChatViewModel(model); _chats = new ObservableViewModelCollection <ChatViewModel, ChatHeader>(DataSource.Names, viewModelCreator); _chatsAcv = new AdvancedCollectionView(_chats, true); _chatsAcv.SortDescriptions.Add(new SortDescription("Order", SortDirection.Ascending)); _chatsAcv.Filter = x => x is ChatViewModel; }
public Export() { this.InitializeComponent(); Acv = new AdvancedCollectionView(App.Context.Tags.ToList(), false); Acv.SortDescriptions.Add(new SortDescription(nameof(Core.Objects.Entities.Tag.Name), SortDirection.Ascending)); Acv.Filter = itm => !TagTokens.Items.Contains(itm) && (itm as Tag).Name.Contains(TagTokens.Text, StringComparison.InvariantCultureIgnoreCase); TagTokens.ItemsSource = new ObservableCollection <Tag>(); TagTokens.SuggestedItemsSource = Acv; }
public SubsceneDownloadPage() { this.InitializeComponent(); Instance = this; SubtitlesACV = new AdvancedCollectionView(Subtitles, true); cmbLanguage.SelectedItem = Helper.Settings.SubtitleLanguage; cmbQuaity.SelectedItem = Helper.Settings.SubtitleQuality; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); Favorites = await FavoriteHelper.LoadFavorites(); FavoritesACV = new AdvancedCollectionView(Favorites, true); FavoritesACV.SortDescriptions.Add(new SortDescription("Title", SortDirection.Ascending)); ShowEmptyNotify(); }
private async void LoadAozoraBunkoDataAsync() { var list = (await NewUI1703.Data.AozoraBunko.GetListAsync()) .Where(d => d.YAKUWARI_Flag == "著者") .OrderBy(d => d.SAKUHIN_ID); _observableCollection = new ObservableCollection <Data.AozoraBunko>(list); _advancedCollectionView = new AdvancedCollectionView(_observableCollection, true); dataGrid.ItemsSource = _advancedCollectionView; }
public ExpensesPageViewModel() { _allExpenses = new ObservableCollection <Expense>(Services.Services.ExpenseService.AllItems); AllExpenses = new AdvancedCollectionView(_allExpenses); // Default sorts to descending id AllExpenses.SortDescriptions.Add(new SortDescription("Date", SortDirection.Descending)); ExpenseService = Services.Services.ExpenseService; }
private async Task ResetList_Internal() { using (var releaser = await _ItemsUpdateLock.LockAsync()) { HasItem.Value = true; LoadedItemsCount.Value = 0; if (ItemsView?.Source is IncrementalLoadingCollection <IIncrementalSource <ITEM_VM>, ITEM_VM> oldItems) { if (oldItems.Source is HohoemaIncrementalSourceBase <ITEM_VM> hohoemaIncrementalSource) { hohoemaIncrementalSource.Error -= HohoemaIncrementalSource_Error; } oldItems.BeginLoading -= BeginLoadingItems; oldItems.DoneLoading -= CompleteLoadingItems; oldItems.Dispose(); } try { var source = GenerateIncrementalSource(); if (source == null) { HasItem.Value = false; return; } MaxItemsCount.Value = await source.ResetSource(); var items = new IncrementalLoadingCollection <IIncrementalSource <ITEM_VM>, ITEM_VM>(source); items.BeginLoading += BeginLoadingItems; items.DoneLoading += CompleteLoadingItems; if (items.Source is HohoemaIncrementalSourceBase <ITEM_VM> ) { (items.Source as HohoemaIncrementalSourceBase <ITEM_VM>).Error += HohoemaIncrementalSource_Error; } ItemsView = new AdvancedCollectionView(items); RaisePropertyChanged(nameof(ItemsView)); //await ItemsView.LoadMoreItemsAsync(items.Source.OneTimeLoadCount); PostResetList(); } catch { NowLoading.Value = false; HasError.Value = true; Debug.WriteLine("failed GenerateIncrementalSource."); } } }
private async void LoadAozoraBunkoDataAsync() { IEnumerable <Data.AozoraBunko> list = (await NewUI1809.Data.AozoraBunko.GetListAsync()) .Where(d => d.役割フラグ == "著者") .OrderBy(d => d.作品ID); _observableCollection = new ObservableCollection <Data.AozoraBunko>(list); _advancedCollectionView = new AdvancedCollectionView(_observableCollection, true); this.dataGrid.ItemsSource = _advancedCollectionView; }
public SiteEditViewModel(Site site) : base(site) { SensorList = new ObservableCollection <SensorViewModel>(); foreach (Sensor sensor in site.Sensors) { SensorList.Add(new SensorViewModel(sensor)); } SensorInView = new AdvancedCollectionView(SensorList); SensorCategories = SensorType.SensorCategoryCollection; SensorInView.Filter = x => FilterSensorByCategory((SensorViewModel)x); SensorInView.SortDescriptions.Add(new SortDescription("Name", SortDirection.Ascending)); }
public TokenizingTextBoxPage() { InitializeComponent(); _acv = new AdvancedCollectionView(_samples, false); _acvEmail = new AdvancedCollectionView(_emailSamples, false); _acv.SortDescriptions.Add(new SortDescription(nameof(SampleDataType.Text), SortDirection.Ascending)); _acvEmail.SortDescriptions.Add(new SortDescription(nameof(SampleEmailDataType.DisplayName), SortDirection.Ascending)); Loaded += (sender, e) => { this.OnXamlRendered(this); }; }
public InvoicePageViewModel() { _allInvoices = new ObservableCollection <Invoice>(Services.Services.InvoiceService.AllItems); AllInvoices = new AdvancedCollectionView(_allInvoices); // Default sorts to descending id AllInvoices.SortDescriptions.Add(new SortDescription("InvoiceDate", SortDirection.Descending)); InvoiceService = Services.Services.InvoiceService; GenerateStats(); }
public VideoCommentSidePaneContentViewModel( VideoCommentPlayer commentPlayer, CommentFilteringFacade commentFiltering, Services.DialogService dialogService ) { CommentPlayer = commentPlayer; CommentFiltering = commentFiltering; _dialogService = dialogService; Comments = new AdvancedCollectionView(CommentPlayer.Comments, true); HandleCommentFilterConditionChanged(); void HandleCommentFilterConditionChanged() { #pragma warning disable IDISP004 // Don't ignore created IDisposable. new[] { Observable.FromEventPattern <CommentFilteringFacade.CommentOwnerIdFilteredEventArgs>( h => CommentFiltering.FilteringCommentOwnerIdAdded += h, h => CommentFiltering.FilteringCommentOwnerIdAdded -= h ).ToUnit(), Observable.FromEventPattern <CommentFilteringFacade.CommentOwnerIdFilteredEventArgs>( h => CommentFiltering.FilteringCommentOwnerIdRemoved += h, h => CommentFiltering.FilteringCommentOwnerIdRemoved -= h ).ToUnit(), Observable.FromEventPattern <CommentFilteringFacade.FilteringCommentTextKeywordEventArgs>( h => CommentFiltering.FilterKeywordAdded += h, h => CommentFiltering.FilterKeywordAdded -= h ).ToUnit(), Observable.FromEventPattern <CommentFilteringFacade.FilteringCommentTextKeywordEventArgs>( h => CommentFiltering.FilterKeywordUpdated += h, h => CommentFiltering.FilterKeywordUpdated -= h ).ToUnit(), Observable.FromEventPattern <CommentFilteringFacade.FilteringCommentTextKeywordEventArgs>( h => CommentFiltering.FilterKeywordRemoved += h, h => CommentFiltering.FilterKeywordRemoved -= h ).ToUnit(), } .Merge() .Subscribe(_ => Comments.RefreshFilter()) #pragma warning restore IDISP004 // Don't ignore created IDisposable. .AddTo(_disposables); using (Comments.DeferRefresh()) { Comments.SortDescriptions.Add(new SortDescription("VideoPosition", SortDirection.Ascending)); Comments.Filter = (c) => !isCommentFiltered(c as VideoComment); } } }
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\ #region --Constructors-- public ChatsPageContext() { this.CHATS_ACV = new AdvancedCollectionView(CHATS, true) { Filter = AcvFilter }; this.CHATS_ACV.ObserveFilterProperty(nameof(ChatDataTemplate.Chat)); this.CHATS_ACV.SortDescriptions.Add(new Microsoft.Toolkit.Uwp.UI.SortDescription(nameof(ChatDataTemplate.Chat), Microsoft.Toolkit.Uwp.UI.SortDirection.Descending)); this.CHAT_FILTER = new ChatFilterDataTemplate(this.CHATS_ACV); LoadChats(); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { vm.Categories = await CryptoCompare.GetNewsCategories(); _acv = new AdvancedCollectionView(vm.Categories, false); _acv.SortDescriptions.Add(new SortDescription(nameof(NewsCategories.categoryName), SortDirection.Ascending)); _ttb = CategoriesTokenBox; _acv.Filter = item => !_ttb.Items.Contains(item) && (item as NewsCategories).categoryName.Contains(_ttb.Text, StringComparison.CurrentCultureIgnoreCase); _ttb.SuggestedItemsSource = _acv; await UpdatePage(); }
public News() { this.InitializeComponent(); _categories = GetNewsCategories().Result; _filters = new List <string>(); GetNews(); _acv = new AdvancedCollectionView(_categories, false); _acv.SortDescriptions.Add(new SortDescription(nameof(NewsCategories.categoryName), SortDirection.Ascending)); Loaded += (sender, e) => { this.OnXamlRendered(this); }; }
public void SortMovies() { var fdt = new DateTime(int.Parse(From.Text), DateTime.Now.Month, DateTime.Now.Day); var tdt = new DateTime(int.Parse(To.Text), DateTime.Now.Month, DateTime.Now.Day); var sort = ViewModel.Movies.Where(x => x.Title.ToLowerInvariant().Contains(Search.Text.ToLowerInvariant())); if (From.Text.Length == 4 || To.Text.Length == 4) { sort = sort.Where(x => x.ReleaseDate != null && (new DateTime(x.ReleaseDate.Value.Year, DateTime.Now.Month, DateTime.Now.Day).Year > fdt.Year && new DateTime(x.ReleaseDate.Value.Year, DateTime.Now.Month, DateTime.Now.Day).Year < tdt.Year)); } var acv = new AdvancedCollectionView(new ObservableCollection <Movie>(sort)); var content = ((ComboBoxItem)Sort.SelectedItem)?.Content; if (content != null && content.ToString().Contains("Ascending")) { acv.SortDescriptions.Add(new SortDescription("Title", SortDirection.Ascending)); } else if (content != null && content.ToString().Contains("Descending")) { acv.SortDescriptions.Add(new SortDescription("Title", SortDirection.Descending)); } else { acv.SortDescriptions.Add(new SortDescription("Title", SortDirection.Ascending)); } var abx = new List <Movie>(acv.ToList().OfType <Movie>()); if (!Genres.Any()) { AdaptiveGridViewMovies.ItemsSource = abx; return; } foreach (var i in abx.ToList()) { if (!i.Genres.Any(x => Genres.Any(y => y == x.Name))) { abx.Remove(i); } } AdaptiveGridViewMovies.ItemsSource = abx; }
protected internal override void OnCreate(object parameter) { base.OnCreate(parameter); if (parameter is InstanceModel instance) { ViewModel = new ChatViewModel(instance) { RoomMessage = OnRoomMessage }; WithHostConverter.Host = ViewModel.Host; AdvancedCollectionView = new AdvancedCollectionView(ViewModel.Rooms, true); AdvancedCollectionView.SortDescriptions.Add(new SortDescription("UpdateAt", SortDirection.Descending)); } }
/// <summary> /// Private Constructor /// </summary> private DataService() { SecretService = App.Current.Container.Resolve <ISecretService>(); FileService = App.Current.Container.Resolve <IFileService>(); Logger = App.Current.Container.Resolve <ILoggerFacade>(); DialogService = App.Current.Container.Resolve <IDialogService>(); NewtonsoftJSONService = App.Current.Container.Resolve <INewtonsoftJSONService>(); NetworkTimeService = App.Current.Container.Resolve <INetworkTimeService>(); ACVCollection = new AdvancedCollectionView(Collection, true); ACVCollection.SortDescriptions.Add(new SortDescription("Label", SortDirection.Ascending)); Collection.CollectionChanged += Accounts_CollectionChanged; CheckDatafile(); CheckTime(); }