public HistoryListPage() { this.InitializeComponent(); HistoryCollectionBind = new CollectionBind <DownloadHistory, DownloadHistoryViewModel>( Core.Histories, VMCollection, (history) => new DownloadHistoryViewModel(history), (history, historyVm) => history == historyVm.OriginalHistory); }
public TaskList() { InitializeComponent(); DownloaderCollectionBind = new CollectionBind <AbstractDownloader, DownloaderBar>( Core.Downloaders, DownloaderBars, (downloader) => { var newBar = new DownloaderBar(); newBar.BindDownloader(downloader); newBar.PointerPressed += VM_Clicked; newBar.Height = 72; return(newBar); }, (downloader, downloaderBar) => downloaderBar.Downloader == downloader); }
public void TestBaseOperations() { var testSrc1 = new TestObservableCollection <int>(); var testDest1 = new Collection <int>(); var testSrc2 = new TestObservableCollection <int>(); var testDest2 = new Collection <int>(); Func <int, int> caster = src => src; Func <int, int, bool> comparer = (src, dest) => dest == caster(src); var bind1 = new CollectionBind <int, int>( testSrc1, testDest1, caster, comparer); var bind2 = new CollectionBind <int, int>( testSrc2, testDest2, caster, comparer); bind1.IsEnabled = true; bind2.IsEnabled = true; int batches = 100; for (int batch = 0; batch < batches; ++batch) { bind1.IsEnabled = bind2.IsEnabled = (batch % 4 != 0); for (int i = 0; i < 100; ++i) { TestAdd(testSrc1, testSrc2); } for (int i = 0; i < 120; ++i) { TestRemove(testSrc1, testSrc2); } TestClear(testSrc1, testSrc2); bind1.IsEnabled = bind2.IsEnabled = true; Assert.IsTrue(CompareCollection(testSrc1, testDest1)); Assert.IsTrue(CompareCollection(testSrc2, testDest2)); Assert.IsTrue(CompareCollection(testDest1, testDest2)); Assert.AreEqual(testSrc1.Count, testDest1.Count); Assert.AreEqual(testSrc2.Count, testDest2.Count); Assert.AreEqual(testDest1.Count, testDest2.Count); } }