private void HandleReset() { _copy.ForEach(a => HandleElement(NotifyCollectionChangedAction.Remove, a)); _collection.ForEach(a => HandleElement(NotifyCollectionChangedAction.Add, a)); _copy.Clear(); _copy.AddRange(_collection); }
public void UpdateTimeline() { timeLine.Clear(); foreach (Show show in shows) { Season latestSeason = show.Seasons[show.Seasons.Count - 1]; List <Episode> futureEpisodes = latestSeason.Episodes.Where(w => w.AirDate != null && w.AirDate >= DateTime.Today) .OrderBy(w => w.AirDate) .ToList(); foreach (Episode episode in futureEpisodes) { if (timeLine.Any(w => w.Episode == episode)) { continue; } timeLine.Add(new TimeLineItem { Show = show, Episode = episode }); } } }
private static void FillUiWithImportedTest(BindableCollection <ResourcePropertyModel> testProperties4Debug, PropertyBag test) { if (test == null) { return; } var defaultType = string.Empty; if (test.HasProperty(Constants.Type)) { defaultType = test.GetProperty <string>(Constants.Type); System.Diagnostics.Trace.TraceInformation("----- FillUiWithImportedTest: defaultType = {0}\n", defaultType); } testProperties4Debug.Clear(); int i = 1; foreach ( var prop in test.GetAllProperties() .SelectMany(p => GetResourcePropertyModel(test, p, defaultType)) .OrderBy(m => m.ResourceType)) { if (prop.Key != Constants.Type) { System.Diagnostics.Trace.TraceInformation("----- FillUiWithImportedTest: {0} {1} = {2}", i++, prop.Key, prop.Value); testProperties4Debug.Add(prop); } } }
private void Initialise() { RunnerSpecs.Clear(); var specs = _runnerSpecRepo.Specs; RunnerSpecs.AddRange(specs.Select(x => new RunnerSpecViewModel(x))); }
private void RefreshHistory() { _historyItems.Clear(); if (_undoRedoManager != null) { _historyItems.Add(new HistoryItemViewModel("Initial State", (_undoRedoManager.UndoStack.Any() ? HistoryItemType.InitialState : HistoryItemType.Current))); for (int i = 0; i < _undoRedoManager.UndoStack.Count; i++) { _historyItems.Add(new HistoryItemViewModel(_undoRedoManager.UndoStack[i], (i == _undoRedoManager.UndoStack.Count - 1) ? HistoryItemType.Current : HistoryItemType.Undo)); } for (int i = _undoRedoManager.RedoStack.Count - 1; i >= 0; i--) { _historyItems.Add(new HistoryItemViewModel( _undoRedoManager.RedoStack[i], HistoryItemType.Redo)); } } if (!_internallyTriggeredChange) { UpdateSelectedIndexOnly(_historyItems.Count); } }
public void ClearItemsUsesDispatcherToRaiseEvents() { var collection = new BindableCollection <Element>() { new Element() }; bool propertyChangedRaised = false; ((INotifyPropertyChanged)collection).PropertyChanged += (o, e) => propertyChangedRaised = true; bool collectionChangingRaised = false; collection.CollectionChanging += (o, e) => collectionChangingRaised = true; bool collectionChangedRaised = false; collection.CollectionChanged += (o, e) => collectionChangedRaised = true; var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Clear(); Assert.False(propertyChangedRaised); Assert.False(collectionChangingRaised); Assert.False(collectionChangedRaised); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.True(propertyChangedRaised); Assert.True(collectionChangingRaised); Assert.True(collectionChangedRaised); }
private void OnSelectedPixelChanged(object sender, PixelChangedEventArgs e) { FrameNumber = _selectionService.SelectedFrame.Number; PixelLocation = e.SelectedPixel; HasSelectedPixel = true; _pixelEvents.Clear(); var swapChainPresenter = new WpfSwapChainPresenter(Dispatcher.CurrentDispatcher); var replayer = new Replayer( _selectionService.SelectedFrame.Model, _selectionService.SelectedEvent.Model, swapChainPresenter, _selectionService.SelectedFrame.ActiveRenderTargetViewIdentifier, _selectionService.SelectedFrame.ActiveRenderTargetArraySlice, e.SelectedPixel.X, e.SelectedPixel.Y); Task.Factory.StartNew(() => { replayer.Replay(); var events = replayer.Logger.GetPixelHistoryEvents(_selectionService.SelectedFrame.Number); _pixelEvents.AddRange(events.Select(x => new PixelHistoryEventViewModel(x))); FinalFrameBufferColor = ((ColorResultViewModel)_pixelEvents.Last(x => x.Result is ColorResultViewModel).Result).Result; }); }
private void RefreshMessages() { var messageInfos = _queueService.GetMessageInfos(_messageQueue); Messages.Clear(); Messages.AddRange(messageInfos.Select(info => new MessageGridRowViewModel(info))); }
public void LoadSessions(Visitor visitor) { if (visitor == null) { return; } _currentVisitor = visitor; var sessions = _esClinicContext.Sessions.Where(p => p.PatientId == _currentVisitor.PatientId).ToList(); Sessions.Clear(); foreach (var session in sessions) { if (session.Stage == ClinicStage.OnExamining) { session.Stage = ClinicStage.Paused; } Sessions.Add(session); } CanNewSession = true; _isSessionCreated = false; PatientInfo = visitor.Patient.Name + " - " + visitor.Patient.Sex; }
public void RefreshPath() { staticTimer.start("Total"); if (System.IO.Directory.Exists(reportsPath)) { reader = new ReportReader(reportsPath); if (reader.UnprocessedReports.Count != 0) { pathFeedback = $"Some report folders were names incorrectly ({reader.UnprocessedReports[0].GetReportDirectory()})"; } else { pathFeedback = ""; } NotifyOfPropertyChange(() => pathFeedback); actions.Clear(); foreach (string action in reader.GetActionList()) { actions.Add(action); } NotifyOfPropertyChange(() => actions); NotifyOfPropertyChange(() => reportsPath); } staticTimer.stop("Total"); staticTimer.log("Total"); }
public WatchesViewModel(IEventAggregator eventAggregator) { Watches = new BindableCollection <WatchViewModel>(); eventAggregator.Subscribe(this); messages = new Dictionary <string, object>(); ThreadPool.QueueUserWorkItem(x => { while (true) { if (clearWatches) { clearWatches = false; Watches.Clear(); } foreach (var message in messages) { AddWatch(message.Key, message.Value); } Thread.Sleep(20); } }); Title = "Watch"; IconName = "watch-16.png"; }
private void LoadShows() { shows.Clear(); var userSettings = pm.Retrieve <UserSettings>("index"); if (userSettings == null) { return; } if (userSettings.Shows == null) { return; } foreach (Show show in userSettings.Shows) { if (show.Seasons.Count > 0) { show.SelectedSeason = show.Seasons[show.Seasons.Count - 1]; } shows.Add(show); ImageHelper.LoadDefaultImages(show); ImageHelper.GetShowImage(show); ImageHelper.GetEpisodeImages(show); } UpdateTimeline(); UpdateBacklog(); }
public void newScores() { _turnScores.Clear(); foreach (Player player in this.endTurn.HumanPlayers) { dynamic dynamicScore = new System.Dynamic.ExpandoObject(); dynamicScore.position = 0; dynamicScore.name = player.Username; dynamicScore.score = player.score.scoreTurn; _turnScores.Add(dynamicScore); } _turnScores = new BindableCollection <dynamic>(_turnScores.OrderByDescending(i => i.score)); int rank = 1; foreach (dynamic score in _turnScores) { score.position = rank + "."; score.score = ": +" + score.score + " points"; rank++; } // _turnScores = new BindableCollection<dynamic>(_turnScores.OrderBy(i => i.position)); turnScores.Refresh(); NotifyOfPropertyChange(() => turnScores); }
public override void ClearAll() { Events.Clear(); _physicalQueryPlanRows.Clear(); _logicalQueryPlanRows.Clear(); NotifyOfPropertyChange(() => PhysicalQueryPlanRows); NotifyOfPropertyChange(() => LogicalQueryPlanRows); }
private void OnSelectedFrameChanged(object sender, TracefileFrameChangedEventArgs e) { _events.Clear(); if (e.TracefileFrameViewModel != null) { _events.AddRange(e.TracefileFrameViewModel.Events); } }
private void UpdatePeople() { People.Clear(); foreach (var person in _addressBookManager.GetAllPeople()) { People.Add(person); } }
private void LoadData() { m_Container.Clear(); m_Maps.Clear(); LoadContainer(); LoadMaps(); }
public void LoadJson(string data) { List <QueryEvent> qe = JsonConvert.DeserializeObject <List <QueryEvent> >(data); _queryEvents.Clear(); _queryEvents.AddRange(qe); NotifyOfPropertyChange(() => QueryEvents); }
protected override void OnDeactivate(bool close) { items.OfType <IDeactivate>().Apply(x => x.Deactivate(close)); if (close) { items.Clear(); } }
private void LoadData() { m_Measures.Clear(); m_ConsumerGroups.Clear(); ((INotifyPropertyChanged)m_ConsumerGroups).PropertyChanged += CGPropertyshavechanged; LoadConsumerGroups(); LoadMeasures(); }
private void LoadConsumers() { m_Consumers.Clear(); m_Repository.Consumers.CollectionChanged += AlterConsumerCollection; foreach (var consumer in m_Repository.Consumers) { m_Consumers.Add(CreateConsumerViewModel(consumer)); } }
private void LoadDistributors() { m_Distributors.Clear(); m_Repository.Distributors.CollectionChanged += AlterDistributorCollection; foreach (var distributor in m_Repository.Distributors) { m_Distributors.Add(CreateDistributorViewModel(distributor)); } }
/// <inheritdoc /> /// <summary> /// Pushes an action to the <see cref="P:ModernApplicationFramework.Basics.UndoRedoManager.UndoRedoManager.UndoStack" /> and /// clears the <see cref="P:ModernApplicationFramework.Basics.UndoRedoManager.UndoRedoManager.RedoStack" /> if this method was executed outside of the manager /// </summary> /// <param name="action">The action that was performed and pushed to the <see cref="P:ModernApplicationFramework.Basics.UndoRedoManager.UndoRedoManager.UndoStack" /></param> public void Push(UndoRedoAction action) { Push(_undoStack, action); if (!_isChanging) { _redoStack.Clear(); } }
protected override void OnViewReady(object view) { _checkups.Clear(); using (var db = new OPContext()) { _checkups.AddRange(db.Checkups.Include("Patient") .Where(c => c.DoctorId == _loginViewModel.Account.Id).ToList()); } }
private void LogAction(string s, LogLevel logLevel, object arg3) { if (logMessages.Count > 500) { logMessages.Clear(); } // this.logMessages.Add(new LogMessageModel(s, logLevel, DateTime.Now)); }
private void LoadRooms() { m_Rooms.Clear(); //m_Repository.Rooms.CollectionChanged += AlterRoomCollection; foreach (var room in m_Repository.Rooms) { m_Rooms.Add(new RoomViewModel(room, m_Repository)); } }
private void LoadData() { m_Rooms.Clear(); m_Addresses.Clear(); m_Buildings.Clear(); LoadBuildings(); LoadAddresses(); LoadRooms(); }
private void LoadData() { m_Rooms.Clear(); m_Inventories.Clear(); m_InventoryTypes.Clear(); LoadInventories(); LoadInventoryTypes(); LoadRooms(); }
/// <summary> /// Initializes a new instance of the <see cref="TransactionDetailsViewModel"/> class. /// </summary> /// <param name="validator">Validator for view model data.</param> /// <param name="accountsVM">Accounts view model.</param> /// <param name="categoriesVM">Categories view model.</param> public TransactionDetailsViewModel(IValidator validator, IAccountsViewModel accountsVM, ICategoriesViewModel categoriesVM) : base(validator) { this.accountsVM = accountsVM; this.categoriesVM = categoriesVM; var accounts = new BindableCollection <AccountDTO>(); accountsCollectionViewSource.Source = accounts; this.accountsVM.Reloaded += (sender, args) => { accounts.Clear(); foreach (var account in this.accountsVM.Accounts) { accounts.Add(account as AccountDTO); } if (!accountsCollectionViewSource.View.IsEmpty) { accountsCollectionViewSource.View.MoveCurrentToFirst(); } }; var categories = new BindableCollection <CategoryDTO>(); categoriesCollectionViewSource.Source = categories; this.categoriesVM.Reloaded += (sender, args) => { categories.Clear(); categories.AddRange(this.categoriesVM.Categories); if (!categoriesCollectionViewSource.View.IsEmpty) { categoriesCollectionViewSource.View.MoveCurrentToFirst(); } }; categoryFilter = (search, item) => { if (string.IsNullOrEmpty(search)) { return(true); } if (item is CategoryDTO) { string searchToLower = search.ToLower(CultureInfo.InvariantCulture); return((item as CategoryDTO).Name.ToLower(CultureInfo.InvariantCulture).Contains(searchToLower)); } return(false); }; }
private void LoadInvestmentPlans() { m_InvestmentPlanViewModels.Clear(); m_Repository.InvestmentPlans.CollectionChanged += AlterInvestmentPlanCollection; foreach (var investmentPlan in m_Repository.InvestmentPlans) { CreateInvestmentPlanViewModel(investmentPlan); } NotifyOfPropertyChange(() => FilteredInvestmentPlans); }
/// <summary> /// button evet click handler, handles Diagnozy synchronization /// </summary> public void SynchronizeDiagnozy() { ambulanceDiagonzies = new BindableCollection<Cis_Diagnoza>(); AmbulanceSynchronizationDomainContext ambulance = _serviceLocator.GetInstance<AmbulanceSynchronizationDomainContext>(); EntityQuery<Cis_Diagnoza> query = ambulance.GetCis_DiagnozaQuery(); EntityQuery<Diagnozy> query2 = _laboratoryDomainContext.GetAllDiagnoziesQuery(); List<IResult> results = new List<IResult>(); results.Add(Show.Busy()); LoadData<Cis_Diagnoza> loadResult = new LoadData<Cis_Diagnoza>(ambulance,query,LoadBehavior.RefreshCurrent,(sender) => { ambulanceDiagonzies.Clear(); ambulanceDiagonzies.AddRange(((LoadOperation<Cis_Diagnoza>)sender).Entities); } ); LoadData<Diagnozy> loadResult2 = new LoadData<Diagnozy>(_laboratoryDomainContext, query2, LoadBehavior.RefreshCurrent, (sender) => { laboratoryDiagnozy.Clear(); laboratoryDiagnozy.AddRange(((LoadOperation<Diagnozy>)sender).Entities); bool found = false; foreach (var item in ambulanceDiagonzies) { for (int i = 0; i < laboratoryDiagnozy.Count; i++) { found = false; if (item.Nazov == laboratoryDiagnozy[i].nazov && item.Poznamka == laboratoryDiagnozy[i].popis) { laboratoryDiagnozy.RemoveAt(i); found = true; break; } } if (found == false) { Diagnozy novaDiagnoza = new Diagnozy(); novaDiagnoza.nazov = item.Nazov; novaDiagnoza.popis = item.Poznamka; _laboratoryDomainContext.Diagnozies.Add(novaDiagnoza); } } _laboratoryDomainContext.SubmitChanges(); Coroutine.BeginExecuteFor(Show.NotBusy(), this); } ); results.Add(loadResult); results.Add(loadResult2); Coroutine.BeginExecuteFor(results, this); }
public void getHerdAgentList(ref BindableCollection <HerdAgentViewModel> outHerdAgentList, int timeoutSeconds= 10) { lock (m_listLock) { outHerdAgentList.Clear(); foreach (var agent in m_herdAgentList) if (System.DateTime.Now.Subtract(agent.Value.lastACK).TotalSeconds < timeoutSeconds) outHerdAgentList.Add(agent.Value); } }
public void when_Clear_is_called_then_Reset_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.Reset) { result = true; } }; bindableCollection.Clear(); Assert.That(result, Is.True); }
public void ClearItemsUsesDispatcherToClearItems() { var collection = new BindableCollection<Element>() { new Element() }; var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Clear(); Assert.AreEqual(1, collection.Count); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.AreEqual(0, collection.Count); }
/// <summary> /// button evet click handler, handles Poistovne synchronization /// </summary> public void SynchronizePoistovne() { ambulancePoistovne = new BindableCollection<Cis_Poistovne>(); AmbulanceSynchronizationDomainContext ambulance = _serviceLocator.GetInstance<AmbulanceSynchronizationDomainContext>(); EntityQuery<Cis_Poistovne> query = ambulance.GetCis_PoistovneQuery(); EntityQuery<Poistovne> query2 = _laboratoryDomainContext.GetAllPoistovneQuery(); List<IResult> results = new List<IResult>(); results.Add(Show.Busy()); LoadData<Cis_Poistovne> loadResult = new LoadData<Cis_Poistovne>(ambulance, query, LoadBehavior.RefreshCurrent, (sender) => { ambulancePoistovne.Clear(); ambulancePoistovne.AddRange(((LoadOperation<Cis_Poistovne>)sender).Entities); } ); LoadData<Poistovne> loadResult2 = new LoadData<Poistovne>(_laboratoryDomainContext, query2, LoadBehavior.RefreshCurrent, (sender) => { laboratoryPoistovne.Clear(); laboratoryPoistovne.AddRange(((LoadOperation<Poistovne>)sender).Entities); bool found = false; foreach (var item in ambulancePoistovne) { for (int i = 0; i < laboratoryPoistovne.Count; i++) { found = false; if (item.Nazov == laboratoryPoistovne[i].nazov) { laboratoryPoistovne.RemoveAt(i); found = true; break; } } if (found == false) { Poistovne novaPoistovna = new Poistovne(); novaPoistovna.nazov = item.Nazov; _laboratoryDomainContext.Poistovnes.Add(novaPoistovna); } } _laboratoryDomainContext.SubmitChanges(); Coroutine.BeginExecuteFor(Show.NotBusy(), this); } ); results.Add(loadResult); results.Add(loadResult2); Coroutine.BeginExecuteFor(results, this); }
/// <summary> /// button evet click handler, handles Lieky synchronization /// </summary> public void SynchronizeLieky() { ambulanceLieky = new BindableCollection<Cis_Lieky>(); AmbulanceSynchronizationDomainContext ambulance = _serviceLocator.GetInstance<AmbulanceSynchronizationDomainContext>(); EntityQuery<Cis_Lieky> query = ambulance.GetCis_LiekyQuery(); EntityQuery<Lieky> query2 = _laboratoryDomainContext.GetAllLiekiesQuery(); List<IResult> results = new List<IResult>(); results.Add(Show.Busy()); LoadData<Cis_Lieky> loadResult = new LoadData<Cis_Lieky>(ambulance, query, LoadBehavior.RefreshCurrent, (sender) => { ambulanceLieky.Clear(); ambulanceLieky.AddRange(((LoadOperation<Cis_Lieky>)sender).Entities); } ); LoadData<Lieky> loadResult2 = new LoadData<Lieky>(_laboratoryDomainContext, query2, LoadBehavior.RefreshCurrent, (sender) => { laboratoryLieky.Clear(); laboratoryLieky.AddRange(((LoadOperation<Lieky>)sender).Entities); bool found = false; foreach (var item in ambulanceLieky) { for (int i = 0; i < laboratoryLieky.Count; i++) { found = false; if (item.Nazov == laboratoryLieky[i].nazov && item.Kod == laboratoryLieky[i].kod) { laboratoryLieky.RemoveAt(i); found = true; break; } } if (found == false) { Lieky novyLiek = new Lieky(); novyLiek.nazov = item.Nazov; novyLiek.kod = item.Kod; _laboratoryDomainContext.Liekies.Add(novyLiek); } } _laboratoryDomainContext.SubmitChanges(); Coroutine.BeginExecuteFor(Show.NotBusy(), this); } ); results.Add(loadResult); results.Add(loadResult2); Coroutine.BeginExecuteFor(results, this); }
public void ClearItemsRaisesCollectionChangingBeforeClearingItems() { var collection = new BindableCollection<Element>() { new Element() }; // We assert elsewhere that this event is raised collection.CollectionChanging += (o, e) => { Assert.AreEqual(1, collection.Count); Assert.AreEqual(NotifyCollectionChangedAction.Reset, e.Action); }; collection.Clear(); }
public void ClearItemsUsesDispatcherToRaiseEvents() { var collection = new BindableCollection<Element>() { new Element() }; bool propertyChangedRaised = false; ((INotifyPropertyChanged)collection).PropertyChanged += (o, e) => propertyChangedRaised = true; bool collectionChangingRaised = false; collection.CollectionChanging += (o, e) => collectionChangingRaised = true; bool collectionChangedRaised = false; collection.CollectionChanged += (o, e) => collectionChangedRaised = true; var dispatcher = new TestDispatcher(); Execute.Dispatcher = dispatcher; collection.Clear(); Assert.False(propertyChangedRaised); Assert.False(collectionChangingRaised); Assert.False(collectionChangedRaised); Assert.NotNull(dispatcher.SendAction); dispatcher.SendAction(); Assert.True(propertyChangedRaised); Assert.True(collectionChangingRaised); Assert.True(collectionChangedRaised); }