diff --git a/v2rayN/ServiceLib/Handler/AppHandler.cs b/v2rayN/ServiceLib/Handler/AppHandler.cs index ddc72d06..4153296c 100644 --- a/v2rayN/ServiceLib/Handler/AppHandler.cs +++ b/v2rayN/ServiceLib/Handler/AppHandler.cs @@ -46,11 +46,13 @@ public bool InitApp() { - _config = ConfigHandler.LoadConfig(); - if (_config == null) + Logging.Setup(); + var config = ConfigHandler.LoadConfig(); + if (config == null) { return false; } + _config = config; Thread.CurrentThread.CurrentUICulture = new(_config.UiItem.CurrentLanguage); //Under Win10 @@ -70,10 +72,9 @@ public bool InitComponents() { - Logging.Setup(); - Logging.LoggingEnabled(_config.GuiItem.EnableLog); Logging.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}"); Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}"); + Logging.LoggingEnabled(_config.GuiItem.EnableLog); Logging.ClearLogs(); return true; diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index 95f587bf..fa214786 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -41,7 +41,34 @@ namespace v2rayN.Desktop.Views ViewModel = new MainWindowViewModel(UpdateViewHandler); Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel)); - //WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); + switch (_config.UiItem.MainGirdOrientation) + { + case EGirdOrientation.Horizontal: + tabProfiles.Content ??= new ProfilesView(this); + tabMsgView.Content ??= new MsgView(); + tabClashProxies.Content ??= new ClashProxiesView(); + tabClashConnections.Content ??= new ClashConnectionsView(); + gridMain.IsVisible = true; + break; + + case EGirdOrientation.Vertical: + tabProfiles1.Content ??= new ProfilesView(this); + tabMsgView1.Content ??= new MsgView(); + tabClashProxies1.Content ??= new ClashProxiesView(); + tabClashConnections1.Content ??= new ClashConnectionsView(); + gridMain1.IsVisible = true; + break; + + case EGirdOrientation.Tab: + default: + tabProfiles2.Content ??= new ProfilesView(this); + tabMsgView2.Content ??= new MsgView(); + tabClashProxies2.Content ??= new ClashProxiesView(); + tabClashConnections2.Content ??= new ClashConnectionsView(); + gridMain2.IsVisible = true; + break; + } + conTheme.Content ??= new ThemeSettingView(); this.WhenActivated(disposables => { @@ -84,7 +111,6 @@ namespace v2rayN.Desktop.Views switch (_config.UiItem.MainGirdOrientation) { case EGirdOrientation.Horizontal: - gridMain.IsVisible = true; this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabMsgView.IsVisible).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashProxies.IsVisible).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashConnections.IsVisible).DisposeWith(disposables); @@ -92,7 +118,6 @@ namespace v2rayN.Desktop.Views break; case EGirdOrientation.Vertical: - gridMain1.IsVisible = true; this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabMsgView1.IsVisible).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashProxies1.IsVisible).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashConnections1.IsVisible).DisposeWith(disposables); @@ -101,7 +126,6 @@ namespace v2rayN.Desktop.Views case EGirdOrientation.Tab: default: - gridMain2.IsVisible = true; this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashProxies2.IsVisible).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashConnections2.IsVisible).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.TabMainSelectedIndex, v => v.tabMain2.SelectedIndex).DisposeWith(disposables); @@ -128,35 +152,10 @@ namespace v2rayN.Desktop.Views menuGlobalHotkeySetting.IsVisible = false; } menuAddServerViaScan.IsVisible = false; - - switch (_config.UiItem.MainGirdOrientation) - { - case EGirdOrientation.Horizontal: - tabProfiles.Content ??= new ProfilesView(this); - tabMsgView.Content ??= new MsgView(); - tabClashProxies.Content ??= new ClashProxiesView(); - tabClashConnections.Content ??= new ClashConnectionsView(); - break; - - case EGirdOrientation.Vertical: - tabProfiles1.Content ??= new ProfilesView(this); - tabMsgView1.Content ??= new MsgView(); - tabClashProxies1.Content ??= new ClashProxiesView(); - tabClashConnections1.Content ??= new ClashConnectionsView(); - break; - - case EGirdOrientation.Tab: - default: - tabProfiles2.Content ??= new ProfilesView(this); - tabMsgView2.Content ??= new MsgView(); - tabClashProxies2.Content ??= new ClashProxiesView(); - tabClashConnections2.Content ??= new ClashConnectionsView(); - break; - } - conTheme.Content ??= new ThemeSettingView(); - + RestoreUI(); AddHelpMenuItem(); + //WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); } #region Event diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 0dc59911..cd467d67 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -40,7 +40,6 @@ namespace v2rayN.Views ViewModel = new MainWindowViewModel(UpdateViewHandler); Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel)); - WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); switch (_config.UiItem.MainGirdOrientation) { case EGirdOrientation.Horizontal: @@ -48,6 +47,7 @@ namespace v2rayN.Views tabMsgView.Content ??= new MsgView(); tabClashProxies.Content ??= new ClashProxiesView(); tabClashConnections.Content ??= new ClashConnectionsView(); + gridMain.Visibility = Visibility.Visible; break; case EGirdOrientation.Vertical: @@ -55,6 +55,7 @@ namespace v2rayN.Views tabMsgView1.Content ??= new MsgView(); tabClashProxies1.Content ??= new ClashProxiesView(); tabClashConnections1.Content ??= new ClashConnectionsView(); + gridMain1.Visibility = Visibility.Visible; break; case EGirdOrientation.Tab: @@ -63,6 +64,7 @@ namespace v2rayN.Views tabMsgView2.Content ??= new MsgView(); tabClashProxies2.Content ??= new ClashProxiesView(); tabClashConnections2.Content ??= new ClashConnectionsView(); + gridMain2.Visibility = Visibility.Visible; break; } pbTheme.Content ??= new ThemeSettingView(); @@ -108,7 +110,6 @@ namespace v2rayN.Views switch (_config.UiItem.MainGirdOrientation) { case EGirdOrientation.Horizontal: - gridMain.Visibility = Visibility.Visible; this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabMsgView.Visibility).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashProxies.Visibility).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashConnections.Visibility).DisposeWith(disposables); @@ -116,7 +117,6 @@ namespace v2rayN.Views break; case EGirdOrientation.Vertical: - gridMain1.Visibility = Visibility.Visible; this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabMsgView1.Visibility).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashProxies1.Visibility).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashConnections1.Visibility).DisposeWith(disposables); @@ -125,7 +125,6 @@ namespace v2rayN.Views case EGirdOrientation.Tab: default: - gridMain2.Visibility = Visibility.Visible; this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashProxies2.Visibility).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashConnections2.Visibility).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.TabMainSelectedIndex, v => v.tabMain2.SelectedIndex).DisposeWith(disposables); @@ -142,6 +141,7 @@ namespace v2rayN.Views RestoreUI(); AddHelpMenuItem(); + WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); } #region Event