Ejemplo n.º 1
0
        private void AlterCatalogCollection(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (var newItem in e.NewItems.OfType <Catalog>())
                {
                    CreateCatalogViewModel(newItem);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (var catalogViewModel in e.OldItems.OfType <Catalog>()
                         .Select(oldItem => m_Catalogs.Single(r => r.Model == oldItem)))
                {
                    m_Catalogs.Remove(catalogViewModel);
                    foreach (var mvm in m_Measures.Where(mvm => catalogViewModel.Measures.Contains(mvm.Model))
                             .ToArray())
                    {
                        m_Measures.Remove(mvm);
                    }
                }
                break;
            }
            NotifyOfPropertyChange(() => Catalogs);
        }
 public void DeleteInventory(object dataContext)
 {
     if (dataContext.GetType() == typeof(InventoryViewModel))
     {
         var ivm = (InventoryViewModel)dataContext;
         m_Inventories.Remove(ivm);
         m_Repository.Inventories.Remove(ivm.Model);
         NotifyOfPropertyChange(() => Inventories);
     }
 }
Ejemplo n.º 3
0
        public static int RemoveWhere <T>(this BindableCollection <T> collection, Func <T, bool> predicate)
            where T : class
        {
            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            var num = 0;

            try
            {
                Monitor.Enter(collection);
                var items = collection.Where(predicate).ToList();
                foreach (var item in items)
                {
                    if (collection.Remove(item))
                    {
                        num++;
                    }
                }
            }
            finally
            {
                Monitor.Exit(collection);
            }
            return(num);
        }
                private async Task CloseItemCoreAsync(T item, CancellationToken cancellationToken)
                {
                    if (item.Equals(ActiveItem))
                    {
                        var index = _items.IndexOf(item);
                        var next  = DetermineNextItemToActivate(_items, index);

                        await ChangeActiveItemAsync(next, true, cancellationToken);
                    }
                    else
                    {
                        await ScreenExtensions.TryDeactivateAsync(item, true, cancellationToken);
                    }

                    _items.Remove(item);
                }
        public void EndProcessing(object data)
        {
            string item = (data ?? "NULL").ToString();

            _processing.Remove(item);
            OnPropertyChanged("Queues");
        }
Ejemplo n.º 6
0
        public void Handle(DatabaseRegistrationMessage message)
        {
            switch (message.Action)
            {
            case DatabaseRegistrationActions.Updated:
            case DatabaseRegistrationActions.Removed:
                var existing = _databases.FirstOrDefault(
                    x => x.Id == message.Id);

                if (existing != null)
                {
                    _databases.Remove(existing);
                }

                break;
            }

            switch (message.Action)
            {
            case DatabaseRegistrationActions.Added:
            case DatabaseRegistrationActions.Updated:
                _databases.Add(Map(message.Registration));
                break;
            }
        }
        public void GetAllProperties(BindableCollection <ClassificationSearchResultContractV2> selectedClasses, string languageCode = null)
        {
            List <NodeItem> newNodes = new List <NodeItem>();

            foreach (var item in selectedClasses)
            {
                if (!_classes.Any(o => o.Name == item.Name))
                {
                    newNodes.Add(GetPropertiesInClassification(item.NamespaceUri, languageCode));
                }
            }
            foreach (var item in newNodes)
            {
                if (!_classes.Any(o => o.Name == item.Name))
                {
                    _classes.Add(item);
                }
            }
            List <NodeItem> removeList = new List <NodeItem>();

            foreach (var item in _classes)
            {
                if (!selectedClasses.Any(o => o.Name == item.Name))
                {
                    removeList.Add(item);
                }
            }
            foreach (var item in removeList)
            {
                _classes.Remove(item);
            }
        }
Ejemplo n.º 8
0
 public QuestionModel GetNextQuestion()
 {
     try
     {
         QuestionModel q = this.Questions[rand.Next(0, this.Questions.Count)];
         Questions.Remove(q);
         QuestionModel ret = new QuestionModel(q.IdDB, q.QuestionText);
         BindableCollection<AnswerModel> answers = new BindableCollection<AnswerModel>();
         foreach (AnswerModel a in q.Answers)
         {
             answers.Add(a);
         }
         while (answers.Count > 0)
         {
             AnswerModel a = answers[rand.Next(0, answers.Count)];
             answers.Remove(a);
             ret.Answers.Add(a);
         }
         return ret;
     }
     catch
     {
         return null;
     }
 }
Ejemplo n.º 9
0
        private void AlterBuildingsCollection(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (var newItem in e.NewItems.OfType <DomainModelService.Building>())
                {
                    CreateBuildingViewModel(newItem);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (var buildingViewModel in e.OldItems.OfType <DomainModelService.Building>()
                         .Select(oldItem => m_Buildings.Single(r => r.Model == oldItem)))
                {
                    m_Buildings.Remove(buildingViewModel);
                    foreach (var rvm in m_Rooms.Where(rvm => buildingViewModel.Rooms.Contains(rvm.Model))
                             .ToArray())
                    {
                        m_Rooms.Remove(rvm);
                    }
                }
                break;
            }
            NotifyOfPropertyChange(() => Buildings);
        }
Ejemplo n.º 10
0
 public void DeleteRow(object def)
 {
     if (def is LedenetDeviceDefinition deviceDefinition)
     {
         Definitions.Remove(deviceDefinition);
     }
 }
Ejemplo n.º 11
0
 void DeleteComment(PhotoCommentViewModel comment)
 {
     comment.IsDeleting = true;
     try
     {
         PhotoServiceClient svc = new PhotoServiceClient();
         svc.DeleteCommentCompleted += (sender, e) =>
         {
             comment.IsDeleting = false;
             if (e.Error != null)
             {
                 e.Error.Handle();
             }
             else
             {
                 if (_comments != null)
                 {
                     _comments.Remove(comment);
                 }
             }
             NotifyOfPropertyChange(() => HasComment);
         };
         svc.DeleteCommentAsync(comment.Id);
     }
     catch
     {
         comment.IsDeleting = false;
     }
 }
Ejemplo n.º 12
0
        public async void DeleteBooks()
        {
            var selectedBooks = SelectedBooks?.Cast <Book>();

            if (selectedBooks?.Count() > 1)
            {
                await _bookManager.DeleteBooks(selectedBooks);

                _allBooks.RemoveRange(selectedBooks);
                _recentBooks.RemoveRange(selectedBooks);
            }
            else
            {
                await _bookManager.DeleteBook(SelectedBook);

                _allBooks.Remove(SelectedBook);
                _recentBooks.Remove(SelectedBook);
            }

            BooksSelectionMode = ListViewSelectionMode.None;
            BooksClickEnabled  = true;

            NotifyOfPropertyChange(nameof(RecentBooks));
            NotifyOfPropertyChange(nameof(AllBooks));
        }
Ejemplo n.º 13
0
                void CloseItemCore(T item)
                {
                    if (item.Equals(ActiveItem))
                    {
                        var index = items.IndexOf(item);
                        var next  = DetermineNextItemToActivate(items, index);

                        ChangeActiveItem(next, true);
                    }
                    else
                    {
                        ScreenExtensions.TryDeactivate(item, true);
                    }

                    items.Remove(item);
                }
Ejemplo n.º 14
0
        public EditGameFlyoutViewModel(
            IDialogManager dialogManager,
            IEventAggregator events,
            IRepository <ArenaSession> arenaRepository,
            IRepository <GameResult> gameRepository,
            IDeckManager deckManager,
            GameManager.GameManager gameManager)
        {
            this.dialogManager   = dialogManager;
            this.events          = events;
            this.arenaRepository = arenaRepository;
            this.gameRepository  = gameRepository;
            this.deckManager     = deckManager;
            this.gameManager     = gameManager;
            Name   = Flyouts.EditGame;
            Header = displayName_new;
            SetPosition(Position.Right);
            heroes = new BindableCollection <Hero>();
            events.Subscribe(this);

            GameMode         = GameMode.Practice;
            StartTime        = DateTime.Now;
            EndTime          = DateTime.Now;
            PropertyChanged += OnPropertyChanged;
            lastIsOpen       = IsOpen;

            // yeah lol :p
            gameModes.Remove(GameMode.Arena);
            selectedServer = servers.Default;
            Busy           = new BusyWatcher();
        }
Ejemplo n.º 15
0
        public override void Remove(RuleViewModelBase rule, bool showOnSnackbar = true)
        {
            var index = _rules.IndexOf(rule);

            if (index == -1)
            {
                return;
            }

            _model.Rules.Remove(rule.Rule);
            _rules.Remove(rule);

            if (!showOnSnackbar)
            {
                return;
            }

            _eventAggregator.PublishOnCurrentThread(new SnackbarMessage()
            {
                Action = smq => smq.Enqueue($"Rule \"{rule.Name}\" removed", "UNDO",
                                            () =>
                {
                    _rules.Insert(index, rule);
                    _model.Rules.Add(rule.Rule);
                }, true)
            });
        }
Ejemplo n.º 16
0
        public void when_Remove_is_called_and_IsNotifying_is_false_then_Remove_event_is_fired()
        {
            var testSchedulerProvider = new TestDispatcherSchedulerProvider();

            var result = false;

            var bindableCollection = new BindableCollection <Guid>(testSchedulerProvider);

            var newGuid = Guid.NewGuid();

            bindableCollection.Add(newGuid);

            bindableCollection.CollectionChanged += (sender, args) =>
            {
                if (args.Action == NotifyCollectionChangedAction.Remove)
                {
                    result = true;
                }
            };

            bindableCollection.IsNotifying = false;

            bindableCollection.Remove(newGuid);

            Assert.That(result, Is.False);
        }
        public void RemoveEventRaised()
        {
            BindableCollection<SimpleBusinessObject> lBindableCollection = new BindableCollection<SimpleBusinessObject>();
            bool removingRaised = false;
            lBindableCollection.ItemRemovedEvent += delegate(object sender, ItemRemovedEventArgs ea)
                {
                    removingRaised = true;
                };

            Assert.IsFalse(removingRaised);

            lBindableCollection.Add(new SimpleBusinessObject());

            Assert.IsFalse(removingRaised);

            lBindableCollection.RemoveAt(0);

            Assert.IsTrue(removingRaised);

            SimpleBusinessObject sbo = new SimpleBusinessObject();
            lBindableCollection.Add(sbo);
            removingRaised = false;

            lBindableCollection.Remove(sbo);

            Assert.IsTrue(removingRaised);
        }
Ejemplo n.º 18
0
        public static BindableCollection <BookDTO> GetAllAvaibleBooksForUserBindableCollection(int userId)
        {
            using (LibraryContext db = new LibraryContext())
            {
                var booksBorrowed = db.Borrows.Where(x => x.UserId == userId && x.IsReturned == false).Select(x => new BorrowDetailsDTO
                {
                    BookId = x.BookId
                }).ToList();

                BindableCollection <BookDTO> AvaibleBooksForUser = new BindableCollection <BookDTO>(db.Books.Where(x => x.Count > 0).Select(
                                                                                                        x => new BookDTO
                {
                    BookId        = x.BookId,
                    Title         = x.Title,
                    Author        = x.Author,
                    ReleaseDate   = x.ReleaseDate,
                    ISBN          = x.ISBN,
                    Count         = x.Count,
                    AddDate       = x.AddDate,
                    ModifiedDate  = x.ModifiedDate,
                    BookGenreId   = x.BookGenreId,
                    BookGenreName = x.DictBookGenre.Name
                }).ToList());

                foreach (var item in booksBorrowed)
                {
                    var y = AvaibleBooksForUser.Where(x => x.BookId == item.BookId).FirstOrDefault();
                    AvaibleBooksForUser.Remove(y);
                }

                return(AvaibleBooksForUser);
            }
        }
Ejemplo n.º 19
0
        public bool CheckAnswers()
        {
            BindableCollection <AnswerModel> selectedAnswers = new BindableCollection <AnswerModel>();
            BindableCollection <AnswerModel> correctAnswers  = this.CorrectAnswers();

            foreach (AnswerModel answer in this.Answers)
            {
                if (answer.IsSelected)
                {
                    selectedAnswers.Add(answer);
                }
            }
            foreach (AnswerModel answer in selectedAnswers)
            {
                if (correctAnswers.Contains(answer))
                {
                    correctAnswers.Remove(answer);
                }
                else
                {
                    return(false);
                }
            }
            if (correctAnswers.Any())
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 20
0
 public void Delete(PositionViewModel positionViewModel)
 {
     Model.Positions.Remove(positionViewModel.Model);
     m_Positions.Remove(positionViewModel);
     CloseEditor();
     NotifyOfPropertyChange(() => FilteredPositions);
     Save();
 }
Ejemplo n.º 21
0
        public void DelMonster()
        {
            DeactivateItem(ActiveItem, true);

            _monsters.Remove(SelectedMonster);

            SelectedMonster = null;
        }
        public void DelTrait()
        {
            DeactivateItem(ActiveItem, true);

            _traits.Remove(SelectedTrait);

            SelectedTrait = null;
        }
Ejemplo n.º 23
0
        private void OnCardRemoved(object sender, ZoneChangedEventArgs e)
        {
            var viewModel = _cards.Single(x => x.Card == e.Card);

            _cards.Remove(viewModel);
            viewModel.Close();
            ViewModels.SelectableCard.Destroy(viewModel);
        }
Ejemplo n.º 24
0
        public void DelEncounterMonster()
        {
            DeactivateItem(ActiveItem, true);

            _encounterMonsters.Remove(SelectedEncounterMonster);

            SelectedEncounterMonster = null;
        }
Ejemplo n.º 25
0
        public void DeleteRoom(object dataContext)
        {
            if (dataContext.GetType() == typeof(RoomViewModel))
            {
                var confirmResult = MessageBox.Show(TranslationProvider.Translate("DeleteRoomMsg"),
                                                    TranslationProvider.Translate("DeleteRoom"), MessageBoxButton.YesNo);
                if (confirmResult != MessageBoxResult.Yes)
                {
                    return;
                }

                var rvm = (RoomViewModel)dataContext;
                m_Rooms.Remove(rvm);
                m_Repository.Rooms.Remove(rvm.Model);
                NotifyOfPropertyChange(() => Rooms);
            }
        }
Ejemplo n.º 26
0
        //private void AlterRoomCollection(object sender, NotifyCollectionChangedEventArgs eventArgs)
        //{
        //  switch (eventArgs.Action)
        //  {
        //    case NotifyCollectionChangedAction.Add:
        //      foreach (var room in eventArgs.NewItems.OfType<Room>())
        //      {
        //        m_Rooms.Add(new RoomViewModel(room));
        //      }
        //      break;
        //    case NotifyCollectionChangedAction.Remove:
        //      foreach (var oldRoom in
        //        eventArgs.OldItems.OfType<Room>()
        //                 .Select(room => m_Rooms.Single(c => c.Model == room)))
        //      {
        //        m_Rooms.Remove(oldRoom);
        //      }
        //      break;
        //  }
        //}

        public void DeleteRoom(object dataContext)
        {
            if (dataContext.GetType() == typeof(RoomViewModel))
            {
                m_Rooms.Remove((RoomViewModel)dataContext);
                NotifyOfPropertyChange(() => Rooms);
            }
        }
Ejemplo n.º 27
0
        public bool DeleteUkodById(int id)
        {
            BindableCollection <UkodModel> adatok = GetAllUkod();
            UkodModel model   = adatok.Where(x => x.Id == id).First();
            bool      success = adatok.Remove(model);

            WriteXml(adatok);
            return(success);
        }
Ejemplo n.º 28
0
        public void SelectPhotos()
        {
            var list = Photos.ToList().Where(p => p.IsChecked == false);

            foreach (var photo in list)
            {
                Photos.Remove(photo);
            }
        }
Ejemplo n.º 29
0
 public void Remove()
 {
     if (SelectedRunnerSpec == null)
     {
         return;
     }
     _runnerSpecRepo.Delete(SelectedRunnerSpec.Instance);
     RunnerSpecs.Remove(SelectedRunnerSpec);
 }
Ejemplo n.º 30
0
 public void DeleteAddress(object dataContext)
 {
     if (dataContext.GetType() == typeof(AddressViewModel))
     {
         var addressViewModel = (AddressViewModel)dataContext;
         m_Addresses.Remove(addressViewModel);
         m_Repository.Addresses.Remove(addressViewModel.Model);
     }
 }
Ejemplo n.º 31
0
 public void Remove()
 {
     if (SelectedConsole == null)
     {
         return;
     }
     _repo.Delete(SelectedConsole.Instance);
     Consoles.Remove(SelectedConsole);
 }
Ejemplo n.º 32
0
        public void when_Remove_is_called_then_Remove_event_is_fired()
        {
            var testSchedulerProvider = new TestDispatcherSchedulerProvider();

            var result = false;

            var bindableCollection = new BindableCollection<Guid>(testSchedulerProvider);

            var newGuid = Guid.NewGuid();

            bindableCollection.Add(newGuid);

            bindableCollection.CollectionChanged += (sender, args) =>
                                                    {
                                                        if (args.Action == NotifyCollectionChangedAction.Remove)
                                                        {
                                                            result = true;
                                                        }
                                                    };

            bindableCollection.Remove(newGuid);

            Assert.That(result, Is.True);
        }
Ejemplo n.º 33
0
        public void RemoveItemRaisesCollectionChangingBeforeRemovingItem()
        {
            var element = new Element();
            var collection = new BindableCollection<Element>() { element };

            // We assert elsewhere that this is raised
            collection.CollectionChanging += (o, e) =>
            {
                Assert.AreEqual(1, collection.Count);

                Assert.AreEqual(NotifyCollectionChangedAction.Remove, e.Action);
                Assert.That(e.OldItems, Is.EquivalentTo(new[] { element }));
                Assert.AreEqual(0, e.OldStartingIndex);
            };

            collection.Remove(element);
        }