diff --git a/src/CodingWithCalvin.VSToolbox.Core/Models/LaunchableInstance.cs b/src/CodingWithCalvin.VSToolbox.Core/Models/LaunchableInstance.cs index 975944d..ecbbed3 100644 --- a/src/CodingWithCalvin.VSToolbox.Core/Models/LaunchableInstance.cs +++ b/src/CodingWithCalvin.VSToolbox.Core/Models/LaunchableInstance.cs @@ -15,6 +15,7 @@ public sealed class LaunchableInstance public string BuildNumber => Instance.BuildNumber; public string InstallationPath => Instance.InstallationPath; public bool IsPrerelease => Instance.IsPrerelease; + public string ChannelType => Instance.ChannelType; public string? IconPath => Instance.IconPath; public bool CanLaunch => Instance.CanLaunch; diff --git a/src/CodingWithCalvin.VSToolbox.Core/Models/VisualStudioInstance.cs b/src/CodingWithCalvin.VSToolbox.Core/Models/VisualStudioInstance.cs index 5e9efc9..119ac75 100644 --- a/src/CodingWithCalvin.VSToolbox.Core/Models/VisualStudioInstance.cs +++ b/src/CodingWithCalvin.VSToolbox.Core/Models/VisualStudioInstance.cs @@ -21,6 +21,26 @@ public sealed class VisualStudioInstance public string BuildNumber => InstallationVersion; + public string ChannelType => ParseChannelType(ChannelId); + + private static string ParseChannelType(string channelId) + { + // ChannelId format: VisualStudio.{majorVersion}.{channel} + // e.g., VisualStudio.17.Release, VisualStudio.17.Preview, VisualStudio.17.Canary + var parts = channelId.Split('.'); + if (parts.Length < 3) + return "Unknown"; + + return parts[^1] switch + { + "Release" => "Stable", + "Preview" => "Preview", + "Canary" => "Canary", + "IntPreview" => "Internal Preview", + _ => parts[^1] + }; + } + public bool CanLaunch => !string.IsNullOrEmpty(ProductPath) && ProductPath.EndsWith("devenv.exe", StringComparison.OrdinalIgnoreCase); diff --git a/src/CodingWithCalvin.VSToolbox/App.xaml b/src/CodingWithCalvin.VSToolbox/App.xaml index 57d2882..54cf87d 100644 --- a/src/CodingWithCalvin.VSToolbox/App.xaml +++ b/src/CodingWithCalvin.VSToolbox/App.xaml @@ -19,6 +19,7 @@ + 14 diff --git a/src/CodingWithCalvin.VSToolbox/Converters/ChannelTypeToBrushConverter.cs b/src/CodingWithCalvin.VSToolbox/Converters/ChannelTypeToBrushConverter.cs new file mode 100644 index 0000000..df02a29 --- /dev/null +++ b/src/CodingWithCalvin.VSToolbox/Converters/ChannelTypeToBrushConverter.cs @@ -0,0 +1,27 @@ +using Microsoft.UI; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Media; + +namespace CodingWithCalvin.VSToolbox.Converters; + +public sealed class ChannelTypeToBrushConverter : IValueConverter +{ + public object Convert(object? value, Type targetType, object? parameter, string language) + { + var channelType = value as string ?? "Unknown"; + + return channelType switch + { + "Stable" => new SolidColorBrush(ColorHelper.FromArgb(255, 34, 197, 94)), // Green + "Preview" => new SolidColorBrush(ColorHelper.FromArgb(255, 168, 85, 247)), // Purple + "Canary" => new SolidColorBrush(ColorHelper.FromArgb(255, 251, 191, 36)), // Amber/Yellow + "Internal Preview" => new SolidColorBrush(ColorHelper.FromArgb(255, 239, 68, 68)), // Red + _ => new SolidColorBrush(ColorHelper.FromArgb(255, 107, 114, 128)) // Gray + }; + } + + public object ConvertBack(object? value, Type targetType, object? parameter, string language) + { + throw new NotImplementedException(); + } +} diff --git a/src/CodingWithCalvin.VSToolbox/Views/MainPage.xaml b/src/CodingWithCalvin.VSToolbox/Views/MainPage.xaml index ee98ea6..8f7071c 100644 --- a/src/CodingWithCalvin.VSToolbox/Views/MainPage.xaml +++ b/src/CodingWithCalvin.VSToolbox/Views/MainPage.xaml @@ -84,34 +84,37 @@ TextTrimming="CharacterEllipsis"/> - + + VerticalAlignment="Center" + Background="{x:Bind ChannelType, Converter={StaticResource ChannelTypeToBrushConverter}}"> + FontWeight="SemiBold" + Foreground="White"/> - + + + +