コード例 #1
0
ファイル: QueryFolder.cs プロジェクト: qdraw/starsky
        /// <summary>
        /// Show previous en next items in the folder view.
        /// There is equivalent class for prev next in the display view
        /// </summary>
        /// <param name="currentFolder">subPath style</param>
        /// <returns>relative object</returns>
        public RelativeObjects GetNextPrevInFolder(string currentFolder)
        {
            if (currentFolder != "/")
            {
                PathHelper.RemoveLatestSlash(currentFolder);
            }

            // We use breadcrumbs to get the parent folder
            var parentFolderPath = FilenamesHelper.GetParentPath(currentFolder);

            var itemsInSubFolder = QueryGetNextPrevInFolder(parentFolderPath);

            var photoIndexOfSubFolder = itemsInSubFolder.FindIndex(p => p.FilePath == currentFolder);

            var relativeObject = new RelativeObjects();

            if (photoIndexOfSubFolder != itemsInSubFolder.Count - 1 && currentFolder != "/")
            {
                // currentFolder != "/" >= on the home folder you will automatically go to a subfolder
                relativeObject.NextFilePath = itemsInSubFolder[photoIndexOfSubFolder + 1]?.FilePath;
                relativeObject.NextHash     = itemsInSubFolder[photoIndexOfSubFolder + 1]?.FileHash;
            }

            if (photoIndexOfSubFolder >= 1)
            {
                relativeObject.PrevFilePath = itemsInSubFolder[photoIndexOfSubFolder - 1]?.FilePath;
                relativeObject.PrevHash     = itemsInSubFolder[photoIndexOfSubFolder - 1]?.FileHash;
            }

            return(relativeObject);
        }
コード例 #2
0
        private static RelativeObjects GetNextPrevInSubFolder(
            FileIndexItem currentFileIndexItem,
            List <FileIndexItem> fileIndexItemsList, SortType sortType)
        {
            // Check if this is item is not !deleted! yet
            if (currentFileIndexItem == null)
            {
                return(new RelativeObjects());
            }

            fileIndexItemsList = SortHelper.Helper(fileIndexItemsList, sortType).ToList();

            var currentIndex   = fileIndexItemsList.FindIndex(p => p.FilePath == currentFileIndexItem.FilePath);
            var relativeObject = new RelativeObjects();

            if (currentIndex != fileIndexItemsList.Count - 1)
            {
                relativeObject.NextFilePath = fileIndexItemsList[currentIndex + 1].FilePath;
                relativeObject.NextHash     = fileIndexItemsList[currentIndex + 1].FileHash;
            }

            if (currentIndex >= 1)
            {
                relativeObject.PrevFilePath = fileIndexItemsList[currentIndex - 1].FilePath;
                relativeObject.PrevHash     = fileIndexItemsList[currentIndex - 1].FileHash;
            }

            return(relativeObject);
        }
コード例 #3
0
ファイル: RelativeObjectsTest.cs プロジェクト: qdraw/starsky
        public void relativeObjects_args_1()
        {
            var relativeObjects = new RelativeObjects(true, new List <ColorClassParser.Color> {
                ColorClassParser.Color.Winner
            });
            var args = relativeObjects.Args;

            Assert.AreEqual(new KeyValuePair <string, string>("colorclass", "1"), args.FirstOrDefault());
        }
コード例 #4
0
        public IActionResult SearchRelative(string f, string t, int p = 0)
        {
            // Json api && View()
            var searchViewModel = _search.Search(t, p);

            var photoIndexOfQuery = GetIndexFilePathFromSearch(searchViewModel, f);

            if (photoIndexOfQuery == -1)
            {
                return(NotFound("image not found in search result"));
            }

            var args = new Dictionary <string, string>
            {
                { "p", p.ToString() },
                { "t", t }
            };

            var relativeObject = new RelativeObjects {
                Args = args
            };

            if (photoIndexOfQuery != searchViewModel.FileIndexItems.Count - 1)
            {
                relativeObject.NextFilePath = searchViewModel.FileIndexItems[photoIndexOfQuery + 1]?.FilePath;
                relativeObject.NextHash     = searchViewModel.FileIndexItems[photoIndexOfQuery + 1]?.FileHash;
            }

            if (photoIndexOfQuery >= 1)
            {
                relativeObject.PrevFilePath = searchViewModel.FileIndexItems[photoIndexOfQuery - 1]?.FilePath;
                relativeObject.PrevHash     = searchViewModel.FileIndexItems[photoIndexOfQuery - 1]?.FileHash;
            }

            return(Json(relativeObject));
        }