1414using CommunityToolkit . Mvvm . Input ;
1515using Google . Protobuf ;
1616using Microsoft . Extensions . DependencyInjection ;
17+ using Microsoft . UI ;
1718using Microsoft . UI . Dispatching ;
1819using Microsoft . UI . Xaml ;
1920using Microsoft . UI . Xaml . Controls ;
21+ using Microsoft . UI . Xaml . Media ;
22+ using Windows . UI ;
23+ using Exception = System . Exception ;
2024
2125namespace Coder . Desktop . App . ViewModels ;
2226
@@ -56,6 +60,8 @@ public partial class TrayWindowViewModel : ObservableObject, IAgentExpanderHost
5660 [ NotifyPropertyChangedFor ( nameof ( ShowWorkspacesHeader ) ) ]
5761 [ NotifyPropertyChangedFor ( nameof ( ShowNoAgentsSection ) ) ]
5862 [ NotifyPropertyChangedFor ( nameof ( ShowAgentsSection ) ) ]
63+ [ NotifyPropertyChangedFor ( nameof ( SignOutButtonForeground ) ) ]
64+ [ NotifyPropertyChangedFor ( nameof ( SignOutButtonTooltip ) ) ]
5965 public partial VpnLifecycle VpnLifecycle { get ; set ; } = VpnLifecycle . Unknown ;
6066
6167 // This is a separate property because we need the switch to be 2-way.
@@ -92,6 +98,41 @@ public partial class TrayWindowViewModel : ObservableObject, IAgentExpanderHost
9298
9399 [ ObservableProperty ] public partial string DashboardUrl { get ; set ; } = DefaultDashboardUrl ;
94100
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+
95136 public TrayWindowViewModel ( IServiceProvider services , IRpcController rpcController ,
96137 ICredentialManager credentialManager , IAgentViewModelFactory agentViewModelFactory , IHostnameSuffixGetter hostnameSuffixGetter )
97138 {
@@ -100,6 +141,10 @@ public TrayWindowViewModel(IServiceProvider services, IRpcController rpcControll
100141 _credentialManager = credentialManager ;
101142 _agentViewModelFactory = agentViewModelFactory ;
102143 _hostnameSuffixGetter = hostnameSuffixGetter ;
144+ _disabledForeground = FindBrushByName ( "SystemControlForegroundBaseMediumBrush" ) ;
145+ _enabledForegroud = FindBrushByName ( "DefaultTextForegroundThemeBrush" ) ;
146+
147+
103148
104149 // Since the property value itself never changes, we add event
105150 // listeners for the underlying collection changing instead.
0 commit comments