protected void RemoveItem() { var index = DisplayFileInfoList.IndexOf(SelectedFileInfo); FileInfoList.Remove(SelectedFileInfo); DisplayFileInfoList.Remove(SelectedFileInfo); //選択アイテムの更新 if (DisplayFileInfoList.Count == 0) { //表示対象がない index = -1; } else if (DisplayFileInfoList.Count <= index) { index = DisplayFileInfoList.Count - 1; } else { //何もしない } if (index >= 0) { DisplayFileInfoList.ElementAt(index).IsSelected = true; } //フィルタの更新 var missingKeywordList = new List <Extension>(); foreach (var item in ExtensionList) { missingKeywordList.Add(item); } missingKeywordList.RemoveAt(0); foreach (var item in DisplayFileInfoList) { var extension = Path.GetExtension(item.FilePath); var extensionItems = ExtensionList.Where(x => x.Name == extension); if (extensionItems.Any()) { foreach (var extItem in extensionItems) { missingKeywordList.Remove(extItem); } } } foreach (var item in missingKeywordList) { ExtensionList.Remove(item); } HasItem = FileInfoList.Any(); }
public void AddFileInfo(string[] pPathList) { foreach (string file in pPathList) { if (!File.Exists(file)) { if (Directory.Exists(file)) { DirectoryInfo dir = new DirectoryInfo(file); string[] names = dir.GetFiles().Select(u => u.FullName).ToArray(); string[] dirs = dir.GetDirectories().Select(u => u.FullName).ToArray(); AddFileInfo(names); AddFileInfo(dirs); } continue; } //중복 제거 foreach (FileDetail item in FileInfoList) { if ((item.FileDirectory + @"\" + item.FileName).ToUpper().Equals(file.ToUpper())) { FileInfoList.Remove(item); break; } } //파일 추가 FileDetail newFile = new FileDetail(file); if (newFile == null || newFile.Text.Length < 0) { continue; } this.FileInfoList.Add(newFile); OnPropertyChanged("TotalCount"); OnPropertyChanged("TotalSize"); OnPropertyChanged("TotalLengh"); OnPropertyChanged("TotalWords"); OnPropertyChanged("TotalCharacter"); OnPropertyChanged("TotalFullBytes"); } }
private void DelFile(object obj) { try { DataGrid dataGrid = obj as DataGrid; FileInfo = dataGrid.SelectedItem as FileInfo; FileHelper.DelFile(fileInfo); FileInfoList.Remove(FileInfo); } catch (Exception ex) { ErrorDialogViewModel.getInstance().show(ex); return; } }
public void DeleteFileInfo(object item) { FileDetail file = item as FileDetail; if (item != null) { FileInfoList.Remove(file); } OnPropertyChanged("TotalCount"); OnPropertyChanged("TotalSize"); OnPropertyChanged("TotalLengh"); OnPropertyChanged("TotalWords"); OnPropertyChanged("TotalCharacter"); OnPropertyChanged("TotalFullBytes"); }
private void RemoveItem() { FileInfoList.Remove(SelectedFileInfo); }