Ejemplo n.º 1
0
        private async void SearchButtonOnClick(object sender, RoutedEventArgs e)
        {
            ChangeBgImage();
            if (CurrentSearch?.IsSearching == true)
            {
                CurrentSearch.StopSearch();
                ChangeSearchVisual(false);
                return;
            }
            ChangeSearchVisual(true);
            StatusTextBlock.Text = "";
            var para = SearchControl.GetSearchPara();

            CurrentSearch      = new SearchSession(Settings, para);
            para.CurrentSearch = CurrentSearch;
            SiteTextBlock.Text = CurrentSearch.GetCurrentSearchStateText();
            Settings.HistoryKeywords.AddHistory(CurrentSearch.CurrentSearchPara.Keyword, Settings);
            MoeExplorer.ResetVisual();
            var t = await CurrentSearch.TrySearchNextPageAsync();

            if (t.IsCanceled || t.Exception != null)
            {
                if (!CurrentSearch.IsSearching)
                {
                    ChangeSearchVisual(false);
                }
            }
            else
            {
                ChangeSearchVisual(false);
                MoeExplorer.AddPage(CurrentSearch);
            }
        }
Ejemplo n.º 2
0
        // Add a new char to current search, causes searc to fire
        private Task <Boolean> UpdateSearchText(AlphaInputViewModel viewModel)
        {
            var currentSearch = CurrentSearch;

            var indexOption = viewModel.CurrentIndexOption == null ? string.Empty : viewModel.CurrentIndexOption.Name;

            if (string.Compare(indexOption, "_") == 0)
            {
                indexOption = " ";
            }

            if (string.Compare(indexOption, "back") == 0)
            {
                if (CurrentSearch.Length > 0)
                {
                    CurrentSearch = CurrentSearch.Substring(0, CurrentSearch.Length - 1);
                }
            }
            else
            {
                CurrentSearch = CurrentSearch + indexOption;
            }

            return(Task.FromResult(true));
        }
Ejemplo n.º 3
0
        private void ApplyConditionalCellFormatting(DataGridViewCell cell, SearchParams.TargetType targType)
        {
            var modified = false;

            if (CurrentSearch != null)
            {
                var matchText = cell.Value as string;

                if (matchText != null && CurrentSearch.Match(targType, matchText))
                {
                    cell.Style.BackColor = Color.GreenYellow;
                    modified             = true;
                }
            }

            if (ShowNullValuesAsGrayed && string.IsNullOrWhiteSpace(cell.Value as string))
            {
                cell.Style.BackColor = Color.Gainsboro;
                modified             = true;
            }

            if (!modified)
            {
                cell.Style.BackColor = dataGridView1.DefaultCellStyle.BackColor;
            }
        }
 private void Start()
 {
     _allSearch         = GameObject.Find("Canvas/ItemMenuCanvas/ClickedItemCanvas/VoiceCanvas/InsertAllPath/InputAllPath").GetComponent <AllSearch>();
     _currentSearch     = GameObject.Find("Canvas/ItemMenuCanvas/ClickedItemCanvas/VoiceCanvas/InsertCurrentPath/InputCurrentPath").GetComponent <CurrentSearch>();
     _scrollRect        = GameObject.Find("Canvas/ItemMenuCanvas/ClickedItemCanvas/VoiceCanvas/Scroll View").GetComponent <ScrollRect>();
     _startDBController = GameObject.Find("StartDBController").GetComponent <StartDBController>();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Clear all of the searches and go to the Top List without any chosen results
        /// </summary>
        public void ClearSearches()
        {
            AllSearches.Clear();
            var newSearch = new SearchVM();

            AllSearches.Add(newSearch);
            CurrentSearch = newSearch;
            CurrentSearch.GoToTopList();
        }
Ejemplo n.º 6
0
        private async Task StartSearch(string from)
        {
            if (!SearchFetchInProgress)
            {
                SearchFetchInProgress = true;
                await CurrentSearch.Start(from);

                SearchFetchInProgress = false;
            }
        }
Ejemplo n.º 7
0
        private async Task PreviousSearch()
        {
            if (CurrentSearch != null && !SearchFetchInProgress && CurrentSearch.HasPrevious)
            {
                SearchFetchInProgress = true;
                await CurrentSearch.Previous();

                SearchFetchInProgress = false;
            }
        }
Ejemplo n.º 8
0
        private async Task NextSearch()
        {
            if (CurrentSearch != null && !SearchFetchInProgress && CurrentSearch.HasNext)
            {
                SearchFetchInProgress = true;
                await CurrentSearch.Next();

                SearchFetchInProgress = false;
            }
        }
Ejemplo n.º 9
0
        private void AddSearchItem(object item)
        {
            var itemString = (string)item;

            if (!string.IsNullOrWhiteSpace(itemString))
            {
                var needNewline = PageContent != "" && !PageContent.EndsWith("\n");
                var newLine     = needNewline ? "\n" : "";
                PageContent += newLine + CurrentSearch.FullItemString(itemString);
                _navigatorService.NavigateToUploadPage();
            }
        }
Ejemplo n.º 10
0
        public object GetCollectionElement(PropertyInfo prop, int collectionIndex)
        {
            var collection = prop.GetValue(_object) as IEnumerable <object>;

            if (collection == null)
            {
                return(null);
            }
            var skipCount = CurrentSearch.GetCollectionNo(collectionIndex) - 1;

            return(collection.Skip(skipCount).FirstOrDefault());
        }
Ejemplo n.º 11
0
        public async Task GetImage()
        {
            try
            {
                var endpoint = new ImageEndpoint(client);
                var image    = await endpoint.GetImageAsync("  ");

                CurrentSearch.Clear();
                CurrentSearch.Add(fillPicture(image));
                Debug.Write("Image retrieved. Image Url: " + image.Link);
            }
            catch (ImgurException imgurEx)
            {
                Debug.Write("An error occurred getting an image from Imgur.");
                Debug.Write(imgurEx.Message);
            }
        }
Ejemplo n.º 12
0
        // Normally you should call RequestRefreshTreeView() instead of this function
        public void RefreshTreeView()
        {
            if (Disposing || IsDisposed || Program.Exiting)
            {
                return;
            }

            Program.Invoke(Program.MainWindow, () =>
            {
                if (ignoreRefreshTreeView > 0)
                {
                    calledRefreshTreeView = true;
                    return;
                }

                ignoreRefreshTreeView++;  // Some events can be ignored while rebuilding the tree

                try
                {
                    var newRootNode = treeBuilder.CreateNewRootNode(CurrentSearch.AddFullTextFilter(searchTextBox.Text), NavigationMode);
                    treeBuilder.RefreshTreeView(newRootNode, searchTextBox.Text, NavigationMode);
                }
                catch (Exception exn)
                {
                    log.Error(exn, exn);
#if DEBUG
                    if (Debugger.IsAttached)
                    {
                        throw;
                    }
#endif
                }
                finally
                {
                    ignoreRefreshTreeView--;
                }

                if (TreeViewRefreshed != null)
                {
                    TreeViewRefreshed();
                }
            });
        }
Ejemplo n.º 13
0
    private void SearchLog()
    {
        int howManyItems = DataAccessContext.ProductRepository.CountQuickSearchResult(
            StoreContext.Culture,
            CurrentSearch,
            DataAccessContext.Configurations.GetValueList("ProductSearchBy"),
            "ProductID",
            new StoreRetriever().GetCurrentStoreID(),
            DataAccessContext.Configurations.GetValue("RootCategory", new StoreRetriever().GetStore()),
            DataAccessContext.Configurations.GetValue("SearchMode", new StoreRetriever().GetStore()));

        if (howManyItems > 0)
        {
            SearchLogAccess.Create(CurrentSearch.ToLower().Trim(), true);
        }
        else
        {
            SearchLogAccess.Create(CurrentSearch.ToLower().Trim(), false);
        }
    }
Ejemplo n.º 14
0
        public async Task GetRandomGalleryAsync()
        {
            var endpoint = new GalleryEndpoint(client);
            var images   = await endpoint.GetRandomGalleryAsync();

            CurrentSearch.Clear();
            foreach (IGalleryItem item in images)
            {
                if (item is IGalleryImage)
                {
                    CurrentSearch.Add(fillPicture(item as IGalleryImage));
                }
                else if (item is IGalleryAlbum)
                {
                    if ((item as IGalleryAlbum).Images.First() != null)
                    {
                        CurrentSearch.Add(fillPicture((item as IGalleryAlbum).Images.First()));
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public async Task GetGalleryTagAsync(string tagName)
        {
            var endpoint = new GalleryEndpoint(client);
            var tag      = await endpoint.GetGalleryTagAsync(tagName);

            CurrentSearch.Clear();
            foreach (IGalleryItem item in tag.Items)
            {
                if (item is IGalleryImage)
                {
                    CurrentSearch.Add(fillPicture(item as IGalleryImage));
                }
                else if (item is IGalleryAlbum)
                {
                    if ((item as IGalleryAlbum).Images.First() != null)
                    {
                        CurrentSearch.Add(fillPicture((item as IGalleryAlbum).Images.First()));
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private async void NextPageButtonOnClick(object sender, RoutedEventArgs e)
        {
            ChangeSearchVisual(true);
            var t = await CurrentSearch.TrySearchNextPageAsync();

            if (t.IsCanceled || t.Exception != null)
            {
                if (!CurrentSearch.IsSearching)
                {
                    ChangeSearchVisual(false);
                }
            }
            else
            {
                ChangeSearchVisual(false);
                if (Settings.IsClearImgsWhenSerachNextPage)
                {
                    MoeExplorer.ResetVisual();
                }
                MoeExplorer.AddPage(CurrentSearch);
            }
        }
Ejemplo n.º 17
0
        public void SelectNextSearchResult()
        {
            if (CurrentSearch == null)
            {
                return;
            }

            var keyColumn = dataGridView1.Columns[Properties.Resources.ColNameKey];

            var currentRow    = dataGridView1.CurrentCell?.RowIndex ?? dataGridView1.RowCount;
            var currentColumn = dataGridView1.CurrentCell?.ColumnIndex ?? -1;

            foreach (DataGridViewRow row in dataGridView1.Rows.Cast <DataGridViewRow>().ToList().Rotate(currentRow))
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                    if (cell.ColumnIndex <= currentColumn)
                    {
                        continue;
                    }

                    if (!(cell.Value is string s))
                    {
                        continue;
                    }

                    if (CurrentSearch.Match(cell.OwningColumn == keyColumn ? SearchParams.TargetType.Key : SearchParams.TargetType.Text, s))
                    {
                        dataGridView1.CurrentCell = cell;
                        return;
                    }
                }
                // Skip cells only in the currently selected row (the selected row is first in order thanks to Rotate call)
                currentColumn = -1;
            }
        }