private void refreshDirectory_Click(object sender, RoutedEventArgs e)
        {
            Location selectedNode = treeView.SelectedItem as Location;

            if (selectedNode == null)
            {
                return;
            }

            Location parent = selectedNode.Parent as Location;
            Location newNode;
            string   fullName = selectedNode.FullName;

            parent.Children.Remove(selectedNode);

            if (selectedNode is DriveLocation)
            {
                newNode = new DriveLocation(new DriveInfo(fullName), infoGatherTask, MediaFileWatcher.Instance.MediaFileState);
            }
            else
            {
                newNode = new DirectoryLocation(new DirectoryInfo(fullName), infoGatherTask, MediaFileWatcher.Instance.MediaFileState);
            }

            CollectionsSort.insertIntoSortedCollection(parent.Children, newNode);
            infoGatherTask.addLocation(newNode);
            newNode.IsExpanded    = selectedNode.IsExpanded;
            treeView.SelectedItem = newNode;
        }
Esempio n. 2
0
        List <SharpTreeNode> getDriveNodes()
        {
            List <SharpTreeNode> drives = new List <SharpTreeNode>();

            try
            {
                DriveInfo[] drivesArray = DriveInfo.GetDrives();
                foreach (DriveInfo driveInfo in drivesArray)
                {
                    Location drive = new DriveLocation(driveInfo, infoGatherTask, MediaFileWatcher.Instance.MediaFileState);

                    drives.Add(drive);
                }
            }
            catch (Exception e)
            {
                Logger.Log.Error("Cannot read system drives", e);
            }

            return(drives);
        }
        private void refreshDirectory_Click(object sender, RoutedEventArgs e)
        {      
            Location selectedNode = treeView.SelectedItem as Location;
            if (selectedNode == null)
            {
                return;
            }

            Location parent = selectedNode.Parent as Location;
            Location newNode;
            string fullName = selectedNode.FullName;
            parent.Children.Remove(selectedNode);

            if (selectedNode is DriveLocation)
            {
                newNode = new DriveLocation(new DriveInfo(fullName), infoGatherTask, MediaFileWatcher.Instance.MediaFileState);                           
            }
            else
            {
                newNode = new DirectoryLocation(new DirectoryInfo(fullName), infoGatherTask, MediaFileWatcher.Instance.MediaFileState);
            }

            CollectionsSort.insertIntoSortedCollection(parent.Children, newNode);
            infoGatherTask.addLocation(newNode);
            newNode.IsExpanded = selectedNode.IsExpanded;
            treeView.SelectedItem = newNode;
                  
        }
Esempio n. 4
0
        List<SharpTreeNode> getDriveNodes()
        {
            List<SharpTreeNode> drives = new List<SharpTreeNode>();

            try
            {
                DriveInfo[] drivesArray = DriveInfo.GetDrives();
                foreach (DriveInfo driveInfo in drivesArray)
                {
                    Location drive = new DriveLocation(driveInfo, infoGatherTask, MediaFileWatcher.Instance.MediaFileState);

                    drives.Add(drive);
                }
            }
            catch (Exception e)
            {
                Logger.Log.Error("Cannot read system drives", e);
            }

            return (drives);
        }