14
14
using CommunityToolkit . Mvvm . Input ;
15
15
using Google . Protobuf ;
16
16
using Microsoft . Extensions . DependencyInjection ;
17
+ using Microsoft . UI ;
17
18
using Microsoft . UI . Dispatching ;
18
19
using Microsoft . UI . Xaml ;
19
20
using Microsoft . UI . Xaml . Controls ;
21
+ using Microsoft . UI . Xaml . Media ;
22
+ using Windows . UI ;
23
+ using Exception = System . Exception ;
20
24
21
25
namespace Coder . Desktop . App . ViewModels ;
22
26
@@ -56,6 +60,8 @@ public partial class TrayWindowViewModel : ObservableObject, IAgentExpanderHost
56
60
[ NotifyPropertyChangedFor ( nameof ( ShowWorkspacesHeader ) ) ]
57
61
[ NotifyPropertyChangedFor ( nameof ( ShowNoAgentsSection ) ) ]
58
62
[ NotifyPropertyChangedFor ( nameof ( ShowAgentsSection ) ) ]
63
+ [ NotifyPropertyChangedFor ( nameof ( SignOutButtonForeground ) ) ]
64
+ [ NotifyPropertyChangedFor ( nameof ( SignOutButtonTooltip ) ) ]
59
65
public partial VpnLifecycle VpnLifecycle { get ; set ; } = VpnLifecycle . Unknown ;
60
66
61
67
// This is a separate property because we need the switch to be 2-way.
@@ -92,6 +98,41 @@ public partial class TrayWindowViewModel : ObservableObject, IAgentExpanderHost
92
98
93
99
[ ObservableProperty ] public partial string DashboardUrl { get ; set ; } = DefaultDashboardUrl ;
94
100
101
+ public string SignOutButtonTooltip
102
+ {
103
+ get
104
+ {
105
+ return VpnLifecycle switch
106
+ {
107
+ VpnLifecycle . Stopped or VpnLifecycle . Unknown => "Sign out" ,
108
+ _ => "Sign out (VPN must be stopped first)" ,
109
+ } ;
110
+ }
111
+ }
112
+
113
+ private Brush ? _enabledForegroud ;
114
+ private Brush ? _disabledForeground ;
115
+
116
+ public Brush SignOutButtonForeground
117
+ {
118
+ get {
119
+ return VpnLifecycle switch
120
+ {
121
+ VpnLifecycle . Stopped or VpnLifecycle . Unknown => _enabledForegroud ?? new SolidColorBrush ( Colors . White ) ,
122
+ _ => _disabledForeground ?? new SolidColorBrush ( Color . FromArgb ( 153 , 255 , 255 , 255 ) ) ,
123
+ } ;
124
+ }
125
+ }
126
+ public static Brush ? FindBrushByName ( string brushName )
127
+ {
128
+ if ( Application . Current . Resources . TryGetValue ( brushName , out var resource ) && resource is Brush brush )
129
+ {
130
+ return brush ;
131
+ }
132
+
133
+ return null ; // Return null if the brush is not found
134
+ }
135
+
95
136
public TrayWindowViewModel ( IServiceProvider services , IRpcController rpcController ,
96
137
ICredentialManager credentialManager , IAgentViewModelFactory agentViewModelFactory , IHostnameSuffixGetter hostnameSuffixGetter )
97
138
{
@@ -100,6 +141,10 @@ public TrayWindowViewModel(IServiceProvider services, IRpcController rpcControll
100
141
_credentialManager = credentialManager ;
101
142
_agentViewModelFactory = agentViewModelFactory ;
102
143
_hostnameSuffixGetter = hostnameSuffixGetter ;
144
+ _disabledForeground = FindBrushByName ( "SystemControlForegroundBaseMediumBrush" ) ;
145
+ _enabledForegroud = FindBrushByName ( "DefaultTextForegroundThemeBrush" ) ;
146
+
147
+
103
148
104
149
// Since the property value itself never changes, we add event
105
150
// listeners for the underlying collection changing instead.
0 commit comments