public void TestSmoke() { int changeCount = 0; ObservableCollectionWatcher <Sample> watcher = new ObservableCollectionWatcher <Sample>(() => changeCount++); ObservableCollection <Sample> collection = new ObservableCollection <Sample>(); watcher.SetCollection(collection); Assert.That(changeCount, Is.EqualTo(0)); Sample sample1 = new Sample(); collection.Add(sample1); Assert.That(changeCount, Is.EqualTo(0)); Sample sample2 = new Sample(); collection.Add(sample2); Assert.That(changeCount, Is.EqualTo(0)); sample1.FirePropertyChanged(); Assert.That(changeCount, Is.EqualTo(1)); sample2.FirePropertyChanged(); Assert.That(changeCount, Is.EqualTo(2)); collection.Remove(sample1); sample1.FirePropertyChanged(); Assert.That(changeCount, Is.EqualTo(2)); Sample sample3 = new Sample(); collection[0] = sample3; Assert.That(changeCount, Is.EqualTo(2)); sample1.FirePropertyChanged(); sample2.FirePropertyChanged(); Assert.That(changeCount, Is.EqualTo(2)); sample3.FirePropertyChanged(); Assert.That(changeCount, Is.EqualTo(3)); watcher.SetCollection(null); Assert.That(changeCount, Is.EqualTo(3)); }
public DockerContainerListView() { XamlReader.Load(this); //todo: workaround for bug in Eto.Forms (probably related to https://github.com/picoe/Eto/issues/515) containersCollectionWatcher = new ObservableCollectionWatcher <DockerContainerViewModel>(ContainersGridView.Invalidate); DataContextChanged += (sender, args) => { DockerContainerListViewModel viewModel = DataContext as DockerContainerListViewModel; containersCollectionWatcher.SetCollection(viewModel?.Containers); }; IdCell.Binding = Binding.Property <DockerContainerViewModel, string>(c => c.Id); ImageCell.Binding = Binding.Property <DockerContainerViewModel, string>(c => c.Image); ImageIdCell.Binding = Binding.Property <DockerContainerViewModel, string>(c => c.ImageId); CreatedCell.Binding = Binding.Property <DockerContainerViewModel, string>(c => c.Created); StateCell.Binding = Binding.Property <DockerContainerViewModel, string>(c => c.State); ContainersGridView.SelectionChanged += ContainersGridViewOnSelectionChanged; }
public DockerImageListView() { XamlReader.Load(this); //todo: workaround for bug in Eto.Forms (probably related to https://github.com/picoe/Eto/issues/515) containersCollectionWatcher = new ObservableCollectionWatcher <DockerImageViewModel>(ImagesGridView.Invalidate); DataContextChanged += (sender, args) => { DockerImageListViewModel viewModel = DataContext as DockerImageListViewModel; containersCollectionWatcher.SetCollection(viewModel?.Images); }; IdCell.Binding = Binding.Property <DockerImageViewModel, string>(c => c.Id); RepoTagsCell.Binding = Binding.Property <DockerImageViewModel, string>(c => c.RepoTagsAsText); RepoDigestsCell.Binding = Binding.Property <DockerImageViewModel, string>(c => c.RepoDigestsAsText); CreatedCell.Binding = Binding.Property <DockerImageViewModel, string>(c => c.CreatedAsText); SizeCell.Binding = Binding.Property <DockerImageViewModel, string>(c => c.SizeAsText); VirtualSizeCell.Binding = Binding.Property <DockerImageViewModel, string>(c => c.VirtualSizeAsText); ImagesGridView.SelectionChanged += ImagesGridViewOnSelectionChanged; }