private void BaseUploading_OnLoaded(object sender, RoutedEventArgs e) { // button visibility BtSeeArchive.Visibility = Visibility.Collapsed; BtUploadArchive.Visibility = Visibility.Collapsed; BtDeleteArchive.Visibility = Visibility.Collapsed; _filesToBind = new List <FileToBind>(); foreach (var dwgBaseItem in _dwgBaseItems) { var file = Path.Combine(_dwgBaseFolder, dwgBaseItem.SourceFile); if (File.Exists(file)) { var fi = new FileInfo(file); var fileToBind = new FileToBind { FileName = fi.Name, FullFileName = fi.FullName, SourceFile = dwgBaseItem.SourceFile, Selected = false, FullDirectory = fi.DirectoryName, SubDirectory = fi.DirectoryName?.Replace(_dwgBaseFolder + @"\", string.Empty) }; if (!HasFileToBindInList(fileToBind)) { _filesToBind.Add(fileToBind); } } } LvDwgFiles.ItemsSource = _filesToBind; }
private bool HasFileToBindInList(FileToBind fileToBind) { var has = false; foreach (var toBind in _filesToBind) { if (toBind.FileName.Equals(fileToBind.FileName) & toBind.FullFileName.Equals(fileToBind.FullFileName) & toBind.SourceFile.Equals(fileToBind.SourceFile)) { has = true; break; } } return(has); }