public SearchViewModel(ref bool IsFirstPageOpen, Action searchBoxFocus) { this.IsWidthBigEnough = true; this.History = new HistoryManager(); this.SearchBoxFocus = searchBoxFocus; this.IsMasterProgressBarVisible = Visibility.Collapsed; this.Query = ""; this.IsSearchBoxEnabled = true; this.IsMoreButtonVisible = Visibility.Collapsed; this.IsErrorMessageVisible = Visibility.Collapsed; this.IsDetailProgressBarVisible = Visibility.Collapsed; this.IsDefinitionViewerVisible = Visibility.Collapsed; this.IsDetailGridVisible = Visibility.Visible; if (IsFirstPageOpen) { this.SearchResults = new ObservableCollection <SearchResultItem>(SearchResultStaticPage.GetHomeTab()); this.Definitions = WordDetailStaticPage.GetHomepage(HandleHyperlinkClick, HandleRecentWordClick); this.IsDefinitionViewerVisible = Visibility.Visible; this.SearchResultSelectedIndex = 0; IsFirstPageOpen = false; } else { this.SearchResults = new ObservableCollection <SearchResultItem>(); this.Definitions = new WordDetailItem(HandleHyperlinkClick); this.SearchResultSelectedIndex = -1; } }
public async void DisplayWordDetail(SearchResultItem clickedItem) { if (NetworkCheck() == false) { return; } if (clickedItem.target_code == -200) { //시작 누를 시 동작 Definitions = WordDetailStaticPage.GetHomepage(HandleHyperlinkClick, HandleRecentWordClick); IsDetailGridVisible = Visibility.Visible; if (!IsWidthBigEnough) { IsTitleBarBackButtonEnabled = true; } RaisePropertyChanged("Definitions", "IsDetailGridVisible", "IsTitleBarBackButtonEnabled"); return; } //일반 단어 클릭시 동작 //되돌리기 위한 기록 History.RecordDefinition(Query, lastSearchedQuery, Definitions, SearchResultSelectedIndex, false, IsMoreButtonVisible); //뜻풀이 감추기 IsDefinitionViewerVisible = Visibility.Collapsed; IsDetailGridVisible = Visibility.Visible; if (!IsWidthBigEnough) { IsTitleBarBackButtonEnabled = true; } RaisePropertyChanged("IsDefinitionViewerVisible", "IsDetailGridVisible", "IsTitleBarBackButtonEnabled"); DefinitionParser definitionParser = new DefinitionParser((Visibility visibility) => { IsDetailProgressBarVisible = visibility; RaisePropertyChanged("IsDetailProgressBarVisible"); }, HandleHyperlinkClick); WordDetailItem definitionItem = await definitionParser.GetWordDetail(clickedItem.target_code.ToString(), clickedItem.word, clickedItem.sup_no); if (definitionItem != null) { Definitions = definitionItem; } IsDefinitionViewerVisible = Visibility.Visible; RaisePropertyChanged("Definitions", "IsDefinitionViewerVisible", "CanGoBack", "CanGoForward"); }
public void GoHome() { // 되돌리기 위한 기록 History.RecordAll(Query, lastSearchedQuery, SearchResults, Definitions, SearchResultSelectedIndex, false, IsMoreButtonVisible); IsDefinitionViewerVisible = Visibility.Collapsed; RaisePropertyChanged("IsDefinitionViewerVisible", "CanGoBack", "CanGoForward"); // 검색어 지우기 Query = ""; // 검색 결과 지우기 SearchResults.Clear(); List <SearchResultItem> homeTab = SearchResultStaticPage.GetHomeTab(); foreach (SearchResultItem item in homeTab) { SearchResults.Add(item); } SearchResultSelectedIndex = 0; Definitions = WordDetailStaticPage.GetHomepage(HandleHyperlinkClick, HandleRecentWordClick); IsDefinitionViewerVisible = Visibility.Visible; RaisePropertyChanged("Query", "SearchResultSelectedIndex", "Definitions", "IsDefinitionViewerVisible"); }