private void HighlightDelta(bool isOn) { // Mark if the raw file descriptor belongs to Delta, based on processed file list matching criteria: bool hasCorrespondent; foreach (FileDescriptorModel fd1 in MyRawFolderListing.FileList) { fd1.BelongsToDelta = false; if (!isOn) { continue; } // For each qualified raw file descriptor if (!fd1.IsQualified) { continue; } hasCorrespondent = false; foreach (FileDescriptorModel fd2 in MyProcessedFolderListing.FileList) { // For each qualified processed file descriptor if (!fd2.IsQualified) { continue; } if (fd2.Name.IndexOf(fd1.Name) != -1) { string raw_num_str = Regex.Match(fd1.Name, @"\d+").Value; string proc_num_str = Regex.Match(fd2.Name, @"\d+").Value; int raw_num = Int32.Parse(raw_num_str); int proc_num = Int32.Parse(proc_num_str); if (raw_num == proc_num) { hasCorrespondent = true; break; } } } if (hasCorrespondent == false) { fd1.BelongsToDelta = true; } } OnPropertyRaised("MyDeltaFilesNo"); MyRawGridView.Refresh(); }
public ShellViewModel(FolderListingModel pfl, FolderListingModel rfl) { MyProcessedFolderListing = pfl; MyRawFolderListing = rfl; ProcessedFolder = MyProcessedFolderListing.FolderPath; RawFolder = MyRawFolderListing.FolderPath; // Build observable collections of file descriptors in view model MyProcessedFolderFiles = new ObservableCollection <FileDescriptorModel>(); foreach (FileDescriptorModel fd in MyProcessedFolderListing.FileList) { MyProcessedFolderFiles.Add(fd); } MyRawFolderFiles = new ObservableCollection <FileDescriptorModel>(); foreach (FileDescriptorModel fd in MyRawFolderListing.FileList) { MyRawFolderFiles.Add(fd); } // Build Views of the above collections, which can then be filtered ListCollectionView MyProcessedFolderFilesView = new ListCollectionView(MyProcessedFolderFiles); MyProcessedFolderFilesView.Filter = new Predicate <object>(ProcessedQualifyFilter); MyProcessedGridView = MyProcessedFolderFilesView; MyProcessedGridView.MoveCurrentTo(null); ListCollectionView MyRawFolderFilesView = new ListCollectionView(MyRawFolderFiles); MyRawFolderFilesView.Filter = new Predicate <object>(RawQualifyFilter); MyRawGridView = MyRawFolderFilesView; MyRawGridView.MoveCurrentTo(null); // Initiate button commands SelectProcessedFolderCommand = new RelayCommand(SelectProcessedFolder); SelectRawFolderCommand = new RelayCommand(SelectRawFolder); RefreshProcessedFileListCommand = new RelayCommand(RefreshProcessedFileList); RefreshRawFileListCommand = new RelayCommand(RefreshRawFileList); RemoveProcessedItemCommand = new RelayCommand(RemoveProcessedItem, RemoveProcessedItemCanUse); RemoveRawItemCommand = new RelayCommand(RemoveRawItem, RemoveRawItemCanUse); GetDeltaCommand = new RelayCommand(GetDelta, GetDeltaCanUse); OpenSettingsCommand = new RelayCommand(OpenSettings); ProgramExitCommand = new RelayCommand(ProgramExit); ProgramHelpCommand = new RelayCommand(ProgramHelp); }
private void RefreshRawFileList(object arg) { MyRawFolderFiles.Clear(); MyRawFolderListing.RefreshFolderListing(); MyRawFolderListing.ReQualifyListedFiles(RSSettingsModel.Instance.RawExtensionSetting); foreach (FileDescriptorModel fd in MyRawFolderListing.FileList) { MyRawFolderFiles.Add(fd); } MyRawGridView.MoveCurrentTo(null); HighlightDelta(CheckHighlightDelta); OnPropertyRaised("MyRawFolderFilesNo"); OnPropertyRaised("MyRawFilesNo"); OnPropertyRaised("MyRawFilesShownNo"); }
private void RemoveRawItem(object arg) { if (arg != null && (int)arg > -1) { // MyRawFolderFiles.RemoveAt((int)arg); Can't do this... // In order for us to properly remove Collection item, we have to precisely know, // what item is at this index of View (View may be filtered, thus index will be different) // FileDescriptorModel fdv = MyRawGridView.Cast<FileDescriptorModel>().ToArray()[(int)arg]; Although it works, this seems too complicated FileDescriptorModel fdv = (FileDescriptorModel)MyRawGridView.CurrentItem; if (fdv != null) { MyRawFolderFiles.Remove(fdv); MyRawFolderListing.FileList.Remove(fdv); MyRawGridView.MoveCurrentTo(null); OnPropertyRaised("MyRawFolderFilesNo"); OnPropertyRaised("MyRawFilesNo"); OnPropertyRaised("MyRawFilesShownNo"); } } }