Пример #1
0
 private void UpdateInfoPanelVisibility(TCFile newSelection)
 {
     if (SelectedFile != null && newSelection != null && (selectedFile.FilePath != newSelection.FilePath))
     {
         SelectedFile.IsInfoMenuOpen = false;
     }
 }
Пример #2
0
        public void AddRemoveFavorite(TCFile selection)
        {
            if (selectedFile != null)
            {
                if (_referenceService.IsFileInFavorite(selection.FilePath))
                {
                    _referenceService.RemoveFromFavourites(selection.FilePath);
                    SelectedFile.IsFavorited = false;
                }
                else
                {
                    cc310_reference_centre_file file = new cc310_reference_centre_file();
                    file.file_nm = selection.FileNameText;

                    file.file_full_nm = selection.FilePath;
                    //file.file_size_nbr = selection.File.Length; //Do we really need this?
                    file.file_path_txt = selection.FilePath;
                    _referenceService.AddToFavourites(file);

                    selection.IsFavorited = true;
                }

                UpdateFavoriteTitle(selection);

                if (isFavoriteView)
                {
                    FavoritesLoader();
                }
            }
        }
Пример #3
0
        private void HandleFolderClick(TCFile itemGotClicked)
        {
            var tempPreviousFolder = previousFolder;
            var tempCurrentFolder  = currentFolder;

            previousFolder = currentFolder;
            currentFolder  = itemGotClicked.FilePath;

            if (!LoadData())
            {
                previousFolder = tempPreviousFolder;
                currentFolder  = tempCurrentFolder;
            }
        }
Пример #4
0
 private void RenderFilesInView(List <FileInfo> files, bool isSearchResults)
 {
     try
     {
         IsCheckIOBusy       = true;
         IsRightPanelVisible = false;
         foreach (var mFile in files)
         {
             //Get Icons
             string shortCutPath = mFile.FullName;
             string icon         = IconUtilities.GetIconString(shortCutPath);
             //ImageSource image = null;
             //string extension = IconUtilities.GetExtension(shortCutPath);
             //try
             //{
             //    if (extension == ".lnk")
             //    {
             //        image = IconUtilities.GetIconForShortCut(shortCutPath);
             //    }
             //    else
             //    {
             //        image = IconUtilities.GetIcon(shortCutPath);
             //    }
             //    if (image == null)
             //    {
             //        image = folderIcon;
             //    }
             //}
             //catch (Exception)
             //{
             //    image = folderIcon;
             //}
             var    isFavorite = _referenceService.IsFileInFavorite(mFile.FullName);
             TCFile file       = new TCFile(mFile.Name, mFile.FullName, previousFolder, TCFile.TCType.FILE, icon);
             file.IsFavorited          = isFavorite;
             file.DoubleClickEvent    += File_DoubleClickEvent;
             file.FileClickedEvent    += File_FileClickedEvent;
             file.InfoPanelClickEvent += File_InfoPanelClickEvent;
             file.FavouriteClickEvent += File_FavouriteClickEvent;
             FileCollection.Add(file);
         }
         IsCheckIOBusy = false;
     }
     catch (Exception e)
     {
         Console.WriteLine("Render Files In View Failed: {0}", e.ToString());
     }
 }
Пример #5
0
 private void RenderDirectoriesInView(List <DirectoryInfo> directories)
 {
     try
     {
         foreach (var dir in directories)
         {
             TCFile file = new TCFile(dir.Name, dir.FullName, previousFolder, TCFile.TCType.FOLDER, IconUtilities.FolderIcon);
             file.FileClickedEvent    += File_FileClickedEvent;
             file.FavouriteClickEvent += File_FavouriteClickEvent;
             FileCollection.Add(file);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("Render Folders In View Failed: {0}", e.ToString());
     }
 }
Пример #6
0
        private void HandleFileClick(TCFile newSelection)
        {
            try
            {
                UpdateInfoPanelVisibility(newSelection);

                SelectedFile = newSelection;
                if (IsRightPanelVisible)
                {
                    RenderRightPanel();
                    SelectedFile.IsInfoMenuOpen = IsRightPanelVisible;
                }
                OpenFile();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Пример #7
0
        private void RenderFavorites(ObservableCollection <cc310_reference_centre_file> favorites)
        {
            IsCheckIOBusy = true;
            FileCollection.Clear();

            foreach (var mFile in favorites)
            {
                //Get Icons

                string shortCutPath = mFile.file_full_nm;
                string icon         = IconUtilities.GetIconString(shortCutPath);

                FileInfo fileInfo = new FileInfo(mFile.file_path_txt);
                TCFile   file     = new TCFile(fileInfo.Name, fileInfo.FullName, previousFolder, TCFile.TCType.FAVORITE, icon); //new TCFile(fileInfo, image, true);
                file.DoubleClickEvent    += File_DoubleClickEvent;
                file.FileClickedEvent    += File_FileClickedEvent;
                file.InfoPanelClickEvent += File_InfoPanelClickEvent;
                file.FavouriteClickEvent += File_FavouriteClickEvent;
                FileCollection.Add(file);
            }
            IsCheckIOBusy = false;
        }
Пример #8
0
 private void UpdateFavoriteTitle(TCFile selection)
 {
     IsFileInFavorites = selection.IsFavorited; //_referenceService.IsFileInFavorite(fullPath);
 }
Пример #9
0
 private void HandleMenuClick(TCFile itemGotClicked)
 {
     HandleFolderClick(itemGotClicked);
 }
Пример #10
0
        private void GenerateMenu(DirectoryInfo directory)
        {
            try
            {
                bool isRoot        = (rootFolderPath == currentFolder);
                var  newFolderMenu = new List <TCFile>();
                int  i             = 0;
                var  menuItem      = new TCFile(directory.Name, directory.FullName, previousFolder, TCFile.TCType.MENU, null);//new TCFile(directory, i, false);
                menuItem.IsFolder          = true;
                menuItem.FileClickedEvent += MenuItem_FileClickedEvent;
                newFolderMenu.Add(menuItem);


                if (!isRoot)
                {
                    //Create Navigation Bar
                    var navPreviousDir = GetPreviousDirectory(directory);
                    i++;
                    while (true)
                    {
                        menuItem = new TCFile(navPreviousDir.Name, navPreviousDir.FullName, previousFolder, TCFile.TCType.MENU, null);
                        menuItem.IsSystemItem      = true;
                        menuItem.IsFolder          = true;
                        menuItem.FileClickedEvent += MenuItem_FileClickedEvent;
                        menuItem.Id = i;
                        newFolderMenu.Add(menuItem);
                        if (navPreviousDir.FullName == rootFolder.FullName)
                        {
                            break;
                        }
                        navPreviousDir = GetPreviousDirectory(navPreviousDir);
                        i++;
                    }

                    //Get Previous Folder
                    var previousDirectory = GetPreviousDirectory(directory);
                    if (previousDirectory != null)
                    {
                        TCFile file = new TCFile("...", previousDirectory.FullName, previousDirectory.FullName, TCFile.TCType.PREVIOUS, IconUtilities.FolderIcon);
                        file.IsSystemItem      = true;
                        file.FileClickedEvent += File_FileClickedEvent;
                        FileCollection.Add(file);
                    }
                    else
                    {
                        Console.WriteLine("Error: Previous directory does not exist!");
                    }
                }


                //Add Menu Items
                newFolderMenu = newFolderMenu.OrderByDescending(x => x.Id).ToList();
                foreach (var item in newFolderMenu)
                {
                    FolderMenu.Add(item);
                }
            }
            catch (Exception e)
            {
            }
        }
Пример #11
0
        public void Search()
        {
            try
            {
                if (!string.IsNullOrEmpty(SearchTerm))
                {
                    IsCheckIOBusy = true;
                    FileCollection.Clear();

                    IsRightPanelVisible = false;
                    if (!isFavoriteView)
                    {
                        IsFavoriteView = false;
                        if (!isSearchInActive)
                        {
                            searchFolder = currentFolder;
                            previousFolderBeforeSearch = previousFolder;
                        }

                        if (lastSearchTerm != searchTerm)
                        {
                            lastSearchTerm = searchTerm;
                            ClearMenu();

                            var clearSearchName = Properties.Resource.lblClearSearchResults;
                            var clearSearchMenu = new TCFile(clearSearchName, searchFolder, previousFolderBeforeSearch, TCFile.TCType.CLEAR, null);
                            clearSearchMenu.FileClickedEvent += MenuItem_FileClickedEvent;
                            FolderMenu.Add(clearSearchMenu);

                            var searchItemName    = Properties.Resource.lblSearchResults;
                            var searchResultsMenu = new TCFile(searchItemName, searchFolder, previousFolderBeforeSearch, TCFile.TCType.SEARCH, null);
                            searchResultsMenu.FileClickedEvent += MenuItem_FileClickedEvent;
                            FolderMenu.Add(searchResultsMenu);
                        }

                        try
                        {
                            List <FileInfo> searchResults           = new List <FileInfo>();
                            var             fileSearchStringResults = SafeFileEnumerator.EnumerateFiles(searchFolder, $"*{SearchTerm}*", SearchOption.AllDirectories);
                            foreach (var filePath in fileSearchStringResults)
                            {
                                FileInfo fileToAdd = new FileInfo(filePath);
                                searchResults.Add(fileToAdd);
                            }
                            isSearchInActive = true;
                            RenderFilesInView(searchResults, true);
                        }
                        catch (UnauthorizedAccessException ue)
                        {
                            Console.WriteLine(ue.Message);
                        }
                        catch (FileNotFoundException fnfe)
                        {
                            Console.WriteLine(fnfe.Message);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }

                        try
                        {
                            List <DirectoryInfo> searchDirResults = new List <DirectoryInfo>();
                            var fileSearchStringResults           = SafeFileEnumerator.EnumerateDirectories(searchFolder, $"*{SearchTerm}*", SearchOption.AllDirectories);
                            foreach (var filePath in fileSearchStringResults)
                            {
                                DirectoryInfo fileToAdd = new DirectoryInfo(filePath);
                                searchDirResults.Add(fileToAdd);
                            }
                            RenderDirectoriesInView(searchDirResults);
                        }
                        catch (UnauthorizedAccessException ue)
                        {
                            Console.WriteLine(ue.Message);
                        }
                        catch (DirectoryNotFoundException dnfe)
                        {
                            Console.WriteLine(dnfe.Message);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                    else
                    {
                        var searchResults = _referenceService.SearchFavorite(SearchTerm);
                        RenderFavorites(searchResults);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Search failed: {0}", e.ToString());
            }
        }