diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index b837f65c..fdabb5f6 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -1,7 +1,9 @@ using System.ComponentModel; using System.Reactive.Disposables; using System.Windows; +using System.Windows.Automation; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; @@ -23,6 +25,8 @@ public partial class MainWindow { InitializeComponent(); + Loaded += MainWindow_Loaded; + _config = AppHandler.Instance.Config; ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false); @@ -155,6 +159,15 @@ public partial class MainWindow })); } + private void MainWindow_Loaded(object sender, RoutedEventArgs e) + { + var popupBox = themePopupBox; + + var toggleButton = FindVisualChild(popupBox, "PART_Toggle"); + + AutomationProperties.SetName(toggleButton, ServiceLib.Resx.ResUI.MoreOptions); + } + private void DelegateSnackMsg(string content) { Application.Current?.Dispatcher.Invoke((() => @@ -466,5 +479,26 @@ public partial class MainWindow } } + private T FindVisualChild(DependencyObject parent, string name) where T : DependencyObject + { + if (parent == null) + return null; + + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) + { + var child = VisualTreeHelper.GetChild(parent, i); + if (child is T childType && child is FrameworkElement element && element.Name == name) + { + return childType; + } + + var result = FindVisualChild(child, name); + if (result != null) + return result; + } + + return null; + } + #endregion UI }