Ejemplo n.º 1
0
        //検索ボタン押下
        public void DoSearch()
        {
            if (SearchText == null || SearchText.Length == 0)
            {
                return;
            }

            SearchResult = new SearchResultViewModel();

            SearchResult.OwnerViewModel = this;

            SearchResult.IsActive = true;

            //検索
            currentSearch = new NicoNicoSearch(this, SearchText, SearchType, sort_by[SelectedIndex]);

            Task.Run(() => {
                NicoNicoSearchResult result = currentSearch.Search();
                //検索結果をUIに
                SearchResult.Total = string.Format("{0:#,0}", result.Total) + "件の動画";

                SearchResult.List.Clear();
                foreach (NicoNicoVideoInfoEntry node in result.List)
                {
                    SearchResult.List.Add(new SearchResultEntryViewModel(node));
                }

                SearchResult.IsActive = false;
            });
        }
Ejemplo n.º 2
0
        //検索ボタン押下
        public async void Search(string text, int page = 1)
        {
            //ページ数がおかしい場合は一番ギリギリセーフな値にバリデートする
            if (page != 1 && SearchResult.MaxPages < page)
            {
                page = SearchResult.MaxPages;
                SearchResult.CurrentPage = page;
            }

            //どうしてそれで検索出来ると思ったんだ
            if (text == null || text.Length == 0)
            {
                return;
            }

            SearchResult.List.Clear();

            SearchResult.IsActive = true;

            //履歴に存在しなかったら履歴に追加する
            if (!Settings.Instance.SearchHistory.Contains(text))
            {
                //一番上に追加する
                SearchHistory.Insert(0, new SearchHistoryViewModel(this, text));
            }
            else
            {
                //存在したら一番上に持ってくる
                SearchHistory.Move(SearchHistory.IndexOf(SearchHistory.Where(e => e.Content == text).First()), 0);
            }
            ApplyHistory();

            var result = await CurrentSearch.Search(text, SearchType, sortBy[Settings.Instance.SearchIndex], page);

            if (result == null)
            {
                SearchResult.IsActive = false;
                return;
            }

            //検索結果をUIに
            SearchResult.Total    = result.Total;
            SearchResult.MaxPages = result.Total / 30;

            if (SearchResult.Total == 0)
            {
                Status = "0件です";
            }

            foreach (var node in result.List)
            {
                SearchResult.List.Add(new SearchResultEntryViewModel(node));
            }

            SearchResult.IsActive = false;
        }
Ejemplo n.º 3
0
        public void SearchNext()
        {
            SearchResult.IsActive = true;
            Task.Run(() => {
                NicoNicoSearchResult result = currentSearch.Search();

                SearchResult.Total = string.Format("{0:#,0}", result.Total) + "件の動画";

                foreach (NicoNicoVideoInfoEntry node in result.List)
                {
                    SearchResult.List.Add(new SearchResultEntryViewModel(node));
                }

                SearchResult.IsActive = false;
            });
        }
Ejemplo n.º 4
0
        //検索ボタン押下
        public async void Search(string text, int page = 1)
        {
            if (page != 1 && SearchResult.MaxPages < page)
            {
                page = SearchResult.MaxPages;
                SearchResult.CurrentPage = page;
            }

            if (text == null || text.Length == 0)
            {
                return;
            }



            SearchResult.IsActive = true;

            if (!Settings.Instance.SearchHistory.Contains(text))
            {
                Settings.Instance.SearchHistory.Add(text);
            }
            var result = await CurrentSearch.Search(text, SearchType, sortBy[Settings.Instance.SearchIndex], page);

            if (result == null)
            {
                SearchResult.IsActive = false;
                return;
            }

            //検索結果をUIに
            SearchResult.Total    = string.Format("{0:#,0}", result.Total) + "件の動画";
            SearchResult.MaxPages = result.Total / 30;

            SearchResult.List.Clear();
            foreach (var node in result.List)
            {
                SearchResult.List.Add(new SearchResultEntryViewModel(node));
            }

            SearchResult.IsActive = false;
        }