Files
AppKit/samples/AppKit.Sample.Wpf/MainWindow.Help.cs
james.maesandCodex f58aac9987 feat(samples): add repository issue and community Help links
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>
2026-10-11 16:33:13 -05:00

44 lines
1.5 KiB
C#

/*
* Copyright (c) 2026 James Maes (KofTwentyTwo)
* SPDX-License-Identifier: MIT
*/
using System.Diagnostics;
using System.Windows;
namespace AppKit.Sample.Wpf;
/// <summary>Opens the sample's fixed public Help destinations using the Windows default browser.</summary>
public partial class MainWindow
{
/// <summary>Shows the sample's source repository.</summary>
private void GitHub_Click(object sender, RoutedEventArgs args) => OpenHelpPage(SampleApp.Info.RepositoryUrl!);
/// <summary>Offers the repository's bug/feature templates.</summary>
private void SubmitIssue_Click(object sender, RoutedEventArgs args) => OpenHelpPage(SampleApp.IssuesUrl);
/// <summary>Opens the sample's community support destination.</summary>
private void CommunitySupport_Click(object sender, RoutedEventArgs args) => OpenHelpPage(SampleApp.SupportUrl);
/// <summary>Surfaces OS/browser launch failure without passing private app data to the shell.</summary>
private void OpenHelpPage(Uri target)
{
try
{
using var process = Process.Start(new ProcessStartInfo(target.AbsoluteUri) { UseShellExecute = true });
}
catch(Exception exception) when(exception is System.ComponentModel.Win32Exception or InvalidOperationException)
{
StatusText.Text = "The link could not be opened. Check your default browser.";
Program.Log.Warning(FormattableString.Invariant($"A Help link could not be opened ({exception.GetType().Name}, 0x{exception.HResult:X8})."));
}
}
}