Пример #1
0
        [ExcludeFromCodeCoverage] // TODO: could maybe remove after creating a test of this
        private void GetFiles()
        {
            var currentView = RegionManager.Regions[RegionNames.MAIN_REGION].ActiveViews.FirstOrDefault();

            if (currentView == null || !currentView.ToString().Equals(MyView))
            {
                return;
            }

            FileCollection.Clear();

            foreach (var file in Directory.GetFiles(SelectedPath, EXTENSION))
            {
                var fi = new FileInfo(file);

                FileCollection.Add(new Clean3DsFiles()
                {
                    FullFilePath = Path.GetFullPath(file),
                    FileName     = Path.GetFileNameWithoutExtension(file),
                    CreatedTime  = fi.CreationTimeUtc.ToLocalTime(),
                    FileSize     = (fi.Length / 1024) + 1,
                    IsSelected   = false
                });
            }

            EventAggregator.GetEvent <FilesUpdateEvent>().Publish(FileCollection);

            if (FileCollection.Count < 1)
            {
                return;
            }

            StartGenerationCommand.RaiseCanExecuteChanged();
        }
Пример #2
0
 public void ClearFileFolderMenu()
 {
     FileCollection.Clear();
     if (!isSearchInActive)
     {
         ClearMenu();
     }
 }
Пример #3
0
 private void OnFileEnumResponse(string rsp)
 {
     if (FileCollection != null)
     {
         FileCollection.Clear();
         var list = JsonConvert.DeserializeObject <List <WinFileModel> >(rsp);
         foreach (var obj in list)
         {
             FileCollection.Add(Tuple.Create <string, bool>(obj.Name, obj.IsFolder));
         }
     }
 }
Пример #4
0
 private void OnFileEnumResponse(CommandMessageRsp rsp)
 {
     if (rsp.RspType == CommandMessageRsp.StringDataType)
     {
         if (FileCollection != null)
         {
             FileCollection.Clear();
             var list = JsonConvert.DeserializeObject <List <WinFileModel> >(rsp.StringCommandRsp);
             foreach (var obj in list)
             {
                 FileCollection.Add(Tuple.Create <string, bool>(obj.Name, obj.IsFolder));
             }
         }
     }
 }
Пример #5
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;
        }
Пример #6
0
 /// <summary>
 /// Clear the file list
 /// </summary>
 private void ClearFilesList()
 {
     _files.Clear();
 }
Пример #7
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());
            }
        }