Пример #1
0
 private void RefreshData(object para)
 {
     vInfoCollection.Clear();
     anInfoCollection.Clear();
     divFreCollection.Clear();
     AddData(para);
 }
Пример #2
0
            public void HandlesChangesOfSuspendedFastObservableCollectionCorrectly()
            {
                var collection = new FastObservableCollection <TestModel>
                {
                    AutomaticallyDispatchChangeNotifications = false
                };

                for (var i = 0; i < 10; i++)
                {
                    var randomModel = new TestModel();
                    collection.Add(randomModel);
                }

                var wrapper = new ChangeNotificationWrapper(collection);

                var collectionItemPropertyChanged = false;

                wrapper.CollectionItemPropertyChanged += (sender, e) => collectionItemPropertyChanged = true;

                var newModel = new TestModel();

                using (collection.SuspendChangeNotifications())
                {
                    collection.Clear();
                    collection.Add(newModel);
                }

                newModel.FirstName = "Geert";

                Assert.IsTrue(collectionItemPropertyChanged, "Collection item property should have changed");
            }
Пример #3
0
            public void HandlesClearOfSuspendedFastObservableCollectionCorrectly()
            {
                var collection = new FastObservableCollection <TestModel>
                {
                    AutomaticallyDispatchChangeNotifications = false
                };

                TestModel model = null;

                for (var i = 0; i < 10; i++)
                {
                    var randomModel = new TestModel();
                    collection.Add(randomModel);
                }

                model = collection[0];

                var wrapper = new ChangeNotificationWrapper(collection);

                var collectionItemPropertyChanged = false;

                wrapper.CollectionItemPropertyChanged += (sender, e) => collectionItemPropertyChanged = true;

                using (collection.SuspendChangeNotifications())
                {
                    collection.Clear();
                }

                model.FirstName = "Geert";

                Assert.IsFalse(collectionItemPropertyChanged);
            }
Пример #4
0
            public void MultipleActionsWithoutSuspendingNotifications()
            {
                var counter = 0;

                var fastCollection = new FastObservableCollection <int>();

                fastCollection.AutomaticallyDispatchChangeNotifications = false;
                fastCollection.CollectionChanged += (sender, e) => counter++;

                fastCollection.Add(0);
                fastCollection.Add(1);

                fastCollection.Remove(0);
                fastCollection.Remove(1);

                fastCollection.AddRange(new[] { 1, 2 });

                fastCollection[0] = 5;

                fastCollection.Move(0, 1);

                fastCollection.Clear();

                Assert.AreEqual(9, counter);
            }
            public void HandlesChangesOfSuspendedFastObservableCollectionCorrectly()
            {
                var       collection = new FastObservableCollection <TestModel>();
                TestModel model      = null;

                for (int i = 0; i < 10; i++)
                {
                    var randomModel = new TestModel();
                    collection.Add(randomModel);
                }

                var wrapper = new ChangeNotificationWrapper(collection);

                var collectionItemPropertyChanged = false;

                wrapper.CollectionItemPropertyChanged += (sender, e) => collectionItemPropertyChanged = true;

                var newModel = new TestModel();

                using (collection.SuspendChangeNotifications())
                {
                    collection.Clear();
                    collection.Add(newModel);
                }

                newModel.FirstName = "Geert";

                Assert.IsTrue(collectionItemPropertyChanged);
            }
Пример #6
0
        public void ClearEntries()
        {
            _isClearingLog = true;

            // Note: we need to dispatch because the FastObservableCollection automatically dispatches (which is a good thing
            // when coming from a background thread). However... the ReplaceRange will be executed *outside* the lock
            // which is not good. So the lock is inside the dispatcher handler, and we manually dispatcher here.
            // Note: don't use BeginInvoke here because we need to wait until action will be processed
            _dispatcherService.Invoke(() =>
            {
                lock (_lock)
                {
                    using (_logEntries.SuspendChangeNotifications())
                    {
                        _logEntries.Clear();

                        var typeNames = TypeNames;
                        if (typeNames != null)
                        {
                            using (typeNames.SuspendChangeNotifications())
                            {
                                typeNames.ReplaceRange(new[] { _defaultComboBoxItem });
                            }
                        }
                    }
                }

                ResetEntriesCount();

                _isClearingLog = false;
            }, false);
        }
Пример #7
0
        public void Handle(ProjectClosedEvent args)
        {
            _selectedItems.Clear();

            OnPropertyChanged(() => Items);
            OnPropertyChanged(() => SelectedItems);
        }
Пример #8
0
        public void CreateOrders(FastObservableCollection <Order> orders)
        {
            orders.Clear();
            var currentOrders = _unitOfWork.Orders.GetAll().Where(_ordersSelector).ToList();

            currentOrders.Sort((o1, o2) => o2.Reservation.Day.CompareTo(o1.Reservation.Day));
            orders.AddItems(currentOrders);
        }
Пример #9
0
            public void ThrowsInvalidOperationExceptionForClearingInAddingMode()
            {
                var fastCollection = new FastObservableCollection <int>();

                using (fastCollection.SuspendChangeNotifications(SuspensionMode.Adding))
                {
                    Assert.Throws <InvalidOperationException>(() => fastCollection.Clear());
                }
            }
Пример #10
0
        public void CreateBonusDishes(FastObservableCollection <OrderedDish> bonusDishes)
        {
            bonusDishes.Clear();
            var currentDishes =
                _unitOfWork.OrderedDishes.GetAll().Where(_orderedDishesSelector)
                .Where(od => od.OrderedPrice == 0).ToList();                 // фильтруем только бонусы

            currentDishes.Sort((d1, d2) => d2.Order.Reservation.Day.CompareTo(d1.Order.Reservation.Day));
            bonusDishes.AddItems(currentDishes);
        }
Пример #11
0
        public void CreateOrderedDishes(FastObservableCollection <OrderedDish> orderedDishes)
        {
            orderedDishes.Clear();
            var currentDishes =
                _unitOfWork.OrderedDishes.GetAll().Where(_orderedDishesSelector)
                .Where(od => od.OrderedPrice != 0).ToList();                         // не считаем бонусы

            currentDishes.Sort((d1, d2) => d2.Order.Reservation.Day.CompareTo(d1.Order.Reservation.Day));

            orderedDishes.AddItems(currentDishes);
        }
Пример #12
0
        private void setEntries(params VM[] viewModels)
        {
            _subItemList = viewModels.ToList();
            FastObservableCollection <VM> all = All as FastObservableCollection <VM>;

            all.SuspendCollectionChangeNotification();
            all.Clear();
            all.NotifyChanges();
            all.AddItems(viewModels);
            all.NotifyChanges();

            if (EntriesChanged != null)
            {
                EntriesChanged(this, EventArgs.Empty);
            }
        }
        /// <summary>
        /// Call to unload sub-entries.
        /// Method can also be used to cancel current load processings.
        /// </summary>
        /// <returns></returns>
        public async Task UnloadAsync()
        {
            Logger.InfoFormat("_");

            // Cancel previous load.
            _lastCancellationToken.Cancel();

            using (var releaser = await _loadingLock.LockAsync())
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    _All.Clear();
                });

                _isLoaded = false;
            }
        }
        /// <summary>
        /// Resets the entries (via Clear and Add) in the ALL items collection
        /// with the entries in the <param name="viewModels"/> parameter.
        /// </summary>
        /// <param name="viewModels"></param>
        private void ResetAllEntries(params VM[] viewModels)
        {
            Logger.InfoFormat("_");

            FastObservableCollection <VM> all = this.All as FastObservableCollection <VM>;

            all.SuspendCollectionChangeNotification();
            try
            {
                all.Clear();
                all.NotifyChanges();
                all.AddItems(viewModels);
            }
            finally
            {
                all.NotifyChanges();

                if (this.EntriesChanged != null)
                {
                    this.EntriesChanged(this, EventArgs.Empty);
                }
            }
        }
Пример #15
0
 private void ReFillTables()
 {
     _myTables.Clear();
     _myTables.AddItems(_unitOfWork.Tables.GetAll());
 }
            public void HandlesClearOfSuspendedFastObservableCollectionCorrectly()
            {
                var collection = new FastObservableCollection<TestModel>();
                TestModel model = null;

                for (int i = 0; i < 10; i++)
                {
                    var randomModel = new TestModel();
                    collection.Add(randomModel);
                }

                model = collection[0];

                var wrapper = new ChangeNotificationWrapper(collection);

                var collectionItemPropertyChanged = false;
                wrapper.CollectionItemPropertyChanged += (sender, e) => collectionItemPropertyChanged = true;

                using (collection.SuspendChangeNotifications())
                {
                    collection.Clear();
                }

                model.FirstName = "Geert";

                Assert.IsFalse(collectionItemPropertyChanged);
            }