Exemple #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                DirInfo nodeToExpand = value as DirInfo;
                if (nodeToExpand == null)
                {
                    return(null);
                }

                //return the subdirectories of the Current Node
                if ((ObjectType)nodeToExpand.DirType == ObjectType.MyComputer)
                {
                    return((from sd in DirectoryService.GetDrives()
                            select new DirInfo(sd)).ToList());
                }
                else
                {
                    IList <DirInfo> childDirList  = new List <DirInfo>();
                    IList <DirInfo> childFileList = new List <DirInfo>();
                    //Combine all the subdirectories and files of the current directory
                    childDirList = (from dir in DirectoryService.GetDirectories(nodeToExpand.Path)
                                    select new DirInfo(dir)).ToList();

                    childFileList = (from fobj in DirectoryService.GetFiles(nodeToExpand.Path)
                                     select new DirInfo(fobj)).ToList();

                    return(childDirList.Concat(childFileList).ToList());
                }
            }
            catch
            {
                return(null);
            }
        }
Exemple #2
0
 private void ProcessFolder(DirInfo parent, IList <string> result)
 {
     if (parent.SubDirectories.Count != 0)
     {
         foreach (DirInfo _item in parent.SubDirectories)
         {
             if (_item.IsChecked2 == null)
             {
                 // if we found a nulled item, we must check its children coz at least one must be checked
                 ProcessFolder(_item, result);
             }
             else
             {
                 if (_item.IsChecked2.Value)
                 {
                     // if we found a checked item, we add it to list and skip processing SubDirectories, they will be anyway fully scanned
                     result.Add(_item.Path);
                     LastSelectedFolder = _item.Path;
                 }
                 else
                 {
                     // if we found a not checked item, we do nothing, just skip processing it
                 }
             }
         }
     }
 }
Exemple #3
0
        public DirInfo SelectPath(string pathToSelect)
        {
            DirInfo _result = null;

            try
            {
                if (!string.IsNullOrEmpty(pathToSelect))
                {
                    string[] _folders = pathToSelect.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                    foreach (string _folder in _folders)
                    {
                        foreach (DirInfo _dir in CurrentDirectory.SubDirectories)
                        {
                            if (_dir.Name == _folder)
                            {
                                _dir.IsSelected  = false;
                                _dir.IsSelected  = true;
                                _dir.IsExpanded  = false;
                                _dir.IsExpanded  = true;
                                CurrentDirectory = _dir;
                                break;
                            }
                        }
                    }
                }
            }
            catch { }
            return(_result);
        }
Exemple #4
0
        public DirInfo(FileInfo fileobj, DirInfo parent, bool isFilterActive)
            : this()
        {
            Parent  = parent;
            Name    = fileobj.Name;
            Path    = fileobj.FullName;
            Root    = parent.Root;
            DirType = ObjectType.File;
            Size    = Helpers.GetFormattedFileSize(fileobj.Length); //(fileobj.Length / 1024).ToString() + " KB";
            Ext     = fileobj.Extension + " File";
            SubDirectories.Clear();
            SetImage();
            if (FileManager.Configuration.Options.FileBrowserOptions.ShowHasExternalSubtitles || isFilterActive)
            {
                SetHasSubtitles(isFilterActive);
            }

            if (FileManager.Configuration.Options.FileBrowserOptions.ShowHasMovieInfo || isFilterActive)
            {
                SetHasMovieInfo(isFilterActive);
            }

            if (FileManager.Configuration.Options.FileBrowserOptions.ShowHasMoviesheet || isFilterActive)
            {
                SetHasMoviesheet(isFilterActive);
            }

            if (FileManager.Configuration.Options.FileBrowserOptions.ShowHasMoviesheetMetadata)
            {
                SetHasMoviesheetMetadata(isFilterActive);
            }
        }
Exemple #5
0
 public DirInfo(DirectoryInfo dir, DirInfo parent)
     : this()
 {
     Parent  = parent;
     Name    = dir.Name;
     Root    = dir.Root.Name;
     Path    = dir.FullName;
     DirType = ObjectType.Directory;
     SetImage();
 }
Exemple #6
0
        public void Refresh()
        {
            // remember current selection
            DirInfo _oldSelection = CurrentDirectory;

            this.Root.IsSelected = true;
            this.Root.ClearChildren();
            this.RefreshCurrentItems(true);
            // select back old selection
            SelectPath(_oldSelection.Path);
        }
Exemple #7
0
        /// <summary>
        /// this method gets the children of current directory and stores them in the CurrentItems Observable collection
        /// </summary>
        public void RefreshCurrentItems(bool reload)
        {
            IList <DirInfo> childDirList  = new List <DirInfo>();
            IList <DirInfo> childFileList = new List <DirInfo>();

            if (reload)
            {
                CurrentDirectory.IsLoaded = false;
            }
            //If current directory is "My computer" then get the all logical drives in the system
            if (CurrentDirectory.Name.Equals(Resources.My_Computer_String))
            {
                childDirList = (from rd in FileSystemExplorerService.GetRootDirectories()
                                select new DirInfo(rd)).ToList();

                CurrentDirectory.LoadDirectories(childDirList);
            }
            else
            {
                //Combine all the subdirectories and files of the current directory
                if (ThumbGen.Helpers.IsDirectory(CurrentDirectory.Path))
                {
                    childDirList = (from dir in FileSystemExplorerService.GetChildDirectories(CurrentDirectory.Path)
                                    select new DirInfo(dir, CurrentDirectory)).ToList();

                    UserOptions _options        = FileManager.Configuration.Options;
                    bool        _isFilterActive = _options.FileBrowserOptions.IsFilterActive();

                    foreach (FileInfo _file in FileSystemExplorerService.GetChildFiles(CurrentDirectory.Path))
                    {
                        if (string.Compare(Path.GetFileName(_file.FullName), ThumbGen.MP4Tagger.MP4Manager.DEST_FILE_NAME) != 0)
                        {
                            bool _skip = false;

                            DirInfo _item = new DirInfo(_file, CurrentDirectory, _isFilterActive);

                            if (!_skip)
                            {
                                childFileList.Add(_item);
                            }
                        }
                    }
                }

                childDirList = childDirList.Concat(childFileList).ToList();

                CurrentDirectory.LoadDirectories(childDirList);
            }
            CurrentItems = childDirList;
        }
Exemple #8
0
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="evm"></param>
        public FileExplorerViewModel(ExplorerWindowViewModel evm)
        {
            _evm = evm;

            //create a node for "my computer"
            // this will be the root for the file system tree
            DirInfo rootNode = new DirInfo(Resources.My_Computer_String, null);

            rootNode.Path         = Resources.My_Computer_String;
            _evm.CurrentDirectory = rootNode; //make root node as the current directory
            // store Root in ExplorerWindowViewModel too
            evm.Root = rootNode;

            SystemDirectorySource = new List <DirInfo> {
                rootNode
            };
        }
Exemple #9
0
        static void IsCheckedPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            DirInfo _dirInfo = obj as DirInfo;

            if (!_dirInfo.IsChecking)
            {
                _dirInfo.IsSelected = true;
            }

            if (_dirInfo.IsChecking)
            {
                _dirInfo.IsChecking = false;
                return;
            }

            Application.Current.Dispatcher.BeginInvoke((Action) delegate
            {
                _dirInfo.SetIsChecked((bool?)e.OldValue, (bool?)e.NewValue, true, true);
            }, DispatcherPriority.Loaded);
        }
Exemple #10
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try {
                DirInfo nodeToExpand = value as DirInfo;
                if (nodeToExpand == null)
                {
                    return(null);
                }

                //return the subdirectories of the Current Node
                if (nodeToExpand.IsLoaded)
                {
                    return(nodeToExpand.SubDirectories);
                }
                else
                {
                    if ((ObjectType)nodeToExpand.DirType == ObjectType.MyComputer)
                    {
                        return((from sd in FileSystemExplorerService.GetRootDirectories()
                                select new DirInfo(sd)).ToList());
                    }
                    else
                    {
                        IList <DirInfo> _tmp =
                            (from dirs in FileSystemExplorerService.GetChildDirectories(nodeToExpand.Path)
                             select new DirInfo(dirs, nodeToExpand)).ToList();
                        foreach (DirInfo _dir in _tmp)
                        {
                            nodeToExpand.SubDirectories.Add(_dir);
                        }
                        return(_tmp);
                    }
                }
            }
            catch { return(null); }
        }
Exemple #11
0
 public DirInfo(string directoryName, DirInfo parent)
     : this()
 {
     Name   = directoryName;
     Parent = parent;
 }
Exemple #12
0
 private DirInfo(DirInfo parent)
 {
     Parent         = parent;
     IsDummy        = true;
     SubDirectories = new ObservableCollection <DirInfo>();
 }