// Sets the selected Directory from UI command
        public void SetSelectedDirectoryCall(object sender)
        {
            UserDirectory clickedDirectory = (UserDirectory)sender;

            clickedDirectory.IsSelected = true;
            SelectedDirectory           = (UserDirectory)sender;
        }
 // Navigate into a directory, or open a file either with the attached program or the default program for it
 public void DoubleClickCall(object sender)
 {
     if (sender.GetType() == typeof(UserDirectory))
     {
         UserDirectory clickedDirectory = (UserDirectory)sender;
         SelectedDirectory.IsExpanded    = true;
         clickedDirectory.ViewIsSelected = false;
         clickedDirectory.IsSelected     = true;
         clickedDirectory.IsExpanded     = true;
         SelectedDirectory = clickedDirectory;
     }
     else if (sender.GetType() == typeof(UserFile))
     {
         UserFile clickedFile = (UserFile)sender;
         if (OpenFileHandler != null)
         {
             OpenFileEventArgs eventArgs = new OpenFileEventArgs
             {
                 FilePath = clickedFile.ItemPath
             };
             OpenFileHandler?.Invoke(this, eventArgs);
         }
         else
         {
             Process.Start(clickedFile.ItemPath);
         }
     }
 }
        // Build out the tree of directories from a root path
        public void BuildDirectoryTree(string path)
        {
            UserDirectory rootDirectory = CreateDirectory(path, null);

            RootDirectoryItems.Add(rootDirectory);
            SelectedDirectory            = rootDirectory;
            SelectedDirectory.IsExpanded = true;
            SelectedDirectory.IsSelected = true;
        }
        // Adds a UserDirectory object into the DirectoryHistory list, if the DirectoryHistoryIndex is in the middle of the
        // list remove all items after the index before adding the new directory
        public void AddDirectoryToHistory(UserDirectory dir)
        {
            if (DirectoryHistoryIndex != -1 && DirectoryHistoryIndex != DirectoryHistory.Count - 1)
            {
                DirectoryHistory.RemoveRange(DirectoryHistoryIndex + 1, DirectoryHistory.Count - (DirectoryHistoryIndex + 1));
            }

            DirectoryHistory.Add(dir);
            DirectoryHistoryIndex = DirectoryHistory.Count - 1;
        }
        // Recursive, create the directory at passed in path and all sub directories within
        public UserDirectory CreateDirectory(string path, UserDirectory parent)
        {
            UserDirectory returnDir = new UserDirectory(path)
            {
                ParentDirectory = parent ?? null
            };

            returnDir.UpdateFileList(ref _userMessage);
            RaisePropertyChanged("UserMessage");

            foreach (string getPath in Directory.GetDirectories(path))
            {
                returnDir.Subfolders.Add(CreateDirectory(getPath, returnDir));
            }

            return(returnDir);
        }
        // Selected the directory tree item with a matching ItemPath passed in path string
        // Used to handle pasting a file path into the content browser to navitage to the pasted path
        public void NavigateToPath(string path)
        {
            ConfigManager configManger = new ConfigManager();
            string        contentRoot  = configManger.GetContentRoot();
            string        filePath     = string.Empty;

            // If path is a file get the Directory of the file instead
            if (Path.HasExtension(path))
            {
                filePath = path;
                string extension = Path.GetExtension(path);
                path = Path.GetDirectoryName(path);

                if (extension == ".uasset")
                {
                    path = path.Replace("Robogore\\Content", "Data");
                    path = FindDirectory(path);
                }
            }

            if ((System.IO.File.Exists(path) || Directory.Exists(path)) && path.ToLower().Contains(contentRoot.ToLower()))
            {
                UserDirectory foundDirectory = (RootDirectoryItems[0] as UserDirectory).FindChildFolder(path);
                if (foundDirectory != null)
                {
                    SelectedDirectory         = foundDirectory;
                    foundDirectory.IsSelected = true;
                }
            }

            if (filePath != string.Empty)
            {
                foreach (UserFile file in SelectedDirectory.Files)
                {
                    if (file.ShortName == Path.GetFileNameWithoutExtension(filePath))
                    {
                        file.ViewIsSelected = true;
                        SelectedFile        = file;
                    }
                }
            }
        }