private void UpdateItems() { var items = new List <FileViewModel>(); var files = new List <string>(_bundle.GetFiles(GetSelectedFolderPath())); Progress.Label = "Reading"; Progress.Reset(files.Count); Progress.IsEnabled = true; var s = Stopwatch.StartNew(); foreach (var vm in _bundle.GetFileViewModels(GetSelectedFolderPath())) { var delegateVm = vm; vm.OpenItemCommand = new DelegateCommand(() => OpenItem(delegateVm)); items.Add(vm); Progress.Current++; } s.Stop(); Debug.WriteLine(s.ElapsedMilliseconds + "ms to scan " + items.Count + " files"); items.Sort((l, r) => SortFunctions.NumericStringCaseInsensitiveCompare(l.Name, r.Name)); _backgroundWorkerService.InvokeOnUiThread(() => { Progress.IsEnabled = false; Items = items; OnPropertyChanged(() => Items); }); }
public void TestNumericStringCaseInsensitiveCompare(string left, string right, int expected) { int result = SortFunctions.NumericStringCaseInsensitiveCompare(left, right); if (expected == 0) { Assert.That(result, Is.EqualTo(0), "expected equal strings"); } else if (expected < 0) { Assert.That(result, Is.LessThan(0), "expected left first"); } else { Assert.That(result, Is.GreaterThan(0), "expected right first"); } }