Beispiel #1
0
 protected void ParrentFolder()
 {
     if (!String.IsNullOrEmpty(CurrentPath))
     {
         string[] path = CurrentPath.Split('\\');
         if (path.Length <= 2 && path.Any(i => String.IsNullOrEmpty(i)))
         {
             CurrentFolderItems.Clear();
             DirectoryItemVM item = Items.FirstOrDefault(i => i.Name == $"{path.FirstOrDefault()}\\");
             item.ClearChildren();
         }
         var parrent = Directory.GetParent(CurrentPath);
         if (parrent != null)
         {
             CurrentPath = parrent.FullName;
         }
     }
 }
Beispiel #2
0
        protected override void ExpandTree(string dir)
        {
            if (String.IsNullOrEmpty(CurrentPath) || !Directory.Exists(CurrentPath))
            {
                return;
            }

            string[] path = CurrentPath.Split('\\');
            if (path.Length == 0)
            {
                return;
            }
            string fullPath = null;

            DirectoryItemVM currentPlace = null;

            foreach (var step in path)
            {
                if (currentPlace == null && !String.IsNullOrEmpty(step))
                {
                    var drive = $"{step}\\";
                    currentPlace = Items.Where(i => i.Name == drive).SingleOrDefault();
                }

                else if (!String.IsNullOrEmpty(step))
                {
                    currentPlace = currentPlace.Children.Where(i => i.Name == step).ToList().SingleOrDefault();
                }

                if (currentPlace != null)
                {
                    currentPlace.ExpandDirectory(); //TODO
                }
            }
            CurrentPath = dir;
        }