OIShoppingListWinPhone.DataModel.ShoppingList.FilterItemsCollection C# (CSharp) 메소드

FilterItemsCollection() 공개 메소드

Filter existing ListItems collection with corresponding application settings. If you filter your collection with this method - collection will be sorted automatically. To prevent doubling of sorting DON'T call SortItemsCollection method after it.
public FilterItemsCollection ( ) : void
리턴 void
        public void FilterItemsCollection()
        {
            IEnumerable<ShoppingListItem> collection = new ObservableCollection<ShoppingListItem>();
            //Select all NOT picked items from list items collection
            if (App.Settings.HideCheckedItemsSettings)
                collection = from item in this.ListItems
                             where item.Status == 0
                             select item;
            else
                collection = from item in this.ListItems
                             where item.Status != 2
                             select item;

            //Filtering collection
            if (_filterTag != "Tag [Empty]")
                //Selecting list items that contains current tag
                collection = from item in collection
                             where item.Tags.Contains(this._filterTag)
                             select item;

            if (_filterStore != "Store [Empty]")
                //Selecting list items that contains current store
                collection = from item in collection
                             from item_store in item.ItemsStores
                             where item_store.Store.StoreName == this._filterStore
                             select item;

            this.bFiltered = true;
            this._sortedItemsCollection = collection;
            //If items collection has just filtered - it is necessary to sort this collection.
            //Sort items collection
            this.SortItemsCollection();
        }

Usage Example

        /// <summary>
        /// Move item to another list
        /// </summary>
        /// <param name="oldList">Instance of old item list</param>
        /// <param name="newList">Instance of new item list</param>
        /// <param name="listItem">Instance of item to be moved</param>
        public void MoveItemToAnotherList(ShoppingList oldList, ShoppingList newList, ShoppingListItem listItem)
        {
            oldList.ListItems.Remove(listItem);
            oldList.ModifiedDate = DateTime.Now;
            //Filter list items collection with adding new item to list
            oldList.FilterItemsCollection();

            listItem.List = newList;
            newList.ListItems.Add(listItem);
            newList.ModifiedDate = DateTime.Now;
            //Filter list items collection with adding new item to list
            newList.FilterItemsCollection();

            //Submiting all changes to database
            //listDB.ListItems.InsertOnSubmit(newListItem);
            listDB.SubmitChanges();
        }
All Usage Examples Of OIShoppingListWinPhone.DataModel.ShoppingList::FilterItemsCollection