public DirectoryTreeViewItemViewModel EnsureFolder(string path)
        {
            var dirInfo  = new DirectoryInfo(path);
            var segments = GetPathSegments(dirInfo);

            var currentRoots = new List <DirectoryTreeViewItemViewModel>(Roots);

            DirectoryTreeViewItemViewModel currentSegment = null;

            foreach (var segment in segments)
            {
                currentSegment = currentRoots.FirstOrDefault(
                    vm => vm.DisplayPath.Equals(segment, StringComparison.InvariantCultureIgnoreCase));
                if (currentSegment == null)
                {
                    break;
                }

                currentSegment.EnsureItemsLoaded();

                currentRoots = new List <DirectoryTreeViewItemViewModel>(currentSegment.Children);
            }

            return(currentSegment);
        }
Esempio n. 2
0
		public FolderViewModel(Folder folder, DirectoryTreeViewItemViewModel parentFolderViewModel)
			: base(parentFolderViewModel, true)
		{
			_folder = folder;

			var dir = new DirectoryInfo(_folder.FolderPath);
			_displayPath = dir.Name;
		}
Esempio n. 3
0
        public FolderViewModel(Folder folder, DirectoryTreeViewItemViewModel parentFolderViewModel)
            : base(parentFolderViewModel, true)
        {
            _folder = folder;

            var dir = new DirectoryInfo(_folder.FolderPath);

            _displayPath = dir.Name;
        }
		public DirectoryTreeViewItemViewModel(DirectoryTreeViewItemViewModel parent, bool lazyLoad)
		{
			_parent = parent;
			_children = new List<DirectoryTreeViewItemViewModel>();

			if (lazyLoad)
				_children.Add(DummyChild);

			_isChecked = false;
		}
Esempio n. 5
0
        public DirectoryTreeViewItemViewModel(DirectoryTreeViewItemViewModel parent, bool lazyLoad)
        {
            _parent   = parent;
            _children = new List <DirectoryTreeViewItemViewModel>();

            if (lazyLoad)
            {
                _children.Add(DummyChild);
            }

            _isChecked = false;
        }
        private static IEnumerable <DirectoryTreeViewItemViewModel> GetCheckedFolders(DirectoryTreeViewItemViewModel node)
        {
            if (node.IsChecked == true)
            {
                yield return(node);
            }

            if (node.HasDummyChild)
            {
                yield break;
            }

            foreach (var subnode in node.Children.SelectMany(GetCheckedFolders))
            {
                yield return(subnode);
            }
        }
		private static IEnumerable<DirectoryTreeViewItemViewModel> GetCheckedFolders(DirectoryTreeViewItemViewModel node)
		{
			if (node.IsChecked == true)
				yield return node;

			if (node.HasDummyChild)
				yield break;

			foreach (var subnode in node.Children.SelectMany(GetCheckedFolders))
			{
				yield return subnode;
			}
		}