예제 #1
0
        // Extract and build a new JFolder from one JFolder
        private static JFolder JBuildRootFromFolder(JFolder folder)
        {
            // This is a bit complicated: We first constrct a string of all folder paths
            List <string> folderNames = new List <string>();
            JFolder       parent      = folder;

            while (parent != null)
            {
                folderNames.Add(parent.FolderName);
                parent = parent.Parent;
            }
            folderNames.Reverse();  // Revese order so things are logical
            // Then we add all those paths to our newly created JFolder
            JFolder representativeFolder = new JFolder(folderNames[0]);
            JFolder currentFolder        = representativeFolder;

            // Expand Root Folder
            currentFolder.bExpanded = true;
            for (int i = 1; i < folderNames.Count; i++) // Skipped the root folder name, i.e. when i = 0
            {
                // Add Children and Iterate
                currentFolder.Folders.Add(new JFolder(folderNames[i]));
                currentFolder = currentFolder.Folders[0];   // Go to the only child folder of current folder
                // Expand Folder
                currentFolder.bExpanded = true;
            }

            // Establish New ParentalShip
            App.EstablishParents(representativeFolder);

            // Return the JSON obejct
            return(representativeFolder);
        }
예제 #2
0
        // Used by SubmitButton: This function generates a complete JSON tree of all folders that are selected by user, then append all drive folders to a Unified Folder to conform to our standard
        // Just note that this is not complicated by Windows OS, since on Linux we will need to do some fair amount of work as well: mostly to expand folders that are not expanded by user
        private void FolderIterator()
        {
            // Create a new Unified Folder
            JUnifiedFolder = new JFolder(App.UnifiedFolderName);

            // Get all drives we have loaded
            List <JFolder> DisplayDrivesList = DirectoryView.ItemsSource as List <JFolder>;
            List <JFolder> JSONDrivesTree    = new List <JFolder>();

            // For each drive, create a tree of all selected folders and their subitems; If folder not completely loaded yet then load it, to not interfering with display, we need to deep copy a new tree from drive down
            // Optimization: This part might be multi-threaded in the future
            foreach (JFolder folder in DisplayDrivesList)
            {
                // Create copies of drives
                JFolder folderCopy = ExpandFolderRecursive(folder);
                if (folderCopy != null)
                {
                    JSONDrivesTree.Add(folderCopy);

                    // Also add current drive to the submitted JSON
                    folderCopy.Parent = JUnifiedFolder;   // Before this all parents for drives are null
                    JUnifiedFolder.Folders.Add(folderCopy);
                }
            }
        }
예제 #3
0
        private void FolderImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // Extract Item from metadata
            JFolder item = (sender as Image).Tag as JFolder;

            OpenFolderForInspection(item);
        }
예제 #4
0
        private bool CleanupMarkFoldersDeletion(JFolder currentFolder)  // Return value is assigned last in programming logic *: Return whether children is empty
        {
            // Check whether we have any subfolders
            bool bChildrenEmpty = true;    // *

            foreach (JFolder folder in currentFolder.Folders)
            {
                if (!CleanupMarkFoldersDeletion(folder))
                {
                    bChildrenEmpty = false; // *
                }
            }

            // End Node Folder where no other folders exist -- check whether we have any files
            //if (currentFolder.Files.Any())
            //{
            //    currentFolder.bMarkRemove = false;
            //}
            //else
            //{
            //    currentFolder.bMarkRemove = true;
            //}
            currentFolder.bMarkRemove = !currentFolder.Files.Any() && bChildrenEmpty;

            //return (!currentFolder.bMarkRemove || bChildrenNotEmpty);    // *
            return(currentFolder.bMarkRemove);
        }
예제 #5
0
        private void MenuItem_FolderProperty_Click(object sender, RoutedEventArgs e)
        {
            // Get folder path
            JFolder folder     = (sender as MenuItem).DataContext as JFolder;
            string  folderPath = App.GetParentFolderPath(folder);

            SystemInterpService.ShowFileProperties(folderPath);
        }
예제 #6
0
        private void OnTreeViewItemPreviewKeyDown(object sender, KeyEventArgs e)
        {
            Key key = (e.Key == Key.System ? e.SystemKey : e.Key);

            // Enter key for quick search
            if (key == Key.Enter)
            {
                // If SHIFT is pressed, then open file location if file, otherwise ignore
                if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    // Make sure some node is selected and that represents a file
                    JFile file = DirectoryView.SelectedItem as JFile;
                    if (file != null)
                    {
                        OpenFolderForInspection(file.Parent);
                        e.Handled = true;
                    }
                }
                // If ALT is pressed, then open property window
                else if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt)
                {
                    // Open as a file
                    JFile file = DirectoryView.SelectedItem as JFile;
                    if (file != null)
                    {
                        SystemInterpService.ShowFileProperties(App.GetParentFolderPath(file.Parent) + file.FileName);
                        e.Handled = true;
                    }
                    // Open as a folder
                    JFolder folder = DirectoryView.SelectedItem as JFolder;
                    if (folder != null)
                    {
                        SystemInterpService.ShowFileProperties(App.GetParentFolderPath(folder));
                        e.Handled = true;
                    }
                }
                // Open as is
                else
                {
                    // Open as a file
                    JFile file = DirectoryView.SelectedItem as JFile;
                    if (file != null)
                    {
                        OpenFileForEditing(file);
                        e.Handled = true;
                    }
                    // Open as a folder
                    JFolder folder = DirectoryView.SelectedItem as JFolder;
                    if (folder != null)
                    {
                        OpenFolderForInspection(folder);
                        e.Handled = true;
                    }
                }
            }
        }
예제 #7
0
        private void OpenFolderButton_Click(object sender, RoutedEventArgs e)
        {
            // Extract Item from metadata
            JFolder item = (sender as Button).Tag as JFolder;

            // Get folder pathh
            string folderPath = App.GetParentFolderPath(item);

            // Open folder in system explorer
            System.Diagnostics.Process.Start(folderPath);
        }
예제 #8
0
        private void DirectoryView_Collapsed(object sender, RoutedEventArgs e)
        {
            // Extra Folder
            JFolder folder = (e.OriginalSource as TreeViewItem).DataContext as JFolder;   // Or e.Source.SelectedValue or e.Source.SelectedItem, see debug watch

            folder.bExpanded = false;

            List <JFolder> DrivesList = DirectoryView.ItemsSource as List <JFolder>;

            DirectoryView.ItemsSource = null;
            DirectoryView.ItemsSource = DrivesList;
        }
예제 #9
0
        public static void EstablishParents(JFolder currentFolder)
        {
            foreach (JFile file in currentFolder.Files)
            {
                file.Parent = currentFolder;
            }

            foreach (JFolder folder in currentFolder.Folders)
            {
                folder.Parent = currentFolder;
                EstablishParents(folder);
            }
        }
예제 #10
0
        private static void KeywordIteratorForFolder(JFolder currentFolder, List <JFolder> foldersList, string keyword)
        {
            // Match Folder
            if (currentFolder.FolderName.ToUpper().Contains(keyword.ToUpper()))
            {
                foldersList.Add(currentFolder);
            }

            // Continue Searching
            foreach (JFolder folder in currentFolder.Folders)
            {
                KeywordIteratorForFolder(folder, foldersList, keyword);
            }
        }
예제 #11
0
        private void FileFilter(string keywrods, CancellationToken token, bool?bSearchFolder)
        {
            try
            {
                // Wait for 10 ms in case someone is typing fast so we don't waste resources
                Thread.Sleep(10);

                // Were we already canceled?
                token.ThrowIfCancellationRequested();

                // Do the job for some time
                // ... Currenlty we do not bother dividing the job into smaller pieces

                // Poll to make sure we are not cancelling before continue on more job
                //if (token.IsCancellationRequested)
                //{
                //    // No clean up to do, so we just stop ourselves
                //    token.ThrowIfCancellationRequested();
                //}
                //else
                //{
                // Lock so we don't mess things up
                lock (newLocker)
                {
                    if (bSearchFolder == true)
                    {
                        JRootFolder_Filtered = QuickMatch.QuickMatchFolder(keywrods, JRootFolder, CurrentSearchMode == ContentSearchMode.MultiFolder);
                    }
                    else
                    {
                        JRootFolder_Filtered = QuickMatch.QuickMatchFile(keywrods, JRootFolder, CurrentSearchMode == ContentSearchMode.MultiFile);
                    }
                }

                /* Here are some information on lock vs mutex
                 * http://stackoverflow.com/questions/34524/what-is-a-mutex
                 * http://stackoverflow.com/questions/3735293/what-is-the-difference-between-lock-and-mutex
                 * https://msdn.microsoft.com/en-us/library/c5kehkcz.aspx
                 * http://stackoverflow.com/questions/6029804/how-does-lock-work-exactly
                 */
                //}

                // Were we actually canceled?
                token.ThrowIfCancellationRequested();
            }
            catch (OperationCanceledException)
            {
            }
        }
예제 #12
0
        private void RecursiveText(JFolder folder, string currentIndentation)
        {
            // Iterate folders
            foreach (JFolder sub in folder.Folders)
            {
                PlainFolderStructure = PlainFolderStructure + currentIndentation + "▷" + sub.FolderName + "\n";
                RecursiveText(sub, currentIndentation + "\t");
            }

            // Iterate files
            foreach (JFile file in folder.Files)
            {
                PlainFolderStructure = PlainFolderStructure + currentIndentation + file.FileName + "\n";
            }
        }
예제 #13
0
 public static string GetParentFolderPath(JFolder folder)
 {
     if (folder.FolderName == UnifiedFolderName)
     {
         return("");
     }
     else if (folder.Parent == null)
     {
         return(folder.FolderName + "\\");
     }
     else
     {
         return(GetParentFolderPath(folder.Parent) + folder.FolderName + "\\");
     }
 }
예제 #14
0
        public UploadWindow()
        {
            InitializeComponent();

            // Load all drives and populate the directory view
            List <JFolder> drivesList = new List <JFolder>();

            DriveInfo[] drivesInfo = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drivesInfo)
            {
                JFolder driveFolder = new JFolder(drive.ToString());
                driveFolder.Folders.Add(new JFolder(TempLoadingFolderString));
                drivesList.Add(driveFolder);
            }
            DirectoryView.ItemsSource = drivesList;
        }
예제 #15
0
        private void FolderSelectionCheckBox_Checked(object sender, RoutedEventArgs e)
        {
            // Changes are made so if previously we generated a mapping then discard that: For efficiency we could search for that and then remove it only but not necessary for our case
            if (JUnifiedFolder != null)
            {
                JUnifiedFolder = null;
            }

            // If a folder is checked, check all its children as well
            JFolder folder = (sender as CheckBox).Tag as JFolder;

            foreach (JFolder subFolder in folder.Folders)
            {
                subFolder.bSelected = true;
            }
        }
예제 #16
0
        private async void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            // Status Update
            StatusLabel.Content = "Loading...";

            // Send Request and Get Content
            FormUrlEncodedContent postContent = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("username", App.username),
                new KeyValuePair <string, string>("password", App.password)
            });
            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.PostAsync(App.RESTServiceAddress, postContent);

            string responseString = response.Content.ReadAsStringAsync().Result;

            if (responseString != "Wrong username/password combination." && responseString != "No folder structure file is available.")
            {
                // Status Update
                StatusLabel.Content = "Loaded!";

                // Deserialize a Root for later use, and strip out its QuickMatch
                // WARNING: CAUTIOUS TOO MUCH ASSUMPTION -- we assume the QuickMatch folder lives in the first layer, and is the last element
                JRootFolderExclusive = JsonConvert.DeserializeObject <JFolder>(responseString);
                App.EstablishParents(JRootFolderExclusive); // Establish Helper Class Members
                JRootFolderExclusive.Folders.Remove(JRootFolderExclusive.Folders[JRootFolderExclusive.Folders.Count - 1]);

                // Deserialize Results
                JFolder JTempRootFolder = JsonConvert.DeserializeObject <JFolder>(responseString);
                App.EstablishParents(JTempRootFolder); // Establish Helper Class Members
                // Do a Cleanup on Results
                CleanupMarkFilesDeletion(JTempRootFolder);
                CleanupFiles(JTempRootFolder);
                CleanupMarkFoldersDeletion(JTempRootFolder);
                CleanupFolders(JTempRootFolder);

                // Update View
                List <JFolder> Roots = new List <JFolder>();
                Roots.Add(JTempRootFolder);
                ChangesList.ItemsSource = Roots;
            }
            else
            {
                // Status Update
                StatusLabel.Content = responseString;
            }
        }
예제 #17
0
        private static void KeywordIterator(JFolder currentFolder, List <JFile> filesList, string keyword)
        {
            // Match Files
            foreach (JFile file in currentFolder.Files)
            {
                if (file.FileName.ToUpper().Contains(keyword.ToUpper()))
                {
                    filesList.Add(file);
                }
            }

            // Continue Searching
            foreach (JFolder folder in currentFolder.Folders)
            {
                KeywordIterator(folder, filesList, keyword);
            }
        }
예제 #18
0
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            // Status Update
            StatusLabel.Content = "Generating Folder Structure...";

            // If Unified folder doesn't exist then create one
            if (JUnifiedFolder == null)
            {
                // Dispatch a thread to handling generation stuff
                await Task.Factory.StartNew(FolderIterator);
            }

            // Status Update
            StatusLabel.Content = "Folder Structure Mapped Successfully, Now Connecting To Server...";

            // QuickMatch® (1/4): Append a folder for QuickMatch usage
            // Make a copy of JRootFolder to add something interseting to it: QuickMatch® Folders
            JFolder JRootFolderCopy = new JFolder(JUnifiedFolder.FolderName);   // I am not providing a copy constructor in wish that we won't need to use it anywhere else

            JRootFolderCopy.Files   = JUnifiedFolder.Files;                     // Shallow Copy
            JRootFolderCopy.Folders = JUnifiedFolder.Folders.ToList();          // Semi-Deep Copy because we will add new items
            JRootFolderCopy.Folders.Add(new JFolder(App.QuickMatchFolderName)); // Add a blank folder

            // Send Request and Get Content
            MyFormUrlEncodedContent postContent = new MyFormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("username", App.username),
                new KeyValuePair <string, string>("password", App.password),
                new KeyValuePair <string, string>("filecontent", JsonConvert.SerializeObject(JRootFolderCopy, Formatting.Indented))  // Notice that we are only adding this folder here for uploading purpose, for HTML and Local saving we don't do that
            });

            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.PostAsync(App.RESTServiceAddress, postContent);

            // Status Update accordingly
            string responseString = response.Content.ReadAsStringAsync().Result;

            if (responseString == "File successfully received.")
            {
                StatusLabel.Content = "Succeeded!";
            }
            else
            {
                StatusLabel.Content = responseString;
            }
        }
예제 #19
0
        private void CleanupFiles(JFolder currentFolder)
        {
            // Remove all file references
            List <JFile> tempFilesList = currentFolder.Files.ToList();    // http://stackoverflow.com/questions/1952185/how-do-i-copy-items-from-list-to-list-without-foreach

            foreach (JFile file in tempFilesList)
            {
                if (file.bMarkRemove == true)
                {
                    currentFolder.Files.Remove(file);
                }
            }

            foreach (JFolder folder in currentFolder.Folders)
            {
                CleanupFiles(folder);
            }
        }
예제 #20
0
        private void CleanupMarkFilesDeletion(JFolder currentFolder)
        {
            // Mark removing all files that are unthouched
            foreach (JFile file in currentFolder.Files)
            {
                file.bMarkRemove = false;   // Mark everyone included, i.e. not to be deleted for now
                if (file.TextContent == null && file.Appendix == null)
                {
                    // currentFolder.Files.Remove(file);    // Cannot execute here
                    file.bMarkRemove = true;
                }
            }

            // Mark subfolders' files
            foreach (JFolder folder in currentFolder.Folders)
            {
                CleanupMarkFilesDeletion(folder);
            }
        }
예제 #21
0
        //private bool CleanupMarkFoldersDeletion(JFolder currentFolder) // Returns whether current folder or its sub folder contains files
        //{
        //    // Mark removing all subfolders that contain nothing
        //    bool bSubFolderContainFiles = true;
        //    foreach (JFolder folder in currentFolder.Folders)
        //    {
        //        bSubFolderContainFiles = CleanupMarkFoldersDeletion(folder);
        //    }
        //    // Clean self if no files contained; For root folder we won't delete itself
        //    currentFolder.bMarkRemove = false;
        //    if (currentFolder.Parent != null && currentFolder.Files.Any() == false && bSubFolderContainFiles == false)
        //    {
        //        // currentFolder.Parent.Folders.Remove(currentFolder);
        //        currentFolder.bMarkRemove = true;
        //    }

        //    return (currentFolder.Files.Any() || bSubFolderContainFiles);
        //}

        private void CleanupFolders(JFolder currentFolder)
        {
            // Remove all folder references
            List <JFolder> tempFoldersList = currentFolder.Folders.ToList();

            foreach (JFolder folder in tempFoldersList)
            {
                if (folder.bMarkRemove == true)
                {
                    currentFolder.Folders.Remove(folder);
                }
                else
                {
                    CleanupFolders(folder);
                }
            }

            // Expand Folder
            currentFolder.bExpanded = true;
        }
예제 #22
0
        private void RecursiveHTML(JFolder folder, string currentIndentation, int indentationLevel)
        {
            // Do it once and use it multiple times
            string folderPath = App.GetParentFolderPath(folder);

            // Iterate folders
            foreach (JFolder sub in folder.Folders)
            {
                HTMLContent = HTMLContent + currentIndentation + String.Concat(Enumerable.Repeat("&emsp;", indentationLevel)) +
                              String.Format("<a href = \"file:///{0}\">{1}</a>", folderPath + "\\" + sub.FolderName, sub.FolderName) + "<br>\r\n";
                RecursiveHTML(sub, currentIndentation + "\t", indentationLevel + 1);
            }

            // Iterate files
            foreach (JFile file in folder.Files)
            {
                HTMLContent = HTMLContent + currentIndentation + String.Concat(Enumerable.Repeat("&emsp;", indentationLevel)) +
                              String.Format("<a href = \"file:///{0}\">{1}</a>", folderPath + "\\" + file.FileName, file.FileName) +
                              "<br>\r\n";
            }
        }
예제 #23
0
        private void OpenFolderForInspection(JFolder folder)
        {
            if (folder.FolderName != App.UnifiedFolderName)
            {
                // Get folder pathh
                string folderPath = App.GetParentFolderPath(folder);

                if (Directory.Exists(folderPath))
                {
                    // Open folder in system explorer
                    System.Diagnostics.Process.Start(folderPath);

                    // Auto Hide
                    this.WindowState = WindowState.Minimized;
                }
                else
                {
                    // Update status
                    StatusLabel.Content = "Folder cannot be found on this computer, might you be using offline structures?";
                }
            }
        }
예제 #24
0
        // http://stackoverflow.com/questions/2280049/why-is-the-treeviewitems-mousedoubleclick-event-being-raised-multiple-times-per
        private void OnTreeViewItemMouseDoubleClick(object sender, RoutedEventArgs e)
        {
            TreeViewItem item = sender as TreeViewItem;

            if (item.IsSelected)
            {
                // Open folder or file depending on item type
                JFolder folder = item.DataContext as JFolder;
                if (folder != null)
                {
                    // Don't do this since by default this should be expanding folder action
                    // OpenFolderForInspection(folder);
                    // e.Handled = true;
                }
                else
                {
                    JFile file = item.DataContext as JFile;
                    OpenFileForEditing(file);
                    e.Handled = true;
                }
            }
        }
예제 #25
0
        private void UpdateFolderContent(JFolder selectedFolder)
        {
            // Add to updated folder list for later clean up
            updatedFolders.Add(selectedFolder);

            // Clear Previous Contents
            selectedFolder.Folders.Clear();
            selectedFolder.Files.Clear();
            FolderGeneratorRecursive(selectedFolder);

            // Expand all parents
            JFolder tempRef = selectedFolder;

            while (tempRef != null)
            {
                tempRef.bExpanded = true;
                tempRef           = tempRef.Parent;
            }

            // Save JSon file
            System.IO.File.WriteAllText(CurrentFolderStructurePath, JsonConvert.SerializeObject(JRootFolder, Formatting.Indented)); // Pending Debug
        }
예제 #26
0
        private async void MenuItem_UpdateFolder_Click(object sender, RoutedEventArgs e)
        {
            // Update Json structure at current location
            JFolder folder = (sender as MenuItem).DataContext as JFolder;

            // Update Status
            UpdateStatus("Working on it...");

            // Dispatch a thread for generating content and save to JSON file because that can be quite intensive
            await Task.Factory.StartNew(() => UpdateFolderContent(folder));

            // Render Objects
            List <JFolder> Roots = new List <JFolder>();

            Roots.Add(JRootFolder);
            DirectoryView.ItemsSource = Roots;
            // Automatically scroll to previous location
            // ...

            // Update Status
            UpdateStatus("Folder structure updated to " + CurrentFolderStructurePath);
        }
예제 #27
0
        // Get file path for specifci JFile in tree, considering QuickMatch
        private string GetFilePath(JFile file)
        {
            // QuickMatch® (4/4): Use QuickMatch® for QuickMatched files
            if (file.Parent.FolderName == App.QuickMatchFolderName)
            {
                JFolder matches = QuickMatch.QuickMatchFile(file.FileName, JRootFolderExclusive);

                // If no match found
                if (matches == null)
                {
                    StatusLabel.Content = "No match found.";
                    return(null);
                }
                // If more than one match if found
                if (matches.Files.Count > 1)
                {
                    StatusLabel.Content = "More than one match is found, please do matching manually using magic explorer.";    // Better with a shortcut to it
                    return(null);
                }
                // Otherwise there can be only one match
                else
                {
                    // Get JFile first
                    List <JFolder> subFolders = matches.Folders;
                    while (subFolders[0].Folders.Count != 0)
                    {
                        subFolders = subFolders[0].Folders;
                    }
                    JFile foundFile = subFolders[0].Files[0];
                    // Then get the file's path
                    return(App.GetParentFolderPath(foundFile.Parent) + foundFile.FileName);
                }
            }
            else
            {
                return(App.GetParentFolderPath(file.Parent) + file.FileName);
            }
        }
예제 #28
0
        // Used to expand current folder by one layer: load all items under this folder
        private void FolderGenerator(JFolder currentFolder)
        {
            // First get folder path
            string FolderPath = App.GetParentFolderPath(currentFolder);

            // Then add items to folder
            try
            {
                foreach (string elementPath in Directory.EnumerateDirectories(FolderPath))  // It seems DirectorInfo can provide directory name directly using ToString()
                {
                    string FolderName = elementPath.Substring(elementPath.LastIndexOf("\\") + 1);

                    // Generate JFolders
                    JFolder elementFolder = new JFolder(FolderName);
                    elementFolder.Parent    = currentFolder;
                    elementFolder.bSelected = currentFolder.bSelected;  // Let Children share the same status of selection as parent
                    elementFolder.Folders.Add(new JFolder(TempLoadingFolderString));
                    currentFolder.Folders.Add(elementFolder);
                }
            }
            catch (UnauthorizedAccessException) { }
            catch (PathTooLongException) { }

            try
            {
                foreach (string elementPath in Directory.EnumerateFiles(FolderPath))
                {
                    string FileName = System.IO.Path.GetFileName(elementPath);

                    // Generate JFiles
                    JFile elementFile = new JFile(FileName);
                    elementFile.Parent = currentFolder;
                    currentFolder.Files.Add(elementFile);
                }
            }
            catch (UnauthorizedAccessException) { }
            catch (System.IO.PathTooLongException) { }
        }
예제 #29
0
        private void DirectoryView_Expanded(object sender, RoutedEventArgs e)
        {
            // Extra Folder
            JFolder folder = (e.OriginalSource as TreeViewItem).DataContext as JFolder;   // Or e.Source.SelectedValue or e.Source.SelectedItem, see debug watch

            // If the folder isn't already loaded then load it
            if ((folder.Folders.Count == 1) && (folder.Folders[0].FolderName == TempLoadingFolderString))
            {
                // Clear existing content
                folder.Folders.Clear();

                // Add new content
                FolderGenerator(folder);
                folder.bExpanded = true;

                // Update Display
                List <JFolder> DrivesList = DirectoryView.ItemsSource as List <JFolder>;
                DirectoryView.ItemsSource = null;
                DirectoryView.ItemsSource = DrivesList;

                // Notice currently this is called multiple times when a lot of files are opened
            }
        }
예제 #30
0
        private void UpdateFolderStructureView(string filePath)
        {
            CurrentFolderStructurePath = filePath;  // For later reference during folder operations
            string fileContent = File.ReadAllText(filePath);

            // Read file and update view
            // Status Update
            StatusLabel.Content = "Loading...";

            // Do Statistics
            JFolder.StatisticAmount = 0;
            JFile.StatisticAmount   = 0;

            // Deserialize Results
            JRootFolder = JsonConvert.DeserializeObject <JFolder>(fileContent);
            // Establish Helper Members
            App.EstablishParents(JRootFolder);

            // Store Statistics and Reset them
            int TotalFolders = JFolder.StatisticAmount;
            int TotalFiles   = JFile.StatisticAmount;

            JFolder.StatisticAmount = 0;
            JFile.StatisticAmount   = 0;

            // Render Objects
            List <JFolder> Roots = new List <JFolder>();

            Roots.Add(JRootFolder);
            DirectoryView.ItemsSource = Roots;

            // Update Status
            StatusLabel.Content = String.Format("Folder Structure Loaded: Folders{0}(Total), Files{1}(Total)! ", TotalFolders, TotalFiles);

            // ENable Searching
            SearchKeywordBox.IsEnabled = true;
        }