// Reset theEpisode searching threshold to the amount specified below; private void ResetSliderSetEpisodeMaxRange_Click(object sender, RoutedEventArgs e) { // As a side effect, this will invoke the above ValueChanged method which sets the state and provides feedback this.SliderSetEpisodeMaxRange.Value = Constant.EpisodeDefaults.DefaultRangeToSearch; Episodes.Reset(); }
private async Task <bool> PopulateAsync() { return(await Task.Run(() => { string dataLabelToUpdate = this.dataLabelByLabel[this.dataFieldLabel]; this.TotalImages = this.fileDatabase.CountAllCurrentlySelectedFiles; int percentDone = 0; ObservableCollection <KeyValuePair <string, string> > keyValueList = new ObservableCollection <KeyValuePair <string, string> >(); List <ColumnTuplesWithWhere> imagesToUpdate = new List <ColumnTuplesWithWhere>(); //for (int imageIndex = 0; imageIndex < totalImages; ++imageIndex) int imageIndex = 0; string singletonData; while (imageIndex < TotalImages) { Episodes.Reset(); Episodes.EpisodeGetEpisodesInRange(this.fileDatabase.FileTable, imageIndex, Int32.MaxValue); // Provide feedback if the operation was cancelled during the database update if (Token.IsCancellationRequested == true) { keyValueList.Clear(); keyValueList.Add(new KeyValuePair <string, string>("Cancelled", "No changes were made")); return false; } // Provide feedback to the busy indicator every now and then if (this.ReadyToRefresh()) { percentDone = Convert.ToInt32(imageIndex / TotalImages * 100.0); this.Progress.Report(new ProgressBarArguments(percentDone, String.Format("Processing {0}/{1} images. ", imageIndex, TotalImages), true, false)); Thread.Sleep(Constant.ThrottleValues.RenderingBackoffTime); // Allows the UI thread to update every now and then } // Distinguish between single files vs and episode of files if (Episodes.EpisodesDictionary.Count <= 1) { if (this.SingletonAsSingle) { singletonData = "Single"; } else if (this.SingletonAsZero) { singletonData = "0:1|1"; } else { this.EpisodeCount++; singletonData = String.Format("{0}1|1", this.IncludeAnEpisodeIDNumber ? this.EpisodeCount + ":" : String.Empty); } List <ColumnTuple> ctl = new List <ColumnTuple>() { new ColumnTuple(this.dataLabelByLabel[this.dataFieldLabel], singletonData) }; imagesToUpdate.Add(new ColumnTuplesWithWhere(ctl, this.fileDatabase.FileTable[imageIndex].ID)); this.SingleCount++; imageIndex++; } else { this.EpisodeCount++; this.EpisodeNoSingletonsCount++; foreach (KeyValuePair <int, Tuple <int, int> > episode in Episodes.EpisodesDictionary) { List <ColumnTuple> ctl = new List <ColumnTuple>() { new ColumnTuple(this.dataLabelByLabel[this.dataFieldLabel], String.Format("{0}{1}|{2}", this.IncludeAnEpisodeIDNumber ? this.EpisodeCount + ":" : String.Empty, episode.Value.Item1, episode.Value.Item2)) }; imagesToUpdate.Add(new ColumnTuplesWithWhere(ctl, this.fileDatabase.FileTable[imageIndex].ID)); imageIndex++; } } } this.IsAnyDataUpdated = true; this.Progress.Report(new ProgressBarArguments(100, String.Format("Writing Episode data for {0} files. Please wait...", TotalImages), false, true)); Thread.Sleep(Constant.ThrottleValues.RenderingBackoffTime); // Allows the UI thread to update every now and then this.fileDatabase.UpdateFiles(imagesToUpdate); return true;//keyValueList; }, this.Token).ConfigureAwait(true)); }
private void SliderSetEpisodeMaxRange_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { this.timelapseState.EpisodeMaxRangeToSearch = Convert.ToInt32(this.SliderSetEpisodeMaxRange.Value); this.SetSliderSetEpisodeMaxRangeFeedack(this.timelapseState.EpisodeMaxRangeToSearch); Episodes.Reset(); }