/*
* Copyright (c) 2026 James Maes (KofTwentyTwo)
* SPDX-License-Identifier: MIT
*/
using System.Diagnostics;
using System.Windows;
namespace AppKit.Sample.Wpf;
/// Opens the sample's fixed public Help destinations using the Windows default browser.
public partial class MainWindow
{
/// Shows the sample's source repository.
private void GitHub_Click(object sender, RoutedEventArgs args) => OpenHelpPage(SampleApp.Info.RepositoryUrl!);
/// Offers the repository's bug/feature templates.
private void SubmitIssue_Click(object sender, RoutedEventArgs args) => OpenHelpPage(SampleApp.IssuesUrl);
/// Opens the sample's community support destination.
private void CommunitySupport_Click(object sender, RoutedEventArgs args) => OpenHelpPage(SampleApp.SupportUrl);
/// Surfaces OS/browser launch failure without passing private app data to the shell.
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})."));
}
}
}