Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

Commit

Permalink
Revert "Debug"
Browse files Browse the repository at this point in the history
This reverts commit 61c0e32.
  • Loading branch information
frg2089 committed Oct 4, 2019
1 parent 61c0e32 commit b19a042
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions PixivFSUWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ private void NavControl_BackRequested(NavigationView sender, NavigationViewBackR
UpdateNavButtonState();
}
}
private async void btnSauceNAO_Click(object sender, RoutedEventArgs e)
private async void SauceNAO()
{
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
string SAUCENAO_API_KEY = localSettings.Values["SauceNAOAPI"] as string;//读取设置项
string IMGUR_API_KEY = localSettings.Values["ImgurAPI"] as string;

var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
Expand All @@ -243,19 +243,25 @@ private async void btnSauceNAO_Click(object sender, RoutedEventArgs e)
picker.FileTypeFilter.Add(".png");

Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
if (file == null) return;
if (file == null)return;
byte[] IMAGE_PATH = await StorageFileExt.AsByteArray(file);
string image = Imgur.Upload(IMAGE_PATH, IMGUR_API_KEY);
List<Result> results = new SauceNao.SauceNao(SAUCENAO_API_KEY).Request(image, null);
results.RemoveAll(result => !result.HasRecognizableSauce());

foreach (Result result in results)
{
System.Diagnostics.Debug.WriteLine(result.ToString() + "\n");
}
System.Diagnostics.Debug.WriteLine(results[0].Response.SauceId.ToString());
ContentFrame.Navigate(typeof(IllustDetailPage), results[0].Response.SauceId);
}
private void btnSauceNAO_Click(object sender, RoutedEventArgs e)
{
System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(SauceNAO);
var thread = new System.Threading.Thread(threadStart);
thread.Start();//开始线程
}
}
static class StorageFileExt
{
Expand Down

0 comments on commit b19a042

Please sign in to comment.