From f0a17ea020c435186b8fcf62d45bc16007a81aee Mon Sep 17 00:00:00 2001
From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com>
Date: Mon, 12 May 2025 12:02:42 +0200
Subject: [PATCH 1/4] feat: added visuals for disabled sign out link
---
App/ViewModels/TrayWindowViewModel.cs | 45 +++++++++++++++++++++++++
App/Views/Pages/TrayWindowMainPage.xaml | 40 +++++++++++-----------
2 files changed, 66 insertions(+), 19 deletions(-)
diff --git a/App/ViewModels/TrayWindowViewModel.cs b/App/ViewModels/TrayWindowViewModel.cs
index cfa5163..b01c0ff 100644
--- a/App/ViewModels/TrayWindowViewModel.cs
+++ b/App/ViewModels/TrayWindowViewModel.cs
@@ -14,9 +14,13 @@
using CommunityToolkit.Mvvm.Input;
using Google.Protobuf;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.UI;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Media;
+using Windows.UI;
+using Exception = System.Exception;
namespace Coder.Desktop.App.ViewModels;
@@ -56,6 +60,8 @@ public partial class TrayWindowViewModel : ObservableObject, IAgentExpanderHost
[NotifyPropertyChangedFor(nameof(ShowWorkspacesHeader))]
[NotifyPropertyChangedFor(nameof(ShowNoAgentsSection))]
[NotifyPropertyChangedFor(nameof(ShowAgentsSection))]
+ [NotifyPropertyChangedFor(nameof(SignOutButtonForeground))]
+ [NotifyPropertyChangedFor(nameof(SignOutButtonTooltip))]
public partial VpnLifecycle VpnLifecycle { get; set; } = VpnLifecycle.Unknown;
// This is a separate property because we need the switch to be 2-way.
@@ -92,6 +98,41 @@ public partial class TrayWindowViewModel : ObservableObject, IAgentExpanderHost
[ObservableProperty] public partial string DashboardUrl { get; set; } = DefaultDashboardUrl;
+ public string SignOutButtonTooltip
+ {
+ get
+ {
+ return VpnLifecycle switch
+ {
+ VpnLifecycle.Stopped or VpnLifecycle.Unknown => "Sign out",
+ _ => "Sign out (VPN must be stopped first)",
+ };
+ }
+ }
+
+ private Brush? _enabledForegroud;
+ private Brush? _disabledForeground;
+
+ public Brush SignOutButtonForeground
+ {
+ get {
+ return VpnLifecycle switch
+ {
+ VpnLifecycle.Stopped or VpnLifecycle.Unknown => _enabledForegroud ?? new SolidColorBrush(Colors.White),
+ _ => _disabledForeground ?? new SolidColorBrush(Color.FromArgb(153, 255, 255, 255)),
+ };
+ }
+ }
+ public static Brush? FindBrushByName(string brushName)
+ {
+ if (Application.Current.Resources.TryGetValue(brushName, out var resource) && resource is Brush brush)
+ {
+ return brush;
+ }
+
+ return null; // Return null if the brush is not found
+ }
+
public TrayWindowViewModel(IServiceProvider services, IRpcController rpcController,
ICredentialManager credentialManager, IAgentViewModelFactory agentViewModelFactory, IHostnameSuffixGetter hostnameSuffixGetter)
{
@@ -100,6 +141,10 @@ public TrayWindowViewModel(IServiceProvider services, IRpcController rpcControll
_credentialManager = credentialManager;
_agentViewModelFactory = agentViewModelFactory;
_hostnameSuffixGetter = hostnameSuffixGetter;
+ _disabledForeground = FindBrushByName("SystemControlForegroundBaseMediumBrush");
+ _enabledForegroud = FindBrushByName("DefaultTextForegroundThemeBrush");
+
+
// Since the property value itself never changes, we add event
// listeners for the underlying collection changing instead.
diff --git a/App/Views/Pages/TrayWindowMainPage.xaml b/App/Views/Pages/TrayWindowMainPage.xaml
index f3549c2..1c60581 100644
--- a/App/Views/Pages/TrayWindowMainPage.xaml
+++ b/App/Views/Pages/TrayWindowMainPage.xaml
@@ -330,24 +330,26 @@
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
From ffd2d7349b8031d36c99abd520ae8b42f162299b Mon Sep 17 00:00:00 2001
From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com>
Date: Mon, 12 May 2025 12:19:23 +0200
Subject: [PATCH 2/4] Added an invisble background to have the tooltip display
always
---
App/Views/Pages/TrayWindowMainPage.xaml | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/App/Views/Pages/TrayWindowMainPage.xaml b/App/Views/Pages/TrayWindowMainPage.xaml
index 1c60581..0db062a 100644
--- a/App/Views/Pages/TrayWindowMainPage.xaml
+++ b/App/Views/Pages/TrayWindowMainPage.xaml
@@ -331,7 +331,9 @@
-
+
+
-
-
-
-
-
-
+
+
+
+
+
From 81fe809300bcde1398038d8c3f89a9b670598f86 Mon Sep 17 00:00:00 2001
From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com>
Date: Mon, 12 May 2025 12:21:07 +0200
Subject: [PATCH 3/4] removed unecessary comment
---
App/ViewModels/TrayWindowViewModel.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/App/ViewModels/TrayWindowViewModel.cs b/App/ViewModels/TrayWindowViewModel.cs
index b01c0ff..31193b3 100644
--- a/App/ViewModels/TrayWindowViewModel.cs
+++ b/App/ViewModels/TrayWindowViewModel.cs
@@ -130,7 +130,7 @@ public Brush SignOutButtonForeground
return brush;
}
- return null; // Return null if the brush is not found
+ return null;
}
public TrayWindowViewModel(IServiceProvider services, IRpcController rpcController,
From d1cbe5a94caf6450179caf9b82b51b3e64c635b5 Mon Sep 17 00:00:00 2001
From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com>
Date: Mon, 12 May 2025 13:26:55 +0200
Subject: [PATCH 4/4] formatting
---
App/ViewModels/TrayWindowViewModel.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/App/ViewModels/TrayWindowViewModel.cs b/App/ViewModels/TrayWindowViewModel.cs
index 31193b3..97a792e 100644
--- a/App/ViewModels/TrayWindowViewModel.cs
+++ b/App/ViewModels/TrayWindowViewModel.cs
@@ -115,7 +115,8 @@ public string SignOutButtonTooltip
public Brush SignOutButtonForeground
{
- get {
+ get
+ {
return VpnLifecycle switch
{
VpnLifecycle.Stopped or VpnLifecycle.Unknown => _enabledForegroud ?? new SolidColorBrush(Colors.White),