From a0e853b93ea90d68b49ddffd2fe930cea8b194ea Mon Sep 17 00:00:00 2001 From: Jerome Laban Date: Fri, 1 Nov 2024 09:30:33 -0400 Subject: [PATCH 1/3] fix(VS): Adjust toast title --- src/Uno.UI.RemoteControl.VS/EntryPoint.cs | 13 ++++---- .../GlobalJsonObserver.cs | 8 ++--- .../Notifications/InfoBar.cs | 30 +++++++++---------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/Uno.UI.RemoteControl.VS/EntryPoint.cs b/src/Uno.UI.RemoteControl.VS/EntryPoint.cs index 3467cf518859..d73493b1ccc6 100644 --- a/src/Uno.UI.RemoteControl.VS/EntryPoint.cs +++ b/src/Uno.UI.RemoteControl.VS/EntryPoint.cs @@ -519,14 +519,11 @@ private async Task CreateInfoBarAsync(NotificationRequestIdeMessage e, IVsShell var infoBar = await _infoBarFactory.CreateAsync( new InfoBarModel( - e.Message, - e.Commands.Select(Commands => new ActionBarItem - { - Text = Commands.Text, - Name = Commands.Name, - ActionContext = Commands.Parameter, - IsButton = true, - }).ToArray(), + new ActionBarTextSpan[] { + new(e.Title, Bold: true), + new(e.Message) + }, + e.Commands.Select(Commands => new ActionBarItem(Commands.Text, Commands.Name, ActionContext: Commands.Parameter, IsButton: true)).ToArray(), e.Kind == NotificationKind.Information ? KnownMonikers.StatusInformation : KnownMonikers.StatusError, isCloseButtonVisible: true)); diff --git a/src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs b/src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs index e7d397e90fbe..1254ac2381b8 100644 --- a/src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs +++ b/src/Uno.UI.RemoteControl.VS/GlobalJsonObserver.cs @@ -121,8 +121,8 @@ await _asyncPackage.GetServiceAsync(typeof(SVsShell)) is IVsShell shell && await _asyncPackage.GetServiceAsync(typeof(SVsInfoBarUIFactory)) is IVsInfoBarUIFactory infoBarFactory) { var factory = new InfoBarFactory(infoBarFactory, shell); - var restartVSItem = new ActionBarItem { Text = "Restart Visual Studio" }; - var moreInformationVSItem = new ActionBarItem { Text = "More information" }; + var restartVSItem = new ActionBarItem("Restart Visual Studio"); + var moreInformationVSItem = new ActionBarItem("More information"); var infoBar = await factory.CreateAsync( new InfoBarModel( @@ -141,7 +141,7 @@ await _asyncPackage.GetServiceAsync(typeof(SVsShell)) is IVsShell shell { _asyncPackage.JoinableTaskFactory.Run(async () => { - if (e.ActionItem == restartVSItem) + if (ReferenceEquals(e.ActionItem, restartVSItem)) { await _asyncPackage.JoinableTaskFactory.SwitchToMainThreadAsync(); @@ -152,7 +152,7 @@ await _asyncPackage.GetServiceAsync(typeof(SVsShell)) is IVsShell shell var hr = shell4.Restart((uint)type); } } - else if (e.ActionItem == moreInformationVSItem) + else if (ReferenceEquals(e.ActionItem, moreInformationVSItem)) { System.Diagnostics.Process.Start("https://aka.platform.uno/upgrade-uno-packages"); } diff --git a/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs b/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs index 524de5fa9b13..709954f22209 100644 --- a/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs +++ b/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs @@ -145,19 +145,17 @@ void IVsInfoBarUIEvents.OnActionItemClicked(IVsInfoBarUIElement infoBarUIElement } } -class ActionBarItem : IVsInfoBarActionItem -{ - public string? Text { get; set; } - - public string? Name { get; set; } - - public bool Bold { get; set; } - - public bool Italic { get; set; } - - public bool Underline { get; set; } - - public object? ActionContext { get; set; } - - public bool IsButton { get; set; } -} +record class ActionBarTextSpan( + string Text + , bool Bold = false + , bool Italic = false + , bool Underline = false) : IVsInfoBarTextSpan; + +record ActionBarItem( + string? Text + , string? Name = null + , bool Bold = false + , bool Italic = false + , bool Underline = false + , object? ActionContext = null + , bool IsButton = false) : IVsInfoBarActionItem; From d199e0d8920440d7fe5417fc88e52845d192e53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= Date: Mon, 4 Nov 2024 15:40:12 -0500 Subject: [PATCH 2/3] chore: Adjust spacing --- src/Uno.UI.RemoteControl.VS/EntryPoint.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.UI.RemoteControl.VS/EntryPoint.cs b/src/Uno.UI.RemoteControl.VS/EntryPoint.cs index d73493b1ccc6..8a9b81a8df58 100644 --- a/src/Uno.UI.RemoteControl.VS/EntryPoint.cs +++ b/src/Uno.UI.RemoteControl.VS/EntryPoint.cs @@ -521,7 +521,7 @@ private async Task CreateInfoBarAsync(NotificationRequestIdeMessage e, IVsShell new InfoBarModel( new ActionBarTextSpan[] { new(e.Title, Bold: true), - new(e.Message) + new(" " + e.Message) }, e.Commands.Select(Commands => new ActionBarItem(Commands.Text, Commands.Name, ActionContext: Commands.Parameter, IsButton: true)).ToArray(), e.Kind == NotificationKind.Information ? KnownMonikers.StatusInformation : KnownMonikers.StatusError, From e9fb0bc88aeacdf9df306fb63cf8a71932d8f91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= Date: Mon, 4 Nov 2024 15:44:33 -0500 Subject: [PATCH 3/3] chore: Adjust format --- .../Notifications/InfoBar.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs b/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs index 709954f22209..fe0f14484f26 100644 --- a/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs +++ b/src/Uno.UI.RemoteControl.VS/Notifications/InfoBar.cs @@ -146,16 +146,16 @@ void IVsInfoBarUIEvents.OnActionItemClicked(IVsInfoBarUIElement infoBarUIElement } record class ActionBarTextSpan( - string Text - , bool Bold = false - , bool Italic = false - , bool Underline = false) : IVsInfoBarTextSpan; + string Text, + bool Bold = false, + bool Italic = false, + bool Underline = false) : IVsInfoBarTextSpan; record ActionBarItem( - string? Text - , string? Name = null - , bool Bold = false - , bool Italic = false - , bool Underline = false - , object? ActionContext = null - , bool IsButton = false) : IVsInfoBarActionItem; + string? Text, + string? Name = null, + bool Bold = false, + bool Italic = false, + bool Underline = false, + object? ActionContext = null, + bool IsButton = false) : IVsInfoBarActionItem;