This commit is contained in:
Alexandre Zollinger Chohfi 2020-05-07 19:26:36 -07:00
Родитель af64aba4ad
Коммит e957d6de32
6 изменённых файлов: 55 добавлений и 30 удалений

Просмотреть файл

@ -5,9 +5,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Windows.Web.Http;
namespace Microsoft.Toolkit.Uwp.SampleApp.Data
{
@ -27,11 +27,22 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.Data
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.TryAppendWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
var uri = $"{_root}/repos/{_repoOwner}/{_repoName}/releases";
var result = await client.GetStringAsync(new Uri(uri));
_releases = JsonConvert.DeserializeObject<List<GitHubRelease>>(result).Take(5).ToList();
var request = new HttpRequestMessage(HttpMethod.Get, uri);
request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
using (request)
{
using (var response = await client.SendAsync(request))
{
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
_releases = JsonConvert.DeserializeObject<List<GitHubRelease>>(result).Take(5).ToList();
}
}
}
}
}
catch (Exception)

Просмотреть файл

@ -569,20 +569,16 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
options = new PropertyOptions();
var split = value.Split('.');
var typeName = string.Join(".", split.Take(split.Length - 1));
Debug.WriteLine("AAA");
var enumType = LookForTypeByName(typeName);
options.DefaultValue = Enum.Parse(enumType, split.Last());
}
catch (Exception ex)
{
Debug.WriteLine("BBB");
Debug.WriteLine($"Unable to parse enum from {value}({ex.Message})");
TrackingManager.TrackException(ex);
continue;
}
Debug.WriteLine("CCC");
break;
case PropertyKind.Bool:

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
@ -63,7 +64,9 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
var fullFileName = Path.Combine(_installedLocationPath, "Microsoft.Toolkit.Uwp.SampleApp", fileName);
var stream = new MemoryStream();
Debug.WriteLine($"LoadLocalFile{Thread.CurrentThread.ManagedThreadId}");
await File.OpenRead(fullFileName).CopyToAsync(stream);
Debug.WriteLine($"LoadLocalFile{Thread.CurrentThread.ManagedThreadId} End");
stream.Seek(0, SeekOrigin.Begin);
return stream;

Просмотреть файл

@ -5,9 +5,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.UI.Animations;
@ -107,7 +109,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.Pages
_compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
var t = Init();
_ = Init();
Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
}
@ -129,34 +131,45 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.Pages
private async Task Init()
{
Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
var loadDataTask = UpdateSections();
var recentSamplesTask = Samples.GetRecentSamples();
var gitHubTask = Data.GitHub.GetPublishedReleases();
Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
await Task.WhenAll(loadDataTask, recentSamplesTask, gitHubTask);
RecentSamples = recentSamplesTask.Result;
GitHubReleases = gitHubTask.Result;
Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
var counter = 1;
var delay = 70;
foreach (var child in InnerGrid.Children)
// Workaround WinUI3 threading issue
await DispatcherQueue.ExecuteOnUIThreadAsync(() =>
{
if (child is ItemsControl itemsControl == false)
{
Implicit.GetShowAnimations(child).Add(new OpacityAnimation()
{
From = 0,
To = 1,
Duration = TimeSpan.FromMilliseconds(300),
Delay = TimeSpan.FromMilliseconds(counter++ * delay),
SetInitialValueBeforeDelay = true
});
}
}
RecentSamples = recentSamplesTask.Result;
Root.Visibility = Visibility.Visible;
GitHubReleases = gitHubTask.Result;
var counter = 1;
var delay = 70;
foreach (var child in InnerGrid.Children)
{
if (child is ItemsControl itemsControl == false)
{
Implicit.GetShowAnimations(child).Add(new OpacityAnimation()
{
From = 0,
To = 1,
Duration = TimeSpan.FromMilliseconds(300),
Delay = TimeSpan.FromMilliseconds(counter++ * delay),
SetInitialValueBeforeDelay = true
});
}
}
Root.Visibility = Visibility.Visible;
});
}
private void RecentSample_Click(object sender, RoutedEventArgs e)

Просмотреть файл

@ -58,6 +58,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
global.json = global.json
nuget.config = nuget.config
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Toolkit.Uwp.Notifications.JavaScript", "Microsoft.Toolkit.Uwp.Notifications.JavaScript\Microsoft.Toolkit.Uwp.Notifications.JavaScript.csproj", "{94F8D702-3A9D-4CFB-85C9-79FC5DBD8B22}"

Просмотреть файл

@ -11,5 +11,6 @@
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="WinUI.Dependencies@Local" value="https://microsoft.pkgs.visualstudio.com/_packaging/WinUI.Dependencies%40Local/nuget/v3/index.json" />
<add key="CsWinRT" value="https://microsoft.pkgs.visualstudio.com/_packaging/CsWinRT/nuget/v3/index.json" />
</packageSources>
<add key="dotnet5@Local" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5%40Local/nuget/v3/index.json" />
</packageSources>
</configuration>