From da4c96e8d0386084ca7ee5a1eaaa0ffc2069a324 Mon Sep 17 00:00:00 2001 From: RMBGAME Date: Fri, 26 Nov 2021 19:56:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2page=E9=A1=B5=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/UI/Views/MainView.axaml | 4 +- .../Application/UI/Views/MainView.axaml.cs | 37 ++++++++++++++----- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml index f71707d32..52a19da4f 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml @@ -68,7 +68,7 @@ - + diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml.cs index a8c42d224..ad71843f8 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml.cs @@ -1,8 +1,6 @@ using Avalonia; using Avalonia.Controls; -using Avalonia.Controls.Primitives; using Avalonia.Markup.Xaml; -using Avalonia.Markup.Xaml.Templates; using Avalonia.Media; using Avalonia.Platform; using Avalonia.ReactiveUI; @@ -13,8 +11,8 @@ using System.Application.Settings; using System.Application.UI.ViewModels; using System.Application.UI.Views.Controls; using System.Linq; -using System.Runtime.InteropServices; -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Application.UI.Views.Pages; namespace System.Application.UI.Views { @@ -22,6 +20,26 @@ namespace System.Application.UI.Views { private readonly IBrush? _backgroundTemp; + private static IReadOnlyDictionary PageTypes { get; } + + static MainView() + { + PageTypes = new Dictionary + { + { typeof(ProxyScriptManagePageViewModel), typeof(ProxyScriptManagePage) }, + { typeof(StartPageViewModel), typeof(StartPage) }, + { typeof(SteamAccountPageViewModel), typeof(SteamAccountPage) }, + { typeof(SettingsPageViewModel), typeof(SettingsPage) }, + { typeof(AboutPageViewModel), typeof(AboutPage) }, + { typeof(DebugPageViewModel), typeof(DebugPage) }, + { typeof(GameListPageViewModel), typeof(GameListPage) }, + { typeof(CommunityProxyPageViewModel), typeof(CommunityProxyPage) }, + { typeof(LocalAuthPageViewModel), typeof(LocalAuthPage) }, + { typeof(GameRelatedPageViewModel), typeof(GameRelatedPage) }, + { typeof(ArchiSteamFarmPlusPageViewModel), typeof(ArchiSteamFarmPlusPage) }, + }; + } + public MainView() { InitializeComponent(); @@ -88,11 +106,12 @@ namespace System.Application.UI.Views { if (x != null) { - var page = frame.DataTemplates.FirstOrDefault(f => f.Match(x)); - if (page is DataTemplate template) - { - frame.Navigate(template.Build(null).GetType()); - } + //var page = frame.DataTemplates.FirstOrDefault(f => f.Match(x)); + //if (page is DataTemplate template) + //{ + // frame.Navigate(template.Build(null).GetType()); + //} + frame.Navigate(PageTypes[x.GetType()]); } }); }