public void OnSelectedCProgramChanged() { if (SelectedCProgram != null) { _selectedCProgramWatcher = new ChangeNotificationWrapper(SelectedCProgram); _selectedCProgramWatcher.PropertyChanged += OnSelectedCProgramPropertyChanged; ListCollectionView list = (ListCollectionView)FreeThreads; list.Filter = new Predicate <object>(x => (!((int?)x).HasValue || ThreadCPrograms.FirstOrDefault(c => c.ThreadID == (int?)x) == null) && (int?)x != SelectedCProgram.ThreadID); list.Refresh(); var ftb = new StringBuilder(); foreach (int?ft in list) { ftb.Append(Convert.ToString(ft)); ftb.Append(" "); } LogTo.Info("Editing C program: {0}, free threads: {1}", SelectedCProgram.FileName, ftb.ToString()); } }
public void OnSelectedCProgramPropertyChanged(object sender, PropertyChangedEventArgs e) { ThreadCProgram cp = sender as ThreadCProgram; if (cp == null) { return; } if (e.PropertyName == "ThreadID") { ListCollectionView list = (ListCollectionView)FreeThreads; //this always returns 'null' (for no thread id) plus the unused ids //list.Filter = new Predicate<object>(x => !((int?)x).HasValue || ThreadCPrograms.FirstOrDefault(c=>c.ThreadID == (int?)x) == null || (int?)x==SelectedCProgram.ThreadID); list.Filter = new Predicate <object>(x => (!((int?)x).HasValue || ThreadCPrograms.FirstOrDefault(c => c.ThreadID == (int?)x) == null) && (int?)x != SelectedCProgram.ThreadID); list.Refresh(); ViewModelCommandManager.InvalidateCommands(true); } }