From b008a58cf8f11f523605d877642a356e87430e91 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 27 Sep 2024 09:58:33 +0800 Subject: [PATCH] Code improvements --- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 47 +++++++++++++------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 37ab2720..2f7b271a 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -42,6 +42,28 @@ namespace v2rayN.Views Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel)); WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); + if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) + { + tabProfiles.Content ??= new ProfilesView(); + tabMsgView.Content ??= new MsgView(); + tabClashProxies.Content ??= new ClashProxiesView(); + tabClashConnections.Content ??= new ClashConnectionsView(); + } + else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) + { + tabProfiles1.Content ??= new ProfilesView(); + tabMsgView1.Content ??= new MsgView(); + tabClashProxies1.Content ??= new ClashProxiesView(); + tabClashConnections1.Content ??= new ClashConnectionsView(); + } + else + { + tabProfiles2.Content ??= new ProfilesView(); + tabMsgView2.Content ??= new MsgView(); + tabClashProxies2.Content ??= new ClashProxiesView(); + tabClashConnections2.Content ??= new ClashConnectionsView(); + } + pbTheme.Content ??= new ThemeSettingView(); this.WhenActivated(disposables => { @@ -150,30 +172,7 @@ namespace v2rayN.Views { RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; } - - if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) - { - tabProfiles.Content ??= new ProfilesView(); - tabMsgView.Content ??= new MsgView(); - tabClashProxies.Content ??= new ClashProxiesView(); - tabClashConnections.Content ??= new ClashConnectionsView(); - } - else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) - { - tabProfiles1.Content ??= new ProfilesView(); - tabMsgView1.Content ??= new MsgView(); - tabClashProxies1.Content ??= new ClashProxiesView(); - tabClashConnections1.Content ??= new ClashConnectionsView(); - } - else - { - tabProfiles2.Content ??= new ProfilesView(); - tabMsgView2.Content ??= new MsgView(); - tabClashProxies2.Content ??= new ClashProxiesView(); - tabClashConnections2.Content ??= new ClashConnectionsView(); - } - pbTheme.Content ??= new ThemeSettingView(); - + RestoreUI(); AddHelpMenuItem(); }