private void createDirectory_Click(object sender, RoutedEventArgs e) { Location selectedNode = treeView.SelectedItem as Location; if (selectedNode == null) { return; } try { String newFolder = FileUtils.getUniqueDirectoryName(selectedNode.FullName); selectedNode.IsExpanded = true; DirectoryInfo newFolderInfo = System.IO.Directory.CreateDirectory(newFolder); DirectoryLocation child = new DirectoryLocation(newFolderInfo, infoGatherTask, MediaFileWatcher.Instance.MediaFileState); CollectionsSort.insertIntoSortedCollection(selectedNode.Children, child); infoGatherTask.addLocation(child); //treeView.SelectedItem = child; //treeView.ScrollIntoView(child); } catch (Exception ex) { Logger.Log.Error("Error creating directory", ex); MessageBox.Show("Error creating directory\n\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public DriveLocation(DriveInfo info, InfoGatherTask infoGatherTask, MediaFileState mediaFileState) : base(infoGatherTask, mediaFileState) { switch (info.DriveType) { case DriveType.CDRom: { ImageUrl = "pack://application:,,,/Resources/Icons/CD_Drive.ico"; VolumeLabel = "CD ROM"; break; } case DriveType.Fixed: { ImageUrl = "pack://application:,,,/Resources/Icons/Hard_Drive.ico"; try { VolumeLabel = !String.IsNullOrEmpty(info.VolumeLabel) ? info.VolumeLabel : "Local Disk"; } catch (Exception) { } break; } case DriveType.Network: { ImageUrl = "pack://application:,,,/Resources/Icons/Network_Drive.ico"; VolumeLabel = "Network Drive"; break; } case DriveType.NoRootDirectory: { break; } case DriveType.Ram: { ImageUrl = "pack://application:,,,/Resources/Icons/ram.ico"; VolumeLabel = "Ram Drive"; break; } case DriveType.Removable: { ImageUrl = "pack://application:,,,/Resources/Icons/Removable_Drive.ico"; VolumeLabel = "Removable Drive"; break; } case DriveType.Unknown: { ImageUrl = "pack://application:,,,/Resources/Icons/UnknownDrive.ico"; VolumeLabel = "Unknown Drive"; break; } } Name = info.Name.TrimEnd(new char[] { '\\' }); if (driveIdleMonitor.DrivesMonitored.Contains(Name)) { FreeSpaceBytes = info.TotalFreeSpace; driveIdleMonitor.DriveInUse += new EventHandler <string>(driveIdleMonitor_driveInUse); } else { FreeSpaceBytes = 0; } infoGatherTask.addLocation(this); LazyLoading = true; }
public DriveLocation(DriveInfo info, InfoGatherTask infoGatherTask, MediaFileState mediaFileState) : base(infoGatherTask, mediaFileState) { switch (info.DriveType) { case DriveType.CDRom: { ImageUrl = "pack://application:,,,/Resources/Icons/CD_Drive.ico"; VolumeLabel = "CD ROM"; break; } case DriveType.Fixed: { ImageUrl = "pack://application:,,,/Resources/Icons/Hard_Drive.ico"; try { VolumeLabel = !String.IsNullOrEmpty(info.VolumeLabel) ? info.VolumeLabel : "Local Disk"; } catch (Exception) { } break; } case DriveType.Network: { ImageUrl = "pack://application:,,,/Resources/Icons/Network_Drive.ico"; VolumeLabel = "Network Drive"; break; } case DriveType.NoRootDirectory: { break; } case DriveType.Ram: { ImageUrl = "pack://application:,,,/Resources/Icons/ram.ico"; VolumeLabel = "Ram Drive"; break; } case DriveType.Removable: { ImageUrl = "pack://application:,,,/Resources/Icons/Removable_Drive.ico"; VolumeLabel = "Removable Drive"; break; } case DriveType.Unknown: { ImageUrl = "pack://application:,,,/Resources/Icons/UnknownDrive.ico"; VolumeLabel = "Unknown Drive"; break; } } Name = info.Name.TrimEnd(new char[] { '\\' }); if (driveIdleMonitor.DrivesMonitored.Contains(Name)) { FreeSpaceBytes = info.TotalFreeSpace; driveIdleMonitor.DriveInUse += new EventHandler<string>(driveIdleMonitor_driveInUse); } else { FreeSpaceBytes = 0; } infoGatherTask.addLocation(this); LazyLoading = true; }