From 82143317522a5dce7b5e891775fe06af37819fca Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 18 Dec 2024 01:55:57 -0600 Subject: [PATCH] Use the non-labs markdown block, because pain and suffering (#240) Co-authored-by: Mike Griese --- nuget.config | 4 ---- .../Microsoft.CmdPal.UI/Controls/IconBox.cs | 11 +++++------ .../ExtViews/FormsPage.xaml.cs | 13 ++++++++----- .../ExtViews/ListPage.xaml.cs | 12 ++++++++---- .../ExtViews/MarkdownPage.xaml | 11 +++++++---- .../ExtViews/MarkdownPage.xaml.cs | 16 ++++++++-------- .../Microsoft.CmdPal.UI.csproj | 2 +- .../cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml | 12 +++++++----- .../cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml.cs | 2 -- 9 files changed, 44 insertions(+), 39 deletions(-) diff --git a/nuget.config b/nuget.config index ef035331a160..892716c8d849 100644 --- a/nuget.config +++ b/nuget.config @@ -4,7 +4,6 @@ - @@ -13,8 +12,5 @@ - - - diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs index e2a07273657a..ee955d1e7b72 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Controls/IconBox.cs @@ -2,9 +2,6 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using CommunityToolkit.Common.Deferred; -using CommunityToolkit.WinUI; -using CommunityToolkit.WinUI.Deferred; using Microsoft.UI.Dispatching; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; @@ -90,20 +87,22 @@ private static void OnSourceKeyPropertyChanged(DependencyObject d, DependencyPro } else { - _ = @this._queue.EnqueueAsync(async () => + // TODO GH #239 switch back when using the new MD text block + // _ = @this._queue.EnqueueAsync(() => + @this._queue.TryEnqueue(new(() => { var eventArgs = new SourceRequestedEventArgs(e.NewValue); if (@this.SourceRequested != null) { - await @this.SourceRequested.InvokeAsync(@this, eventArgs); + @this.SourceRequested.Invoke(@this, eventArgs); if (eventArgs.Value != null) { @this.Source = eventArgs.Value; } } - }); + })); } } } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/FormsPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/FormsPage.xaml.cs index 1d92619a8e45..77bf11e59e86 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/FormsPage.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/FormsPage.xaml.cs @@ -4,7 +4,6 @@ using CommunityToolkit.Common; using CommunityToolkit.Mvvm.Messaging; -using CommunityToolkit.WinUI; using Microsoft.CmdPal.UI.ViewModels; using Microsoft.CmdPal.UI.ViewModels.Messages; using Microsoft.UI.Dispatching; @@ -73,21 +72,25 @@ protected override void OnNavigatedTo(NavigationEventArgs e) // TODO: Handle failure case System.Diagnostics.Debug.WriteLine(fpvm.InitializeCommand.ExecutionTask.Exception); - _ = _queue.EnqueueAsync(() => + // TODO GH #239 switch back when using the new MD text block + // _ = _queue.EnqueueAsync(() => + _queue.TryEnqueue(new(() => { LoadedState = ViewModelLoadedState.Error; - }); + })); } else { - _ = _queue.EnqueueAsync(() => + // TODO GH #239 switch back when using the new MD text block + // _ = _queue.EnqueueAsync(() => + _queue.TryEnqueue(new(() => { var result = (bool)fpvm.InitializeCommand.ExecutionTask.GetResultOrDefault()!; ViewModel = fpvm; WeakReferenceMessenger.Default.Send(new(result ? fpvm : null)); LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error; - }); + })); } }); } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml.cs index dd9ec1218e55..2373b3e9b811 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/ListPage.xaml.cs @@ -76,21 +76,25 @@ protected override void OnNavigatedTo(NavigationEventArgs e) // TODO: Handle failure case System.Diagnostics.Debug.WriteLine(lvm.InitializeCommand.ExecutionTask.Exception); - _ = _queue.EnqueueAsync(() => + // TODO GH #239 switch back when using the new MD text block + // _ = _queue.EnqueueAsync(() => + _queue.TryEnqueue(new(() => { LoadedState = ViewModelLoadedState.Error; - }); + })); } else { - _ = _queue.EnqueueAsync(() => + // TODO GH #239 switch back when using the new MD text block + // _ = _queue.EnqueueAsync(() => + _queue.TryEnqueue(new(() => { var result = (bool)lvm.InitializeCommand.ExecutionTask.GetResultOrDefault()!; ViewModel = lvm; WeakReferenceMessenger.Default.Send(new(result ? lvm : null)); LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error; - }); + })); } }); } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/MarkdownPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/MarkdownPage.xaml index d7fcab28129d..eb30846b2b9d 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/MarkdownPage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/MarkdownPage.xaml @@ -12,7 +12,7 @@ xmlns:cmdPalControls="using:Microsoft.CmdPal.UI.Controls" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewmodels="using:Microsoft.CmdPal.UI.ViewModels" - xmlns:labs="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock" + xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls" Background="Transparent" mc:Ignorable="d"> @@ -40,10 +40,13 @@ Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"> - + Background="Transparent" + Header3FontSize="12" + Header3FontWeight="Normal" + Header3Foreground="{ThemeResource TextFillColorSecondaryBrush}" + IsTextSelectionEnabled="True"/> diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/MarkdownPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/MarkdownPage.xaml.cs index fd7aef5d8f61..11b5f384b756 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/MarkdownPage.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ExtViews/MarkdownPage.xaml.cs @@ -3,9 +3,7 @@ // See the LICENSE file in the project root for more information. using CommunityToolkit.Common; -using CommunityToolkit.Labs.WinUI.MarkdownTextBlock; using CommunityToolkit.Mvvm.Messaging; -using CommunityToolkit.WinUI; using Microsoft.CmdPal.UI.ViewModels; using Microsoft.CmdPal.UI.ViewModels.Messages; using Microsoft.UI.Dispatching; @@ -22,8 +20,6 @@ public sealed partial class MarkdownPage : Page { private readonly DispatcherQueue _queue = DispatcherQueue.GetForCurrentThread(); - public static readonly MarkdownConfig MarkdownConfig = CommunityToolkit.Labs.WinUI.MarkdownTextBlock.MarkdownConfig.Default; - public MarkdownPageViewModel? ViewModel { get => (MarkdownPageViewModel?)GetValue(ViewModelProperty); @@ -76,21 +72,25 @@ protected override void OnNavigatedTo(NavigationEventArgs e) // TODO: Handle failure case System.Diagnostics.Debug.WriteLine(mdpvm.InitializeCommand.ExecutionTask.Exception); - _ = _queue.EnqueueAsync(() => + // TODO GH #239 switch back when using the new MD text block + // _ = _queue.EnqueueAsync(() => + _queue.TryEnqueue(new(() => { LoadedState = ViewModelLoadedState.Error; - }); + })); } else { - _ = _queue.EnqueueAsync(() => + // TODO GH #239 switch back when using the new MD text block + // _ = _queue.EnqueueAsync(() => + _queue.TryEnqueue(new(() => { var result = (bool)mdpvm.InitializeCommand.ExecutionTask.GetResultOrDefault()!; ViewModel = mdpvm; WeakReferenceMessenger.Default.Send(new(result ? mdpvm : null)); LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error; - }); + })); } }); } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj index 7f3a2b962247..89af42d8a0dc 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj @@ -52,7 +52,7 @@ - + diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml index 3e8b7b8a9642..1f8defb45d15 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml @@ -7,7 +7,7 @@ xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:help="using:Microsoft.CmdPal.UI.Helpers" - xmlns:labs="using:CommunityToolkit.Labs.WinUI.MarkdownTextBlock" + xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Background="Transparent" mc:Ignorable="d"> @@ -105,11 +105,13 @@ Visibility="{x:Bind ViewModel.Details.Title, Converter={StaticResource StringNotEmptyToVisibilityConverter}, Mode=OneWay}" /> - - + Header3FontSize="12" + Header3FontWeight="Normal" + Header3Foreground="{ThemeResource TextFillColorSecondaryBrush}" + IsTextSelectionEnabled="True"/> diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml.cs index 36bc7d2e1e35..90c4c1851b9d 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/ShellPage.xaml.cs @@ -36,8 +36,6 @@ public ShellPage() { this.InitializeComponent(); - DetailsMarkdown.Config = CommunityToolkit.Labs.WinUI.MarkdownTextBlock.MarkdownConfig.Default; - // how we are doing navigation around WeakReferenceMessenger.Default.Register(this); WeakReferenceMessenger.Default.Register(this);