Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        List <SharpTreeNode> createDirectoryNodes(String location)
        {
            List <SharpTreeNode> directories = new List <SharpTreeNode>();

            try
            {
                IEnumerable <DirectoryInfo> dirInfos = new DirectoryInfo(location).EnumerateDirectories();

                foreach (DirectoryInfo dirInfo in dirInfos)
                {
                    if (dirInfo.Attributes.HasFlag(FileAttributes.System))
                    {
                        continue;
                    }

                    Location directory = new DirectoryLocation(dirInfo, infoGatherTask, MediaFileState);

                    directories.Add(directory);
                }
            }
            catch (Exception e)
            {
                Logger.Log.Error("Cannot read directories", e);
            }

            return(directories);
        }
Exemplo n.º 4
0
        List<SharpTreeNode> createDirectoryNodes(String location)
        {
            List<SharpTreeNode> directories = new List<SharpTreeNode>();

            try
            {                
                IEnumerable<DirectoryInfo> dirInfos = new DirectoryInfo(location).EnumerateDirectories();

                foreach (DirectoryInfo dirInfo in dirInfos)
                {
                    if (dirInfo.Attributes.HasFlag(FileAttributes.System))
                    {
                        continue;
                    }
                    
                    Location directory = new DirectoryLocation(dirInfo, infoGatherTask, MediaFileState);

                    directories.Add(directory);
                }
            }
            catch (Exception e)
            {
                Logger.Log.Error("Cannot read directories", e);
            }

            return (directories);
        }
Exemplo n.º 5
0
        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;
                  
        }
Exemplo n.º 6
0
        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);
            }
                        
        }