private async void GetFileTypes() { try { List <FileTypeDto> sources = null; using (var context = new SqlDbContext()) { sources = await context.FileTypes.ToListAsync(); } _fileTypes = new ObservableCollection <FileTypeDto>(sources); var itemsView = new CollectionViewSource() { Source = _fileTypes }.View; itemsView.SortDescriptions.Add(new SortDescription() { Direction = ListSortDirection.Ascending, PropertyName = "Name" }); FileTypes = itemsView as ICollectionViewLiveShaping; if (FileTypes.CanChangeLiveSorting) { FileTypes.LiveSortingProperties.Add("Name"); FileTypes.IsLiveSorting = true; } RadGridViewFileTypes.ItemsSource = (ICollectionView)FileTypes; } catch (Exception ex) { } }
/// <inheritdoc/> public LiveShapingSortedValueList(ICollectionViewLiveShaping liveShapingView) { LiveShapingView = liveShapingView; if (LiveShapingView.CanChangeLiveFiltering || LiveShapingView.CanChangeLiveSorting || LiveShapingView.CanChangeLiveGrouping) { throw new NotSupportedException( $"{nameof(LiveShapingSortedValueList<T>)} does not support changes in live shaping properties."); } if (liveShapingView.IsLiveGrouping == true) { throw new NotSupportedException("(Live) grouping is not supported."); } if (LiveShapingView.IsLiveSorting == false && LiveShapingView.IsLiveFiltering == false) { throw new NotSupportedException($"Only use {nameof(LiveShapingSortedValueList<T>)} if you are actually live shaping."); } LiveShapingView.LiveSortingProperties.ForEach(propertyName => AddLiveShapingProperty(propertyName, LiveShapingCategory.Sorting)); LiveShapingView.LiveSortingProperties.CollectionChanged += CreateCollectionChangedEventHandlerFor(LiveShapingCategory.Sorting); LiveShapingView.LiveFilteringProperties.ForEach(propertyName => AddLiveShapingProperty(propertyName, LiveShapingCategory.Filtering)); LiveShapingView.LiveFilteringProperties.CollectionChanged += CreateCollectionChangedEventHandlerFor(LiveShapingCategory.Filtering); }
private bool ApplySortBy(String fieldName1, ListSortDirection sortDirection1, String fieldName2, ListSortDirection sortDirection2) { if (_schema == null) { return(false); } ICollectionView cv = CollectionViewSource.GetDefaultView(_items); ICollectionViewLiveShaping cvls = cv as ICollectionViewLiveShaping; if (!cv.CanSort) { return(false); } cvls.IsLiveSorting = true; cv.SortDescriptions.Clear(); //cvls.LiveSortingProperties.Clear(); if (!String.IsNullOrEmpty(fieldName1)) { cv.SortDescriptions.Add(new SortDescription(fieldName1, sortDirection1)); //cvls.LiveSortingProperties.Add(fieldName1); } if (!String.IsNullOrEmpty(fieldName2)) { cv.SortDescriptions.Add(new SortDescription(fieldName2, sortDirection2)); //cvls.LiveSortingProperties.Add(fieldName2); } return(true); }
private void ApplyWpfFilter(Boolean enableFilter) { ICollectionView cv = CollectionViewSource.GetDefaultView(_items); ICollectionViewLiveShaping cvls = cv as ICollectionViewLiveShaping; if (!enableFilter) { cv.Filter = null; return; } if (cv != null && cv.CanFilter) { if (cvls != null && cvls.CanChangeLiveFiltering) { if (_schema != null) { PropertyInfo[] propInfos = _schema.GetProperties(); cvls.LiveFilteringProperties.Clear(); foreach (var propInfo in propInfos) { cvls.LiveFilteringProperties.Add(propInfo.Name); } } cvls.IsLiveFiltering = true; cv.Filter = IsItemIncludedForFilter; } } }
public LiveTableViewModel(IObservable <T> t, string sortonproperty, ListSortDirection lsd = ListSortDirection.Descending) { View = (ICollectionViewLiveShaping)CollectionViewSource.GetDefaultView(_items); View.IsLiveSorting = true; ((ICollectionView)View).SortDescriptions.Add(new SortDescription(sortonproperty, lsd)); t.ObserveOnDispatcher().Subscribe(_ => _items.Add(_)); }
public MergedInventoryViewModel() { MergedInventory = new SynchronizedObservableCollection <MergedInventoryItem>(); MergedInventoryView = Utils.InitLiveView(o => o != null, MergedInventory, new string[] { }, new[] { new SortDescription("Item.Item.Id", ListSortDirection.Ascending), new SortDescription("Item.Item.RareGrade", ListSortDirection.Ascending), }); ((ICollectionView)MergedInventoryView).CollectionChanged += Reeeee; }
/// <summary> /// Sort a collection /// </summary> /// <param name="ItemsSource">An object reference to the binding source to be sorted</param> /// <param name="propertyName">The name of the property to sort the list by.</param> public static void SortingAscending(IEnumerable ItemsSource, string propertyName) { //cboPlaneIndicator Live shaping (sort) ICollectionView pView = CollectionViewSource.GetDefaultView(ItemsSource); pView.SortDescriptions.Add(new SortDescription(propertyName, ListSortDirection.Ascending)); ICollectionViewLiveShaping viewLiveShaping = (ICollectionViewLiveShaping)CollectionViewSource.GetDefaultView(ItemsSource); viewLiveShaping.IsLiveSorting = true; }
public MergedInventoryViewModel() { MergedInventory = new TSObservableCollection <MergedInventoryItem>(); MergedInventoryView = CollectionViewFactory.CreateLiveCollectionView(MergedInventory, sortFilters: new[] { new SortDescription($"{nameof(MergedInventoryItem.Item)}.{nameof(InventoryItem.Item)}.{nameof(Item.Id)}", ListSortDirection.Ascending), new SortDescription($"{nameof(MergedInventoryItem.Item)}.{nameof(InventoryItem.Item)}.{nameof(Item.RareGrade)}", ListSortDirection.Ascending), }); }
private bool ApplyGroupBy(String groupByName) { if (_schema == null) { return(false); } ICollectionView cv = CollectionViewSource.GetDefaultView(_items); ICollectionViewLiveShaping cvls = cv as ICollectionViewLiveShaping; if (!cv.CanGroup) { return(false); } foreach (var viewModel in GroupByColumnViewModels) { viewModel.IsChecked = (viewModel.PropertyName == groupByName); } cvls.IsLiveGrouping = true; cvls.IsLiveFiltering = true; cvls.IsLiveSorting = true; // clear the group cv.GroupDescriptions.Clear(); cvls.LiveGroupingProperties.Clear(); // if groupByName not in schema - set the group to "None" if (!_schema.DoesAliasExist(groupByName)) { return(false); } // set the group if (groupByName != "None") { cv.GroupDescriptions.Add(new PropertyGroupDescription(groupByName)); cvls.LiveGroupingProperties.Add(groupByName); } // refresh the live properties cvls.LiveFilteringProperties.Clear(); cvls.LiveSortingProperties.Clear(); PropertyInfo[] propInfos = _schema.GetProperties(); foreach (var propInfo in propInfos) { cvls.LiveFilteringProperties.Add(propInfo.Name); cvls.LiveSortingProperties.Add(propInfo.Name); //cvls.LiveFilteringProperties.Add(propInfo.Name); } return(true); }
private void EnableLiveShaping() { ICollectionView cvs = CollectionViewSource.GetDefaultView(this.Entries); cvs.SortDescriptions.Add(new SortDescription("LastName", ListSortDirection.Ascending)); cvs.SortDescriptions.Add(new SortDescription("FirstName", ListSortDirection.Ascending)); ICollectionViewLiveShaping cvsls = (ICollectionViewLiveShaping)cvs; cvsls.IsLiveSorting = true; }
public SystemMessagesConfigWindow() { InitializeComponent(); DataContext = this; HiddenMessages = new TSObservableCollection <SystemMessageViewModel>(); ShowedMessages = new TSObservableCollection <SystemMessageViewModel>(); App.Settings.UserExcludedSysMsg.ForEach(opc => { HiddenMessages.Add(new SystemMessageViewModel(opc, Game.DB !.SystemMessagesDatabase.Messages[opc])); }); Game.DB !.SystemMessagesDatabase.Messages.ToList().ForEach(keyVal => { if (App.Settings.UserExcludedSysMsg.Contains(keyVal.Key)) { return; } ShowedMessages.Add(new SystemMessageViewModel(keyVal.Key, keyVal.Value)); }); HiddenMessages.CollectionChanged += (_, args) => { switch (args.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: foreach (var item in args.NewItems !) { var opcode = ((SystemMessageViewModel?)item)?.Opcode; if (opcode != null) { App.Settings.UserExcludedSysMsg.Add(opcode); } } break; case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: foreach (var item in args.OldItems !) { var opcode = ((SystemMessageViewModel?)item)?.Opcode; if (opcode != null) { App.Settings.UserExcludedSysMsg.Remove(opcode); } } break; } App.Settings.Save(); }; ShowedMessagesView = CollectionViewFactory.CreateLiveCollectionView(ShowedMessages); HiddenMessagesView = CollectionViewFactory.CreateLiveCollectionView(HiddenMessages); }
private void EnableLiveFiltering() { // Set properties to trigger live updating ICollectionViewLiveShaping liveCollection = this.EpisodesCollectionView as ICollectionViewLiveShaping; liveCollection.LiveFilteringProperties.Add("Season"); liveCollection.LiveFilteringProperties.Add("DisplayName"); liveCollection.LiveFilteringProperties.Add("Status"); liveCollection.IsLiveFiltering = true; liveCollection.LiveGroupingProperties.Add("Missing"); liveCollection.LiveGroupingProperties.Add("Season"); liveCollection.LiveGroupingProperties.Add("Show"); liveCollection.IsLiveGrouping = true; }
public void Initialize() { _viewSource.Source = TradeHandler?.OrderVMCollection; ExecutionTreeView.ItemsSource = _viewSource.View; mColumns = ColumnObject.GetColumns(ExecutionTreeView); ExecutionChanged = _viewSource.View as ICollectionViewLiveShaping; if (ExecutionChanged.CanChangeLiveFiltering) { ExecutionChanged.LiveFilteringProperties.Add("Status"); ExecutionChanged.IsLiveFiltering = true; } TradeHandler.OrderVMCollection.Clear(); TradeHandler.QueryOrder(); FilterSettingsWin.UserID = TradeHandler.MessageWrapper?.User.Id; }
// Token: 0x060075AC RID: 30124 RVA: 0x002196E0 File Offset: 0x002178E0 internal LiveShapingList(ICollectionViewLiveShaping view, LiveShapingFlags flags, IComparer comparer) { this._view = view; this._comparer = comparer; this._isCustomSorting = !(comparer is SortFieldComparer); this._dpFromPath = new LiveShapingList.DPFromPath(); this._root = new LiveShapingTree(this); if (comparer != null) { this._root.Comparison = new Comparison <LiveShapingItem>(this.CompareLiveShapingItems); } this._sortDirtyItems = new List <LiveShapingItem>(); this._filterDirtyItems = new List <LiveShapingItem>(); this._groupDirtyItems = new List <LiveShapingItem>(); this.SetLiveShapingProperties(flags); }
private void ActivateLiveFiltering(ICollectionView collectionView, IList <String> propertyNames) { ICollectionViewLiveShaping collectionViewLiveShaping = collectionView as ICollectionViewLiveShaping; if (Equals(collectionViewLiveShaping, null)) { return; } else if (collectionViewLiveShaping.CanChangeLiveFiltering) { foreach (String propertyName in propertyNames) { collectionViewLiveShaping.LiveFilteringProperties.Add(propertyName); } collectionViewLiveShaping.IsLiveFiltering = true; } }
public ContentCollectionControlViewModel(ContentType contentType) { this.contentType = contentType; this.FolderFilters = new ObservableCollection <string>(); this.GenreFilters = new ObservableCollection <string>(); this.MoveRootFolderItems = new ObservableCollection <MenuItem>(); this.ContentType = contentType; ContentCollection contentCollection = contentType == ContentType.TvShow ? Organization.Shows : Organization.Movies; lock (contentCollection.ContentLock) { foreach (Content cntnt in contentCollection) { Contents.Add(cntnt); } contentCollection.LoadProgressChange += Content_LoadProgressChange; contentCollection.CollectionChanged += Contents_CollectionChanged; contentCollection.LoadComplete += Content_LoadComplete; } Settings.SettingsModified += Settings_SettingsModified; ContentRootFolder.UpdateProgressChange += ContentRootFolder_UpdateProgressChange; ContentRootFolder.UpdateProgressComplete += ContentRootFolder_UpdateProgressComplete; this.Folders = new ObservableCollection <ContentRootFolder>(); this.Contents = new ObservableCollection <Content>(); this.ContentsCollectionView = CollectionViewSource.GetDefaultView(this.Contents); this.ContentsCollectionView.Filter = new Predicate <object>(ContentFilter); this.ContentsCollectionView.SortDescriptions.Add(new SortDescription("DisplayName", ListSortDirection.Ascending)); // Set properties to trigger live updating ICollectionViewLiveShaping liveCollection = this.ContentsCollectionView as ICollectionViewLiveShaping; liveCollection.LiveFilteringProperties.Add("DisplayGenres"); liveCollection.LiveFilteringProperties.Add("DisplayYear"); liveCollection.LiveFilteringProperties.Add("RootFolder"); liveCollection.LiveFilteringProperties.Add("DisplayName"); liveCollection.LiveFilteringProperties.Add("Watched"); liveCollection.IsLiveFiltering = true; liveCollection.IsLiveSorting = true; liveCollection.LiveSortingProperties.Add("DisplayName"); }
public LiveTableViewModel(IObservable <T> t, IObservable <KeyValuePair <string, ListSortDirection> > sortonproperty = null, IObservable <Predicate <object> > filterbyproperty = null) { View = (ICollectionViewLiveShaping)CollectionViewSource.GetDefaultView(_items); View.IsLiveSorting = true; sortonproperty?.ObserveOnDispatcher().Subscribe(_ => ((ICollectionView)View).SortDescriptions.Add(new SortDescription(_.Key, _.Value))); Predicate <object> a = null; filterbyproperty.Subscribe(_ => { if (a != null) { ((ICollectionView)View).Filter -= _; } a = _; ((ICollectionView)View).Filter += _; }); t.ObserveOnDispatcher().Subscribe(_ => _items.Add(_)); }
public MainWindow() { InitializeComponent(); _items = GenerateTestData(); ICollectionViewLiveShaping view = (ICollectionViewLiveShaping)CollectionViewSource.GetDefaultView(_items); view.IsLiveSorting = true; view.LiveSortingProperties.Add("Value"); dgAsset.ItemsSource = (IEnumerable)view; Random random = new Random(); _timer.Interval = TimeSpan.FromSeconds(1); _timer.Tick += (s, e) => { foreach (var item in _items) { item.Value += random.NextDouble() * 1000 - 500; } }; _timer.Start(); }
public OrgItemDisplayViewModel() { this.OrgItems = new ObservableCollection <OrgItem>(); this.OrgItemsCollection = CollectionViewSource.GetDefaultView(OrgItems); this.OrgItemsCollection.Filter = new Predicate <object>(FilterItem); // Set properties to trigger live updating ICollectionViewLiveShaping liveCollection = this.OrgItemsCollection as ICollectionViewLiveShaping; liveCollection.LiveFilteringProperties.Add("Category"); liveCollection.LiveFilteringProperties.Add("Action"); liveCollection.IsLiveFiltering = true; liveCollection.IsLiveSorting = true; liveCollection.LiveSortingProperties.Add("ActionTime"); liveCollection.LiveSortingProperties.Add("Action"); liveCollection.LiveSortingProperties.Add("Category"); liveCollection.LiveSortingProperties.Add("QueueStatus"); liveCollection.LiveSortingProperties.Add("DestinationPath"); liveCollection.LiveSortingProperties.Add("SourcePath"); liveCollection.LiveSortingProperties.Add("Status"); }
public SortCommand(ICollectionViewLiveShaping view) { _view = view; }
// Forward properties from the CollectionViewSource to the CollectionView void ApplyPropertiesToView(ICollectionView view) { if (view == null || _deferLevel > 0) { return; } ICollectionViewLiveShaping liveView = view as ICollectionViewLiveShaping; using (view.DeferRefresh()) { int i, n; // Culture if (Culture != null) { view.Culture = Culture; } // Sort if (view.CanSort) { view.SortDescriptions.Clear(); for (i = 0, n = SortDescriptions.Count; i < n; ++i) { view.SortDescriptions.Add(SortDescriptions[i]); } } else if (SortDescriptions.Count > 0) { throw new InvalidOperationException(SR.Get(SRID.CannotSortView, view)); } // Filter Predicate <object> filter; if (FilterHandlersField.GetValue(this) != null) { filter = FilterWrapper; } else { filter = null; } if (view.CanFilter) { view.Filter = filter; } else if (filter != null) { throw new InvalidOperationException(SR.Get(SRID.CannotFilterView, view)); } // GroupBy if (view.CanGroup) { view.GroupDescriptions.Clear(); for (i = 0, n = GroupDescriptions.Count; i < n; ++i) { view.GroupDescriptions.Add(GroupDescriptions[i]); } } else if (GroupDescriptions.Count > 0) { throw new InvalidOperationException(SR.Get(SRID.CannotGroupView, view)); } // Live shaping if (liveView != null) { ObservableCollection <string> properties; // sorting if (liveView.CanChangeLiveSorting) { liveView.IsLiveSorting = IsLiveSortingRequested; properties = liveView.LiveSortingProperties; properties.Clear(); if (IsLiveSortingRequested) { foreach (string s in LiveSortingProperties) { properties.Add(s); } } } CanChangeLiveSorting = liveView.CanChangeLiveSorting; IsLiveSorting = liveView.IsLiveSorting; // filtering if (liveView.CanChangeLiveFiltering) { liveView.IsLiveFiltering = IsLiveFilteringRequested; properties = liveView.LiveFilteringProperties; properties.Clear(); if (IsLiveFilteringRequested) { foreach (string s in LiveFilteringProperties) { properties.Add(s); } } } CanChangeLiveFiltering = liveView.CanChangeLiveFiltering; IsLiveFiltering = liveView.IsLiveFiltering; // grouping if (liveView.CanChangeLiveGrouping) { liveView.IsLiveGrouping = IsLiveGroupingRequested; properties = liveView.LiveGroupingProperties; properties.Clear(); if (IsLiveGroupingRequested) { foreach (string s in LiveGroupingProperties) { properties.Add(s); } } } CanChangeLiveGrouping = liveView.CanChangeLiveGrouping; IsLiveGrouping = liveView.IsLiveGrouping; } else { CanChangeLiveSorting = false; IsLiveSorting = null; CanChangeLiveFiltering = false; IsLiveFiltering = null; CanChangeLiveGrouping = false; IsLiveGrouping = null; } } }
// Forward properties from the CollectionViewSource to the CollectionView private void ApplyPropertiesToView(ICollectionView view) { if (view == null || _deferLevel > 0) { return; } #if false // no live shaping ICollectionViewLiveShaping liveView = view as ICollectionViewLiveShaping; #endif // no live shaping using (view.DeferRefresh()) { int i, n; // Culture if (Culture != null) { view.Culture = Culture; } // Sort if (view.CanSort) { view.SortDescriptions.Clear(); for (i = 0, n = SortDescriptions.Count; i < n; ++i) { view.SortDescriptions.Add(SortDescriptions[i]); } } else if (SortDescriptions.Count > 0) { throw new InvalidOperationException(string.Format("'{0}' view does not support sorting.", view)); } // Filter Predicate <object> filter; if (_filterHandlers != null) { filter = FilterWrapper; } else { filter = null; } if (view.CanFilter) { view.Filter = filter; } else if (filter != null) { throw new InvalidOperationException(string.Format("'{0}' view does not support filtering.", view)); } // GroupBy if (view.CanGroup) { view.GroupDescriptions.Clear(); for (i = 0, n = GroupDescriptions.Count; i < n; ++i) { view.GroupDescriptions.Add(GroupDescriptions[i]); } } else if (GroupDescriptions.Count > 0) { throw new InvalidOperationException(string.Format("'{0}' view does not support grouping.", view)); } #if false // no live shaping // Live shaping if (liveView != null) { ObservableCollection <string> properties; // sorting if (liveView.CanChangeLiveSorting) { liveView.IsLiveSorting = IsLiveSortingRequested; properties = liveView.LiveSortingProperties; properties.Clear(); if (IsLiveSortingRequested) { foreach (string s in LiveSortingProperties) { properties.Add(s); } } } CanChangeLiveSorting = liveView.CanChangeLiveSorting; IsLiveSorting = liveView.IsLiveSorting; // filtering if (liveView.CanChangeLiveFiltering) { liveView.IsLiveFiltering = IsLiveFilteringRequested; properties = liveView.LiveFilteringProperties; properties.Clear(); if (IsLiveFilteringRequested) { foreach (string s in LiveFilteringProperties) { properties.Add(s); } } } CanChangeLiveFiltering = liveView.CanChangeLiveFiltering; IsLiveFiltering = liveView.IsLiveFiltering; // grouping if (liveView.CanChangeLiveGrouping) { liveView.IsLiveGrouping = IsLiveGroupingRequested; properties = liveView.LiveGroupingProperties; properties.Clear(); if (IsLiveGroupingRequested) { foreach (string s in LiveGroupingProperties) { properties.Add(s); } } } CanChangeLiveGrouping = liveView.CanChangeLiveGrouping; IsLiveGrouping = liveView.IsLiveGrouping; } else { CanChangeLiveSorting = false; IsLiveSorting = null; CanChangeLiveFiltering = false; IsLiveFiltering = null; CanChangeLiveGrouping = false; IsLiveGrouping = null; } #endif // no live shaping } }