1
+ using Microsoft . Win32 ;
2
+ using System ;
3
+ using System . Windows ;
4
+ using System . Windows . Controls ;
5
+ using System . Windows . Media ;
6
+ //
7
+ using EXT . System . Registry ;
8
+
9
+ namespace WinUtil . Grid_Tabs
10
+ {
11
+ public partial class AppearanceGrid : UserControl
12
+ {
13
+ public AppearanceGrid ( )
14
+ {
15
+ InitializeComponent ( ) ;
16
+
17
+ Loaded += OnLoaded ;
18
+ }
19
+
20
+ private void OnLoaded ( object sender , RoutedEventArgs e )
21
+ {
22
+ Init_Theme_Switch ( ) ;
23
+
24
+ Init_Context_Button ( ) ;
25
+
26
+ Init_Terminal_Integrator_Button ( ) ;
27
+
28
+ Visibility = Visibility . Collapsed ;
29
+ }
30
+
31
+ //# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
32
+
33
+ private void Init_Theme_Switch ( )
34
+ {
35
+ Int32 v0 = xRegistry . Get . Value ( "HKEY_CURRENT_USER\\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Themes\\ Personalize" , "SystemUsesLightTheme" , RegistryValueKind . DWord ) ;
36
+ Int32 v1 = xRegistry . Get . Value ( "HKEY_CURRENT_USER\\ Software\\ Microsoft\\ Windows\\ CurrentVersion\\ Themes\\ Personalize" , "AppsUseLightTheme" , RegistryValueKind . DWord ) ;
37
+
38
+ if ( ( v0 == 1 ) || ( v1 == 1 ) )
39
+ {
40
+ OSTheme_ToggleButton . Checked -= Set_System_Theme_Toggle ;
41
+ OSTheme_ToggleButton . IsChecked = true ;
42
+ OSTheme_ToggleButton . Checked += Set_System_Theme_Toggle ;
43
+ }
44
+ }
45
+
46
+ private void Init_Context_Button ( )
47
+ {
48
+ if ( xRegistry . TestRegValuePresense ( @"HKEY_CURRENT_USER\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" , "" ) )
49
+ {
50
+ ContextMenu_ToggleButton . Checked -= ContextMenu_ToggleButton_Handler ;
51
+ ContextMenu_ToggleButton . IsChecked = true ;
52
+ ContextMenu_ToggleButton . Checked += ContextMenu_ToggleButton_Handler ;
53
+ }
54
+ }
55
+ internal void External_Set_OS_Aware_Context_Button_State ( )
56
+ {
57
+ if ( Machine . UIVersion == Machine . WindowsUIVersion . Windows10 )
58
+ {
59
+ Context_Button . IsEnabled = false ;
60
+ Context_Button_Icon . Opacity = 0.41 ;
61
+ ContextMenu_ToggleButton . Opacity = 0.41 ;
62
+ Context_Button_Head . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#747474" ) ) ;
63
+ Context_Button_Body . Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#747474" ) ) ;
64
+ }
65
+ }
66
+
67
+ private void Init_Terminal_Integrator_Button ( )
68
+ {
69
+ if ( xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWTHere" , "Extended" )
70
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWTHere" , "Icon" )
71
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWTHere" , "MUIVerb" )
72
+
73
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWTHereAsAdmin" , "Extended" )
74
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWTHereAsAdmin" , "HasLUAShield" )
75
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWTHereAsAdmin" , "Icon" )
76
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\Background\shell\OpenWTHereAsAdmin" , "MUIVerb" )
77
+
78
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\shell\OpenWTHere" , "Extended" )
79
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\shell\OpenWTHere" , "Icon" )
80
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\shell\OpenWTHere" , "MUIVerb" )
81
+
82
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\shell\OpenWTHereAsAdmin" , "Extended" )
83
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\shell\OpenWTHereAsAdmin" , "HasLUAShield" )
84
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\shell\OpenWTHereAsAdmin" , "Icon" )
85
+ && xRegistry . TestRegValuePresense ( @"HKEY_CLASSES_ROOT\Directory\shell\OpenWTHereAsAdmin" , "MUIVerb" ) )
86
+ {
87
+ Terminal_Integration_ToggleButton . Checked -= Terminal_Integration_ToggleButton_Handler ;
88
+ Terminal_Integration_ToggleButton . IsChecked = true ;
89
+ Terminal_Integration_ToggleButton . Checked += Terminal_Integration_ToggleButton_Handler ;
90
+ }
91
+ }
92
+ }
93
+ }
0 commit comments