Beispiel #1
0
 public DirectoryViewModel(DirectoryInfo model, DirectoryViewModel parent = null, Exception exception = null)
 {
     _model = model;
     _parent = parent;
     _exception = exception;
     _refresh = true;
     _items = new ObservableCollection<DirectoryViewModel>();
 }
 public DirectoryViewModel(DirectoryInfo model, DirectoryViewModel parent = null, Exception exception = null)
 {
     _model     = model;
     _parent    = parent;
     _exception = exception;
     _refresh   = true;
     _items     = new ObservableCollection <DirectoryViewModel>();
 }
        private void ExpandAndSelect(DirectoryInfo path)
        {
            DirectoryViewModel vm = Lookup(path);

            if (vm != null)
            {
                vm.IsExpanded = true;
                vm.IsSelected = true;
            }
        }
        private DirectoryViewModel Lookup(DirectoryInfo path)
        {
            DirectoryViewModel root = LookupRoot(path);

            if (root != null)
            {
                return(root.Lookup(path));
            }
            return(null);
        }
        /// <summary>
        /// Method to invoke when the UploadAllRecursively command is executed.
        /// </summary>
        private void OnUploadAllRecursivelyExecute()
        {
            DirectoryViewModel dvm = SelectedDirectory;

            if (dvm == null)
            {
                return;
            }
            DirectoryInfo di = dvm.DirectoryInfo;
            var           t  = new Thread(() =>
                                          AddFilesInDirectory(di, true));

            t.Start();
        }
        /// <summary>
        /// Called when the SelectedDirectory property has changed.
        /// </summary>
        private void OnSelectedDirectoryChanged()
        {
            DirectoryViewModel item = SelectedDirectory;

            if (item != null)
            {
                DirectoryInfo di = item.DirectoryInfo;
                if (di != null)
                {
                    ExpandAndSelect(di);
                    Settings settings = Settings.Default;
                    settings.LastDirectoryExplorerSelectedPath = di.FullName;
                    settings.Save();
                }
            }
        }
        public DirectoryViewModel Lookup(DirectoryInfo path)
        {
            // if we found the path
            if (DirectoryInfo.FullName == path.FullName)
            {
                return(this);
            }

            DirectoryInfo p = path;

            while (p.Parent.FullName != DirectoryInfo.FullName)
            {
                p = p.Parent;
            }

            DirectoryViewModel child = Directories.FirstOrDefault(x => x.DirectoryInfo.FullName == p.FullName);

            if (child == null)
            {
                return(null);
            }
            return(child.Lookup(path));
        }