コード例 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            MyFileItemViewSource        = ((CollectionViewSource)(FindResource("MyFileItemViewSource")));
            MyFileItemViewSource.Source = _currentItem.SubFiles;

            _currentDir = new MyDirInfo("C:/");
            FileTreeView.ItemsSource = _currentDir.SubFiles;
        }
コード例 #2
0
        private void FileTreeView_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            MyDirInfo selected = FileTreeView.SelectedItem as MyDirInfo;

            if (selected != null)
            {
                _currentDir = selected;
                _myFileViewSource.Source = new MyFileInfo(selected.FullPath, null).SubFiles;
            }
            else
            {
                Console.WriteLine("Cant cast");
            }
        }
コード例 #3
0
ファイル: MyDirInfo.cs プロジェクト: EnochFin/WPF_FileSizer
        /// <summary>
        /// Enoch's contribution, I decided my feature would be to include a sidebar that would start at a root directory ex: C:\ and would show only directories
        /// if you click on any directory in the tree, it will rediretc you to that directory in the file explorer carver and I made.
        /// 
        /// If I would be able to work more on this, I would delay the population of the Subdirectories until after you selected a directory in the side panel so it would be faster on startup
        /// and the side panel would probably be a popout that would would show only when you wanted it to, while working on this project I learned about Hierarchical Data Templates and 
        /// discovered a use for private constructors, like in the class below.
        /// 
        /// Through this process I definitely feel more comfortable in binding, Data Templates, Styles, file exploration, and styling in general.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="parent"></param>
        private MyDirInfo(string path, MyDirInfo parent)
        {
            Name = path.Substring(path.LastIndexOf("\\") + 1);
            Parent = parent;
            SubFiles = new List<MyDirInfo>();
            FileAttributes attr = File.GetAttributes(path);

            if (attr.HasFlag(FileAttributes.Directory))
            {
                try
                {
                    FullPath = path;
                    foreach (string dir in Directory.GetDirectories(path))
                    {
                        SubFiles.Add(new MyDirInfo(dir, this));
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    Name += (" - UnAuthorized");
                }
            }
        }
コード例 #4
0
ファイル: MyDirInfo.cs プロジェクト: EnochFin/WPF_FileSizer
        /// <summary>
        /// Enoch's contribution, I decided my feature would be to include a sidebar that would start at a root directory ex: C:\ and would show only directories
        /// if you click on any directory in the tree, it will rediretc you to that directory in the file explorer carver and I made.
        ///
        /// If I would be able to work more on this, I would delay the population of the Subdirectories until after you selected a directory in the side panel so it would be faster on startup
        /// and the side panel would probably be a popout that would would show only when you wanted it to, while working on this project I learned about Hierarchical Data Templates and
        /// discovered a use for private constructors, like in the class below.
        ///
        /// Through this process I definitely feel more comfortable in binding, Data Templates, Styles, file exploration, and styling in general.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="parent"></param>
        private MyDirInfo(string path, MyDirInfo parent)
        {
            Name     = path.Substring(path.LastIndexOf("\\") + 1);
            Parent   = parent;
            SubFiles = new List <MyDirInfo>();
            FileAttributes attr = File.GetAttributes(path);

            if (attr.HasFlag(FileAttributes.Directory))
            {
                try
                {
                    FullPath = path;
                    foreach (string dir in Directory.GetDirectories(path))
                    {
                        SubFiles.Add(new MyDirInfo(dir, this));
                    }
                }
                catch (UnauthorizedAccessException)
                {
                    Name += (" - UnAuthorized");
                }
            }
        }
コード例 #5
0
 private void FileTreeView_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
 {
     MyDirInfo selected = FileTreeView.SelectedItem as MyDirInfo;
     
     if (selected != null)
     {
         _currentDir = selected;
         _myFileViewSource.Source = new MyFileInfo(selected.FullPath, null).SubFiles;
     }
     else
     {
         Console.WriteLine("Cant cast");
     }
 }
コード例 #6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            MyFileItemViewSource = ((CollectionViewSource)(FindResource("MyFileItemViewSource")));
            MyFileItemViewSource.Source = _currentItem.SubFiles;

            _currentDir = new MyDirInfo("C:/");
            FileTreeView.ItemsSource = _currentDir.SubFiles;
        }