Skip to content

Commit 7a5b887

Browse files
authored
Merge pull request #61 from dotnet-campus/t/lindexi/Uno
2 parents 1da8977 + 34b9244 commit 7a5b887

105 files changed

Lines changed: 468 additions & 1955 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/UnoFileDownloader/UnoFileDownloader/.editorconfig renamed to src/UnoFileDownloader/.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ csharp_indent_labels = one_less_than_current
153153
csharp_using_directive_placement = outside_namespace:silent
154154
csharp_prefer_simple_using_statement = true:suggestion
155155
csharp_prefer_braces = true:silent
156-
csharp_style_namespace_declarations = block_scoped:silent
156+
csharp_style_namespace_declarations = file_scoped:warning
157157
csharp_style_prefer_method_group_conversion = true:silent
158158
csharp_style_prefer_top_level_statements = true:silent
159159
csharp_style_prefer_primary_constructors = true:suggestion

src/UnoFileDownloader/UnoFileDownloader/.gitignore renamed to src/UnoFileDownloader/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,5 +399,5 @@ FodyWeavers.xsd
399399

400400
# Single Target Config
401401
solution-config.props
402-
# Windows Publish Profiles
403-
!**/*.Windows/Properties/PublishProfiles/*.pubxml
402+
# Publish Profiles
403+
!**/Properties/PublishProfiles/*.pubxml

src/UnoFileDownloader/UnoFileDownloader/.vsconfig renamed to src/UnoFileDownloader/.vsconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515
"Microsoft.Component.NetFX.Native",
1616
"Microsoft.VisualStudio.Component.Graphics",
1717
"Microsoft.VisualStudio.Component.Merq",
18-
"Component.Xamarin.RemotedSimulator",
19-
"Microsoft.VisualStudio.Component.MonoDebugger",
20-
"Component.Xamarin",
21-
"Microsoft.VisualStudio.ComponentGroup.Maui.All",
22-
"Component.Android.SDK34",
23-
"Component.Android.SDK33",
24-
"Component.OpenJDK",
2518
"Microsoft.VisualStudio.Workload.NetCrossPlat",
2619
"Microsoft.VisualStudio.Workload.NetCoreTools"
2720
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ImplicitUsings>enable</ImplicitUsings>
4+
<Nullable>enable</Nullable>
5+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
6+
7+
<!--
8+
Adding NoWarn to remove build warnings
9+
NU1507: Warning when there are multiple package sources when using CPM with no source mapping
10+
NETSDK1201: Warning that specifying RID won't create self containing app
11+
PRI257: Ignore default language (en) not being one of the included resources (eg en-us, en-uk)
12+
-->
13+
<NoWarn>$(NoWarn);NU1507;NETSDK1201;PRI257</NoWarn>
14+
</PropertyGroup>
15+
16+
<!-- See https://aka.platform.uno/using-uno-sdk#implicit-packages for more information regarding the Implicit Packages version properties. -->
17+
<PropertyGroup>
18+
<UnoExtensionsVersion>4.1.23</UnoExtensionsVersion>
19+
<UnoToolkitVersion>6.0.18</UnoToolkitVersion>
20+
<UnoThemesVersion>5.0.13</UnoThemesVersion>
21+
<UnoCSharpMarkupVersion>5.2.14</UnoCSharpMarkupVersion>
22+
</PropertyGroup>
23+
</Project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<Project>
2+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project ToolsVersion="15.0">
2+
<!--
3+
To update the version of Uno, you should instead update the Sdk version in the global.json file.
4+
5+
See https://aka.platform.uno/using-uno-sdk for more information.
6+
-->
7+
<ItemGroup>
8+
</ItemGroup>
9+
</Project>

src/UnoFileDownloader/UnoFileDownloader.sln

Lines changed: 20 additions & 212 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Application x:Class="UnoFileDownloader.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:utum="using:Uno.Toolkit.UI.Material">
5+
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<!-- Load WinUI resources -->
10+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
11+
<utum:MaterialToolkitTheme
12+
ColorOverrideSource="ms-appx:///Styles/ColorPaletteOverride.xaml">
13+
<!-- NOTE: You can override the default Roboto font by providing your font assets here. -->
14+
<!-- <utum:MaterialToolkitTheme.FontOverrideDictionary>
15+
<ResourceDictionary>
16+
<FontFamily x:Key="MaterialLightFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Light.ttf#Roboto</FontFamily>
17+
<FontFamily x:Key="MaterialMediumFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Medium.ttf#Roboto</FontFamily>
18+
<FontFamily x:Key="MaterialRegularFontFamily">ms-appx:///Uno.Fonts.Roboto/Fonts/Roboto-Regular.ttf#Roboto</FontFamily>
19+
</ResourceDictionary>
20+
</utum:MaterialToolkitTheme.FontOverrideDictionary> -->
21+
</utum:MaterialToolkitTheme>
22+
</ResourceDictionary.MergedDictionaries>
23+
</ResourceDictionary>
24+
</Application.Resources>
25+
26+
<!-- Add resources here -->
27+
28+
</Application>
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
using System;
2+
3+
using Microsoft.Extensions.Hosting;
4+
using Microsoft.Extensions.Localization;
5+
using Microsoft.Extensions.Logging;
6+
7+
using Uno.Resizetizer;
8+
using UnoFileDownloader.Business;
9+
using UnoFileDownloader.Business.Models;
10+
using UnoFileDownloader.Presentation;
11+
using UnoFileDownloader.Utils;
12+
13+
namespace UnoFileDownloader;
14+
public partial class App : Application
15+
{
16+
/// <summary>
17+
/// Initializes the singleton application object. This is the first line of authored code
18+
/// executed, and as such is the logical equivalent of main() or WinMain().
19+
/// </summary>
20+
public App()
21+
{
22+
this.InitializeComponent();
23+
}
24+
25+
protected Window? MainWindow { get; private set; }
26+
protected IHost? Host { get; private set; }
27+
28+
protected async override void OnLaunched(LaunchActivatedEventArgs args)
29+
{
30+
31+
32+
var builder = this.CreateBuilder(args)
33+
.UseToolkitNavigation()
34+
.Configure(host =>
35+
{
36+
host.UseConfiguration(configure: configBuilder =>
37+
configBuilder
38+
.EmbeddedSource<App>()
39+
.Section<AppConfig>())
40+
.UseLocalization()
41+
.ConfigureServices((context, services) =>
42+
{
43+
services.AddSingleton<IDispatcherQueueProvider>(c =>
44+
{
45+
return new DispatcherQueueProvider(MainWindow!.DispatcherQueue);
46+
});
47+
48+
// 下载文件管理器
49+
services.AddSingleton<DownloadFileListManager>();
50+
})
51+
.UseNavigation(ReactiveViewModelMappings.ViewModelMappings, RegisterRoutes)
52+
;
53+
});
54+
MainWindow = builder.Window;
55+
//MainWindow = new Window();
56+
#if DEBUG
57+
MainWindow.EnableHotReload();
58+
#endif
59+
Host = await builder.NavigateAsync<Shell>();
60+
var localizer = (Uno.Extensions.Localization.ResourceLoaderStringLocalizer) Host.Services.GetRequiredService<IStringLocalizer>();
61+
string title = localizer["ApplicationName"];
62+
63+
MainWindow.Title = title;
64+
65+
//// Do not repeat app initialization when the Window already has content,
66+
//// just ensure that the window is active
67+
//if (MainWindow.Content is not Frame rootFrame)
68+
//{
69+
// // Create a Frame to act as the navigation context and navigate to the first page
70+
// rootFrame = new Frame();
71+
72+
// // Place the frame in the current Window
73+
// MainWindow.Content = rootFrame;
74+
75+
// rootFrame.NavigationFailed += OnNavigationFailed;
76+
//}
77+
78+
//if (rootFrame.Content == null)
79+
//{
80+
// // When the navigation stack isn't restored navigate to the first page,
81+
// // configuring the new page by passing required information as a navigation
82+
// // parameter
83+
// rootFrame.Navigate(typeof(Shell), args.Arguments);
84+
//}
85+
86+
MainWindow.SetWindowIcon();
87+
// Ensure the current window is active
88+
MainWindow.Activate();
89+
}
90+
91+
private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes)
92+
{
93+
views.Register
94+
(
95+
new ViewMap(ViewModel: typeof(ShellModel), View: typeof(Shell)),
96+
new ViewMap<MainPage, MainModel>(),
97+
new ViewMap<AboutPage, AboutModel>(),
98+
new ViewMap<NewTaskPage, NewTaskModel>(),
99+
new DataViewMap<SecondPage, SecondModel, Entity>()
100+
);
101+
102+
// 必须写注册哦,否则无法跳转
103+
routes.Register
104+
(
105+
new RouteMap("", View: views.FindByViewModel<ShellModel>(),
106+
Nested: new RouteMap[]
107+
{
108+
new RouteMap("Main", View: views.FindByViewModel<MainModel>()),
109+
new RouteMap("Second", View: views.FindByViewModel<SecondModel>()),
110+
new RouteMap("About", View: views.FindByViewModel<AboutModel>()),
111+
new RouteMap("NewTask",View: views.FindByViewModel<NewTaskModel>()),
112+
}
113+
)
114+
);
115+
}
116+
117+
/// <summary>
118+
/// Invoked when Navigation to a certain page fails
119+
/// </summary>
120+
/// <param name="sender">The Frame which failed navigation</param>
121+
/// <param name="e">Details about the navigation failure</param>
122+
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
123+
{
124+
throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
125+
}
126+
127+
/// <summary>
128+
/// Configures global Uno Platform logging
129+
/// </summary>
130+
public static void InitializeLogging()
131+
{
132+
#if DEBUG
133+
// Logging is disabled by default for release builds, as it incurs a significant
134+
// initialization cost from Microsoft.Extensions.Logging setup. If startup performance
135+
// is a concern for your application, keep this disabled. If you're running on the web or
136+
// desktop targets, you can use URL or command line parameters to enable it.
137+
//
138+
// For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html
139+
140+
var factory = LoggerFactory.Create(builder =>
141+
{
142+
#if __WASM__
143+
builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider());
144+
#elif __IOS__ || __MACCATALYST__
145+
builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider());
146+
#else
147+
builder.AddConsole();
148+
#endif
149+
150+
// Exclude logs below this level
151+
builder.SetMinimumLevel(LogLevel.Information);
152+
153+
// Default filters for Uno Platform namespaces
154+
builder.AddFilter("Uno", LogLevel.Warning);
155+
builder.AddFilter("Windows", LogLevel.Warning);
156+
builder.AddFilter("Microsoft", LogLevel.Warning);
157+
158+
// Generic Xaml events
159+
// builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug );
160+
// builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug );
161+
// builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug );
162+
// builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug );
163+
// builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace );
164+
165+
// Layouter specific messages
166+
// builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug );
167+
// builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug );
168+
// builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug );
169+
170+
// builder.AddFilter("Windows.Storage", LogLevel.Debug );
171+
172+
// Binding related messages
173+
// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );
174+
// builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug );
175+
176+
// Binder memory references tracking
177+
// builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug );
178+
179+
// DevServer and HotReload related
180+
// builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Information);
181+
182+
// Debug JS interop
183+
// builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug );
184+
});
185+
186+
global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory;
187+
188+
#if HAS_UNO
189+
global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize();
190+
#endif
191+
#endif
192+
}
193+
}

src/UnoFileDownloader/UnoFileDownloader/UnoFileDownloader.Base/Icons/icon.svg renamed to src/UnoFileDownloader/UnoFileDownloader/Assets/Icons/icon.svg

File renamed without changes.

0 commit comments

Comments
 (0)