private void NextButton_Click(object sender, RoutedEventArgs e) { if (DatabaseGrid.Items == null || DatabaseGrid.Items.Count < 1) { return; } if (DatabaseGrid.SelectedIndex < DatabaseGrid.Items.Count - 1) { DatabaseGrid.SelectedIndex++; DatabaseGrid.ScrollIntoView(_vm.SelectedResult); } CheckNextPreviousEnabled(); }
private void ListPreviousButton_Click(object sender, RoutedEventArgs e) { if (DatabaseGrid.Items == null || DatabaseGrid.Items.Count < 1) { return; } if (DatabaseGrid.SelectedIndex > 0) { DatabaseGrid.SelectedIndex--; DatabaseGrid.ScrollIntoView(_vm.SelectedFin); } CheckNextPreviousEnabled(); }
public void RefreshDatabaseAfterAdd() { Trace.WriteLine("Start database refresh after add..."); _vm.Fins = new ObservableNotifiableCollection <DatabaseFin>( _vm.DarwinDatabase .GetAllFins() .Select(x => { x.ThumbnailFilename = x.ImageFilename; return(x); }) .ToList()); // Select the last fin, and scroll to it so the user can see it if (_vm.Fins != null) { Trace.WriteLine("Selecting added individual..."); _vm.SelectedFin = _vm.Fins[_vm.Fins.Count - 1]; DatabaseGrid.ScrollIntoView(_vm.SelectedFin); } Trace.WriteLine("Refresh complete."); }
private void SelectFirstFin() { if (DatabaseGrid.Items != null && DatabaseGrid.Items.Count > 0) { DatabaseGrid.SelectedIndex = 0; if (_vm.SelectedFin != null) { DatabaseGrid.ScrollIntoView(_vm.SelectedFin); } } else if (_vm.Fins?.Count > 0) { _vm.SelectedFin = _vm.Fins[0]; } else { _vm.SelectedFin = null; } }
private void AutoScrollTimer_Tick(object sender, EventArgs e) { if (_vm.AutoScroll && _vm.MatchResults?.Results?.Count > 0) { if (_vm.SelectedResult == null) { _vm.SelectedResult = _vm.MatchResults.Results[0]; } else { if (DatabaseGrid.SelectedIndex < DatabaseGrid.Items.Count - 1) { DatabaseGrid.SelectedIndex++; } else { DatabaseGrid.SelectedIndex = 0; } DatabaseGrid.ScrollIntoView(_vm.SelectedResult); CheckNextPreviousEnabled(); } } }
private void MatchWork(object sender, DoWorkEventArgs e) { if (_vm.MatchingQueue.Fins.Count < 1) { return; } bool done = false; _vm.MatchingQueue.MatchRunning = true; int currentIndex = 0; do { if (_matchingWorker.CancellationPending) { e.Cancel = true; done = true; _vm.MatchingQueue.MatchRunning = false; } else if (_vm.PauseMatching) { // Sleep for a small amount of time Thread.Sleep(100); } else { // TODO: Put this logic inside the MatchingQueue class? if (_vm.MatchingQueue.Matches.Count < currentIndex + 1) { switch (_vm.MatchingQueue.Database.CatalogScheme.FeatureSetType) { case Features.FeatureSetType.DorsalFin: _vm.MatchingQueue.Matches.Add(new Match( _vm.MatchingQueue.Fins[currentIndex], _vm.MatchingQueue.Database, null, _vm.MatchingQueue.RegistrationMethod, (_vm.MatchingQueue.RangeOfPoints == RangeOfPointsType.AllPoints) ? true : false)); break; case Features.FeatureSetType.Bear: _vm.MatchingQueue.Matches.Add(new Match( _vm.MatchingQueue.Fins[currentIndex], _vm.MatchingQueue.Database, null, null, true)); break; default: throw new NotImplementedException(); } // This needs to run on the UI thread since it affects dependency objects Dispatcher.BeginInvoke(new Action(() => { _vm.SelectedFin = _vm.MatchingQueue.Fins[currentIndex]; DatabaseGrid.ScrollIntoView(_vm.SelectedFin); }), DispatcherPriority.Background); } // Do Work float percentComplete = _vm.MatchingQueue.Matches[currentIndex].MatchSingleIndividual(_vm.MatchingQueue.Database.Categories.ToList()); int roundedProgress = (int)Math.Round(percentComplete * 100); _vm.CurrentUnknownPercent = roundedProgress; var totalProgress = (int)Math.Round(((float)currentIndex / _vm.MatchingQueue.Fins.Count + percentComplete / _vm.MatchingQueue.Fins.Count) * 100); _vm.QueueProgressPercent = totalProgress; _matchingWorker.ReportProgress(roundedProgress); if (percentComplete >= 1.0) { //***1.5 - sort the results here, ONCE, rather than as list is built _vm.MatchingQueue.Matches[currentIndex].MatchResults.Sort(); if (currentIndex >= _vm.MatchingQueue.Fins.Count - 1) { _vm.SaveMatchResults(); done = true; _vm.MatchingQueue.MatchRunning = false; } else { currentIndex++; } } } } while (!done); }