Refs #28. Align WinUI and WPF Help commands with gclo and add native menu acceptance without launching a browser. Co-Authored-By: Codex (GPT-6) <noreply@openai.com> Signed-off-by: James Maes <james@kof22.com>
46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
/*
|
|
* Copyright (c) 2026 James Maes
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
namespace AppKit.Sample.WinUI;
|
|
|
|
/// <summary>Opens only the app's fixed public Help destinations after deliberate native menu actions.</summary>
|
|
public sealed partial class MainWindow
|
|
{
|
|
/// <summary>Shows this Windows app's repository in the user's default browser.</summary>
|
|
private async void GitHub_Click(object sender, RoutedEventArgs args) => await OpenHelpPageAsync(SampleApp.Info.RepositoryUrl!);
|
|
|
|
|
|
|
|
/// <summary>Offers the app's issue templates without sending private document data.</summary>
|
|
private async void SubmitIssue_Click(object sender, RoutedEventArgs args) => await OpenHelpPageAsync(SampleApp.IssuesUrl);
|
|
|
|
|
|
|
|
/// <summary>Opens community questions and tips in this app's repository.</summary>
|
|
private async void CommunitySupport_Click(object sender, RoutedEventArgs args) => await OpenHelpPageAsync(SampleApp.SupportUrl);
|
|
|
|
|
|
|
|
/// <summary>A missing browser or OS launch failure is visible; no document path/content is included.</summary>
|
|
private async Task OpenHelpPageAsync(Uri target)
|
|
{
|
|
try
|
|
{
|
|
if(!await global::Windows.System.Launcher.LaunchUriAsync(target))
|
|
{
|
|
StatusText.Text = "The link could not be opened. Check your default browser.";
|
|
}
|
|
}
|
|
catch(Exception exception) when(exception is System.Runtime.InteropServices.COMException or InvalidOperationException or ArgumentException)
|
|
{
|
|
StatusText.Text = "The link could not be opened. Check your default browser.";
|
|
App.Log.Warning(FormattableString.Invariant($"A Help link could not be opened ({exception.GetType().Name}, 0x{exception.HResult:X8})."));
|
|
}
|
|
}
|
|
}
|