From 8b54c6be009c2a1d91e181e9fb2fc4e7e2edbd4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=B0=E9=98=9F=E7=9A=84=E5=81=B6=E5=83=8F-=E5=B2=9B?= =?UTF-8?q?=E9=A3=8E=E9=85=B1=EF=BC=81?= Date: Mon, 11 Jan 2021 13:40:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=B2=97=E7=95=A5=E8=BD=AC=E7=A7=BB?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=88=B0=E5=AF=B9=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PixivFSUWP/MainPage.xaml.cs | 19 +-- PixivFSUWP/PixivFSUWP.csproj | 6 +- .../{SearchPage.xaml => SearchDialog.xaml} | 19 +-- ...earchPage.xaml.cs => SearchDialog.xaml.cs} | 150 +++++++++--------- 4 files changed, 99 insertions(+), 95 deletions(-) rename PixivFSUWP/{SearchPage.xaml => SearchDialog.xaml} (95%) rename PixivFSUWP/{SearchPage.xaml.cs => SearchDialog.xaml.cs} (72%) diff --git a/PixivFSUWP/MainPage.xaml.cs b/PixivFSUWP/MainPage.xaml.cs index 3448d85..3e49778 100644 --- a/PixivFSUWP/MainPage.xaml.cs +++ b/PixivFSUWP/MainPage.xaml.cs @@ -183,15 +183,16 @@ private void BtnMe_Click(object sender, RoutedEventArgs e) private async void BtnSearch_Click(object sender, RoutedEventArgs e) { - try - { - if (ContentFrame.Content is SearchPage) - await (ContentFrame.Content as SearchPage).ShowSearch(); - else - ContentFrame.Navigate(typeof(SearchPage), WaterfallPage.ListContent.SearchResult, App.FromRightTransitionInfo); - } - //吞掉异常,这个异常没有意义 - catch { } + await new SearchDialog().ShowAsync(); + //try + //{ + // if (ContentFrame.Content is SearchPage) + // await (ContentFrame.Content as SearchPage).ShowSearch(); + // else + // ContentFrame.Navigate(typeof(SearchPage), WaterfallPage.ListContent.SearchResult, App.FromRightTransitionInfo); + //} + ////吞掉异常,这个异常没有意义 + //catch { } } public void UpdateNavButtonState() diff --git a/PixivFSUWP/PixivFSUWP.csproj b/PixivFSUWP/PixivFSUWP.csproj index a8e1a94..e254b1a 100644 --- a/PixivFSUWP/PixivFSUWP.csproj +++ b/PixivFSUWP/PixivFSUWP.csproj @@ -191,8 +191,8 @@ ReportIssuePage.xaml - - SearchPage.xaml + + SearchDialog.xaml SettingsPage.xaml @@ -276,7 +276,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/PixivFSUWP/SearchPage.xaml b/PixivFSUWP/SearchDialog.xaml similarity index 95% rename from PixivFSUWP/SearchPage.xaml rename to PixivFSUWP/SearchDialog.xaml index 2a7e2b9..decea16 100644 --- a/PixivFSUWP/SearchPage.xaml +++ b/PixivFSUWP/SearchDialog.xaml @@ -1,5 +1,5 @@ - - + + + + - + - - - - - + diff --git a/PixivFSUWP/SearchPage.xaml.cs b/PixivFSUWP/SearchDialog.xaml.cs similarity index 72% rename from PixivFSUWP/SearchPage.xaml.cs rename to PixivFSUWP/SearchDialog.xaml.cs index cf9b97a..e0dd9bd 100644 --- a/PixivFSUWP/SearchPage.xaml.cs +++ b/PixivFSUWP/SearchDialog.xaml.cs @@ -28,43 +28,45 @@ namespace PixivFSUWP /// /// 可用于自身或导航至 Frame 内部的空白页。 /// - public sealed partial class SearchPage : Page, IGoBackFlag + public sealed partial class SearchDialog { string lastWord = null; int lastSearchTarget = -1; int lastSort = -1; int lastDuration = -1; - public SearchPage() + public SearchDialog() { this.InitializeComponent(); + Title = GetResourceString("SearchPagePlain"); + CloseButtonText = GetResourceString("CancelPlain"); } - private bool _backflag { get; set; } = false; + //private bool _backflag { get; set; } = false; - public void SetBackFlag(bool value) - { - _backflag = value; - } + //public void SetBackFlag(bool value) + //{ + // _backflag = value; + //} - protected override void OnNavigatedFrom(NavigationEventArgs e) - { - base.OnNavigatedFrom(e); - if (!_backflag) - { - Data.OverAll.SearchResultList?.PauseLoading(); - if (e.Parameter is ValueTuple tuple) - { - Data.Backstack.Default.Push - (typeof(SearchPage), - new ValueTuple - (WaterfallPage.ListContent.SearchResult, tuple.Item2)); - } - else - Data.Backstack.Default.Push(typeof(SearchPage), WaterfallPage.ListContent.SearchResult); - } - ((Frame.Parent as Grid)?.Parent as MainPage)?.UpdateNavButtonState(); - } + //protected override void OnNavigatedFrom(NavigationEventArgs e) + //{ + // base.OnNavigatedFrom(e); + // if (!_backflag) + // { + // Data.OverAll.SearchResultList?.PauseLoading(); + // if (e.Parameter is ValueTuple tuple) + // { + // Data.Backstack.Default.Push + // (typeof(SearchPage), + // new ValueTuple + // (WaterfallPage.ListContent.SearchResult, tuple.Item2)); + // } + // else + // Data.Backstack.Default.Push(typeof(SearchPage), WaterfallPage.ListContent.SearchResult); + // } + // ((Frame.Parent as Grid)?.Parent as MainPage)?.UpdateNavButtonState(); + //} async Task> getTrendingTags() { @@ -92,29 +94,29 @@ async Task loadContents() panelTags.ItemsSource = tags; } - protected override void OnNavigatedTo(NavigationEventArgs e) - { - base.OnNavigatedTo(e); - if (e.Parameter is WaterfallPage.ListContent) - { - _ = loadContents(); - SearchResultList?.StopLoading(); - } - else if (e.Parameter is ValueTuple) - { - resultFrame.Navigate(typeof(WaterfallPage), e.Parameter); - grdSearchPanel.Visibility = Visibility.Collapsed; - if (txtWord.Text.Trim() != lastWord || cbSearchTarget.SelectedIndex != lastSearchTarget || - cbSort.SelectedIndex != lastSort || cbDuration.SelectedIndex != lastDuration) - { - lastWord = txtWord.Text.Trim(); - lastSearchTarget = cbSearchTarget.SelectedIndex; - lastSort = cbSort.SelectedIndex; - lastDuration = cbDuration.SelectedIndex; - } - } - ((Frame.Parent as Grid)?.Parent as MainPage)?.SelectNavPlaceholder(GetResourceString("SearchPagePlain")); - } + //protected override void OnNavigatedTo(NavigationEventArgs e) + //{ + // base.OnNavigatedTo(e); + // if (e.Parameter is WaterfallPage.ListContent) + // { + // _ = loadContents(); + // SearchResultList?.StopLoading(); + // } + // else if (e.Parameter is ValueTuple) + // { + // resultFrame.Navigate(typeof(WaterfallPage), e.Parameter); + // grdSearchPanel.Visibility = Visibility.Collapsed; + // if (txtWord.Text.Trim() != lastWord || cbSearchTarget.SelectedIndex != lastSearchTarget || + // cbSort.SelectedIndex != lastSort || cbDuration.SelectedIndex != lastDuration) + // { + // lastWord = txtWord.Text.Trim(); + // lastSearchTarget = cbSearchTarget.SelectedIndex; + // lastSort = cbSort.SelectedIndex; + // lastDuration = cbDuration.SelectedIndex; + // } + // } + // ((Frame.Parent as Grid)?.Parent as MainPage)?.SelectNavPlaceholder(GetResourceString("SearchPagePlain")); + //} public async Task ShowSearch() { @@ -224,30 +226,30 @@ private async void btnSauceNAO_Click(object sender, RoutedEventArgs e) string SAUCENAO_API_KEY, IMGUR_API_KEY; Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; //读取设置项 - if (localSettings.Values["SauceNAOAPI"] as string == null) - { - Frame.Navigate(typeof(SettingsPage),null, App.FromRightTransitionInfo); - SAUCENAO_API_KEY = sauceNAOAPI; - return; - } - else if ((localSettings.Values["SauceNAOAPI"] as string).Length == 0) - { - Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); - SAUCENAO_API_KEY = sauceNAOAPI; - return; - } - if (localSettings.Values["ImgurAPI"] as string == null) - { - Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); - IMGUR_API_KEY = imgurAPI; - return; - } - else if ((localSettings.Values["ImgurAPI"] as string).Length == 0) - { - Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); - IMGUR_API_KEY = imgurAPI; - return; - } + //if (localSettings.Values["SauceNAOAPI"] as string == null) + //{ + // Frame.Navigate(typeof(SettingsPage),null, App.FromRightTransitionInfo); + // SAUCENAO_API_KEY = sauceNAOAPI; + // return; + //} + //else if ((localSettings.Values["SauceNAOAPI"] as string).Length == 0) + //{ + // Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); + // SAUCENAO_API_KEY = sauceNAOAPI; + // return; + //} + //if (localSettings.Values["ImgurAPI"] as string == null) + //{ + // Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); + // IMGUR_API_KEY = imgurAPI; + // return; + //} + //else if ((localSettings.Values["ImgurAPI"] as string).Length == 0) + //{ + // Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); + // IMGUR_API_KEY = imgurAPI; + // return; + //} SAUCENAO_API_KEY = localSettings.Values["SauceNAOAPI"] as string; IMGUR_API_KEY = localSettings.Values["ImgurAPI"] as string; // 选择文件 @@ -261,7 +263,7 @@ private async void btnSauceNAO_Click(object sender, RoutedEventArgs e) // 检测文件 if (file == null) { - Frame.GoBack(); + //Frame.GoBack(); return; } // @@ -274,7 +276,7 @@ private void GoPixivID_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuery { try { - Frame.Navigate(typeof(IllustDetailPage), int.Parse(asbGTPID.Text), App.FromRightTransitionInfo); + //Frame.Navigate(typeof(IllustDetailPage), int.Parse(asbGTPID.Text), App.FromRightTransitionInfo); } catch(OverflowException) { From 2bdc522c75aa8a48d79f0c68e4f22de9744cfb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=B0=E9=98=9F=E7=9A=84=E5=81=B6=E5=83=8F-=E5=B2=9B?= =?UTF-8?q?=E9=A3=8E=E9=85=B1=EF=BC=81?= Date: Mon, 11 Jan 2021 15:28:13 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PixivFSUWP/Controls/TagsPanel.cs | 2 +- PixivFSUWP/Data/OverAll.cs | 18 ++- PixivFSUWP/MainPage.xaml.cs | 13 +- PixivFSUWP/SearchDialog.xaml | 191 ++++++++++------------ PixivFSUWP/SearchDialog.xaml.cs | 263 +++++++++++-------------------- PixivFSUWP/WaterfallPage.xaml.cs | 11 +- 6 files changed, 198 insertions(+), 300 deletions(-) diff --git a/PixivFSUWP/Controls/TagsPanel.cs b/PixivFSUWP/Controls/TagsPanel.cs index a016c43..4e443dd 100644 --- a/PixivFSUWP/Controls/TagsPanel.cs +++ b/PixivFSUWP/Controls/TagsPanel.cs @@ -77,7 +77,7 @@ protected override Size MeasureOverride(Size availableSize) else widths[rowCount - 1] = tmpWidth; } - return new Size(widths.Max(), rowCount * ItemHeight + (rowCount - 1) * ItemVerticalMargin); + return new Size(0, rowCount * ItemHeight + (rowCount - 1) * ItemVerticalMargin); } protected override Size ArrangeOverride(Size finalSize) diff --git a/PixivFSUWP/Data/OverAll.cs b/PixivFSUWP/Data/OverAll.cs index 3c32eb9..165439e 100644 --- a/PixivFSUWP/Data/OverAll.cs +++ b/PixivFSUWP/Data/OverAll.cs @@ -36,12 +36,28 @@ public static class OverAll public static UserIllustsCollection UserList { get; private set; } public static MainPage TheMainPage { get; set; } - public struct SearchParam + public struct SearchParam : IEquatable { public string Word; public string SearchTarget; public string Sort; public string Duration; + + public override bool Equals(object obj) => obj is SearchParam param && Equals(param); + public bool Equals(SearchParam other) => Word == other.Word && SearchTarget == other.SearchTarget && Sort == other.Sort && Duration == other.Duration; + + public override int GetHashCode() + { + var hashCode = -582144489; + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Word); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(SearchTarget); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Sort); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(Duration); + return hashCode; + } + + public static bool operator ==(SearchParam left, SearchParam right) => left.Equals(right); + public static bool operator !=(SearchParam left, SearchParam right) => !(left == right); } public static void RefreshRecommendList() diff --git a/PixivFSUWP/MainPage.xaml.cs b/PixivFSUWP/MainPage.xaml.cs index 3e49778..a826a92 100644 --- a/PixivFSUWP/MainPage.xaml.cs +++ b/PixivFSUWP/MainPage.xaml.cs @@ -182,18 +182,7 @@ private void BtnMe_Click(object sender, RoutedEventArgs e) } private async void BtnSearch_Click(object sender, RoutedEventArgs e) - { - await new SearchDialog().ShowAsync(); - //try - //{ - // if (ContentFrame.Content is SearchPage) - // await (ContentFrame.Content as SearchPage).ShowSearch(); - // else - // ContentFrame.Navigate(typeof(SearchPage), WaterfallPage.ListContent.SearchResult, App.FromRightTransitionInfo); - //} - ////吞掉异常,这个异常没有意义 - //catch { } - } + => await new SearchDialog(ContentFrame).ShowAsync(); public void UpdateNavButtonState() { diff --git a/PixivFSUWP/SearchDialog.xaml b/PixivFSUWP/SearchDialog.xaml index decea16..826335f 100644 --- a/PixivFSUWP/SearchDialog.xaml +++ b/PixivFSUWP/SearchDialog.xaml @@ -12,22 +12,6 @@ - - - - - - - - - - - - - - - + + - - - - - - - - - - + + + + + + + + + - - - - - - - + + + + + + - - - - - - + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PixivFSUWP/SearchDialog.xaml.cs b/PixivFSUWP/SearchDialog.xaml.cs index e0dd9bd..40344d0 100644 --- a/PixivFSUWP/SearchDialog.xaml.cs +++ b/PixivFSUWP/SearchDialog.xaml.cs @@ -30,43 +30,18 @@ namespace PixivFSUWP /// public sealed partial class SearchDialog { - string lastWord = null; - int lastSearchTarget = -1; - int lastSort = -1; - int lastDuration = -1; + private readonly Frame Frame; + SearchParam last = default; public SearchDialog() { this.InitializeComponent(); Title = GetResourceString("SearchPagePlain"); CloseButtonText = GetResourceString("CancelPlain"); - } - - //private bool _backflag { get; set; } = false; - //public void SetBackFlag(bool value) - //{ - // _backflag = value; - //} - - //protected override void OnNavigatedFrom(NavigationEventArgs e) - //{ - // base.OnNavigatedFrom(e); - // if (!_backflag) - // { - // Data.OverAll.SearchResultList?.PauseLoading(); - // if (e.Parameter is ValueTuple tuple) - // { - // Data.Backstack.Default.Push - // (typeof(SearchPage), - // new ValueTuple - // (WaterfallPage.ListContent.SearchResult, tuple.Item2)); - // } - // else - // Data.Backstack.Default.Push(typeof(SearchPage), WaterfallPage.ListContent.SearchResult); - // } - // ((Frame.Parent as Grid)?.Parent as MainPage)?.UpdateNavButtonState(); - //} + _ = loadContents(); + } + public SearchDialog(Frame frame) : this() => Frame = frame; async Task> getTrendingTags() { @@ -87,136 +62,81 @@ public SearchDialog() async Task loadContents() { - stkMain.Visibility = Visibility.Visible; var tags = await getTrendingTags(); - //progressRing.IsActive = false; progressRing.Visibility = Visibility.Collapsed; panelTags.ItemsSource = tags; } - //protected override void OnNavigatedTo(NavigationEventArgs e) - //{ - // base.OnNavigatedTo(e); - // if (e.Parameter is WaterfallPage.ListContent) - // { - // _ = loadContents(); - // SearchResultList?.StopLoading(); - // } - // else if (e.Parameter is ValueTuple) - // { - // resultFrame.Navigate(typeof(WaterfallPage), e.Parameter); - // grdSearchPanel.Visibility = Visibility.Collapsed; - // if (txtWord.Text.Trim() != lastWord || cbSearchTarget.SelectedIndex != lastSearchTarget || - // cbSort.SelectedIndex != lastSort || cbDuration.SelectedIndex != lastDuration) - // { - // lastWord = txtWord.Text.Trim(); - // lastSearchTarget = cbSearchTarget.SelectedIndex; - // lastSort = cbSort.SelectedIndex; - // lastDuration = cbDuration.SelectedIndex; - // } - // } - // ((Frame.Parent as Grid)?.Parent as MainPage)?.SelectNavPlaceholder(GetResourceString("SearchPagePlain")); - //} + private void TxtWord_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) => Search(sender.Text); - public async Task ShowSearch() + public void Search(string word) { - if (grdSearchPanel.Visibility == Visibility.Collapsed) + if (string.IsNullOrWhiteSpace(word)) + return; + + var param = new SearchParam { - searchProgressRing.Visibility = Visibility.Collapsed; - searchProgressRing.IsActive = false; - grdSearchPanel.Visibility = Visibility.Visible; - stkMain.Visibility = Visibility.Collapsed; - storyShow.Begin(); - await Task.Delay(200); + Word = word.Trim() + }; + switch (cbSearchTarget.SelectedIndex) + { + case 0: + param.SearchTarget = "partial_match_for_tags"; + break; + case 1: + param.SearchTarget = "exact_match_for_tags"; + break; + case 2: + param.SearchTarget = "title_and_caption"; + break; } - else stkMain.Visibility = Visibility.Collapsed; - //progressRing.IsActive = true; - progressRing.Visibility = Visibility.Visible; - (panelTags.ItemsSource as List).Clear(); - panelTags.ItemsSource = null; - await loadContents(); - } - - private async void TxtWord_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) - { - if (string.IsNullOrWhiteSpace(txtWord.Text)) return; - if (txtWord.Text.Trim() != lastWord || cbSearchTarget.SelectedIndex != lastSearchTarget || - cbSort.SelectedIndex != lastSort || cbDuration.SelectedIndex != lastDuration) + switch (cbSort.SelectedIndex) { - if (resultFrame.Content != null) - (resultFrame.Content as WaterfallPage).ItemsSource.CollectionChanged -= ItemsSource_CollectionChanged; - var param = new OverAll.SearchParam() - { - Word = txtWord.Text.Trim() - }; - switch (cbSearchTarget.SelectedIndex) - { - case 0: - param.SearchTarget = "partial_match_for_tags"; - break; - case 1: - param.SearchTarget = "exact_match_for_tags"; - break; - case 2: - param.SearchTarget = "title_and_caption"; - break; - } - switch (cbSort.SelectedIndex) - { - case 0: - param.Sort = "date_desc"; - break; - case 1: - param.Sort = "date_asc"; - break; - } - switch (cbDuration.SelectedIndex) - { - case 0: - param.Duration = null; - break; - case 1: - param.Duration = "within_last_day"; - break; - case 2: - param.Duration = "within_last_week"; - break; - case 3: - param.Duration = "within_last_month"; - break; - } - OverAll.RefreshSearchResultList(param); - resultFrame.Navigate(typeof(WaterfallPage), WaterfallPage.ListContent.SearchResult, App.FromRightTransitionInfo); - (resultFrame.Content as WaterfallPage).ItemsSource.CollectionChanged += ItemsSource_CollectionChanged; + case 0: + param.Sort = "date_desc"; + break; + case 1: + param.Sort = "date_asc"; + break; } - storyFade.Begin(); - await Task.Delay(200); - grdSearchPanel.Visibility = Visibility.Collapsed; - if (txtWord.Text.Trim() != lastWord || cbSearchTarget.SelectedIndex != lastSearchTarget || - cbSort.SelectedIndex != lastSort || cbDuration.SelectedIndex != lastDuration) + switch (cbDuration.SelectedIndex) { - lastWord = txtWord.Text.Trim(); - lastSearchTarget = cbSearchTarget.SelectedIndex; - lastSort = cbSort.SelectedIndex; - lastDuration = cbDuration.SelectedIndex; - searchProgressRing.IsActive = true; - searchProgressRing.Visibility = Visibility.Visible; + case 0: + param.Duration = null; + break; + case 1: + param.Duration = "within_last_day"; + break; + case 2: + param.Duration = "within_last_week"; + break; + case 3: + param.Duration = "within_last_month"; + break; } + Search(param); } - - private void ItemsSource_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + public void Search(SearchParam param) { - searchProgressRing.Visibility = Visibility.Collapsed; - searchProgressRing.IsActive = false; + if (param != last) + { + RefreshSearchResultList(param); + Frame?.Navigate(typeof(WaterfallPage), WaterfallPage.ListContent.SearchResult, App.FromRightTransitionInfo); + } + Hide(); + if (param != last) + last = param; } private void BtnTag_Click(object sender, RoutedEventArgs e) { - txtWord.Text = (sender as Button).Tag as string; - cbSearchTarget.SelectedIndex = 1; - cbSort.SelectedIndex = 0; - cbDuration.SelectedIndex = 0; - TxtWord_QuerySubmitted(null, null); + Search(new SearchParam + { + Word = (sender as Button).Tag as string, + SearchTarget = "exact_match_for_tags", + Sort = "date_desc", + Duration = null + }); } private async void btnSauceNAO_Click(object sender, RoutedEventArgs e) @@ -226,30 +146,30 @@ private async void btnSauceNAO_Click(object sender, RoutedEventArgs e) string SAUCENAO_API_KEY, IMGUR_API_KEY; Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; //读取设置项 - //if (localSettings.Values["SauceNAOAPI"] as string == null) - //{ - // Frame.Navigate(typeof(SettingsPage),null, App.FromRightTransitionInfo); - // SAUCENAO_API_KEY = sauceNAOAPI; - // return; - //} - //else if ((localSettings.Values["SauceNAOAPI"] as string).Length == 0) - //{ - // Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); - // SAUCENAO_API_KEY = sauceNAOAPI; - // return; - //} - //if (localSettings.Values["ImgurAPI"] as string == null) - //{ - // Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); - // IMGUR_API_KEY = imgurAPI; - // return; - //} - //else if ((localSettings.Values["ImgurAPI"] as string).Length == 0) - //{ - // Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); - // IMGUR_API_KEY = imgurAPI; - // return; - //} + if (localSettings.Values["SauceNAOAPI"] as string == null) + { + Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); + SAUCENAO_API_KEY = sauceNAOAPI; + return; + } + else if ((localSettings.Values["SauceNAOAPI"] as string).Length == 0) + { + Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); + SAUCENAO_API_KEY = sauceNAOAPI; + return; + } + if (localSettings.Values["ImgurAPI"] as string == null) + { + Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); + IMGUR_API_KEY = imgurAPI; + return; + } + else if ((localSettings.Values["ImgurAPI"] as string).Length == 0) + { + Frame.Navigate(typeof(SettingsPage), null, App.FromRightTransitionInfo); + IMGUR_API_KEY = imgurAPI; + return; + } SAUCENAO_API_KEY = localSettings.Values["SauceNAOAPI"] as string; IMGUR_API_KEY = localSettings.Values["ImgurAPI"] as string; // 选择文件 @@ -263,10 +183,10 @@ private async void btnSauceNAO_Click(object sender, RoutedEventArgs e) // 检测文件 if (file == null) { - //Frame.GoBack(); + Frame.GoBack(); return; } - // + // //ImgurNaoAPI imgurNaoApi = new ImgurNaoAPI(SAUCENAO_API_KEY, IMGUR_API_KEY); //string image = imgurNaoApi.UpLoad(await StorageFileExt.AsByteArray(file)).GetNamedString("link"); //int retPid = (int)imgurNaoApi.DownLoad(image).GetNamedNumber("pixiv_id"); @@ -274,13 +194,10 @@ private async void btnSauceNAO_Click(object sender, RoutedEventArgs e) } private void GoPixivID_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { - try - { - //Frame.Navigate(typeof(IllustDetailPage), int.Parse(asbGTPID.Text), App.FromRightTransitionInfo); - } - catch(OverflowException) + if (int.TryParse(sender.Text, out var id)) { - //吞了异常。一般是由于输入的数字过大,超过了Int32的限制导致 + Frame.Navigate(typeof(IllustDetailPage), id, App.FromRightTransitionInfo); + Hide(); } } diff --git a/PixivFSUWP/WaterfallPage.xaml.cs b/PixivFSUWP/WaterfallPage.xaml.cs index 65ef051..fd880c9 100644 --- a/PixivFSUWP/WaterfallPage.xaml.cs +++ b/PixivFSUWP/WaterfallPage.xaml.cs @@ -61,10 +61,14 @@ public WaterfallPage() protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (e.Parameter is ListContent) listContent = (ListContent)e.Parameter; - else if(e.Parameter is ValueTuple tuple) + switch (e.Parameter) { - (listContent, clicked) = tuple; + case ListContent content: + listContent = content; + break; + case ValueTuple tuple: + (listContent, clicked) = tuple; + break; } switch (listContent) { @@ -85,6 +89,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) Data.OverAll.RankingList.ResumeLoading(); break; case ListContent.SearchResult: + TheMainPage.SelectNavPlaceholder(GetResourceString("SearchPagePlain")); ItemsSource = Data.OverAll.SearchResultList; Data.OverAll.SearchResultList.ResumeLoading(); WaterfallListView.ItemsSource = ItemsSource; From 9c923e1905d00571b933bbcde040e7dd8f545e67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=88=B0=E9=98=9F=E7=9A=84=E5=81=B6=E5=83=8F-=E5=B2=9B?= =?UTF-8?q?=E9=A3=8E=E9=85=B1=EF=BC=81?= Date: Mon, 11 Jan 2021 15:37:07 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BD=BF=E5=9B=BE=E7=89=87=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E7=9A=84=E6=A0=87=E7=AD=BE=E5=8F=AF=E7=82=B9?= =?UTF-8?q?=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PixivFSUWP/IllustDetailPage.xaml | 2 +- PixivFSUWP/IllustDetailPage.xaml.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/PixivFSUWP/IllustDetailPage.xaml b/PixivFSUWP/IllustDetailPage.xaml index fcf0441..dcb8410 100644 --- a/PixivFSUWP/IllustDetailPage.xaml +++ b/PixivFSUWP/IllustDetailPage.xaml @@ -135,7 +135,7 @@