using System.ComponentModel; using System.Diagnostics; using System.Windows; using System.Windows.Navigation; using CursorLang.Services; using CursorLang.ViewModels; namespace CursorLang.Views; /// /// The settings window of the application. /// public partial class MainWindow : Window { public MainWindow( SettingsViewModel viewModel, IThemeService theme, MainWindowPlacement placement, MainWindowPresenter presenter) { InitializeComponent(); DataContext = viewModel; theme.Register(this); placement.Attach(this); presenter.Attach(this); } /// /// Opens the release page in a browser. A link in WPF leads nowhere on its own: /// where to hand it over is up to the application. /// private void OnReleaseLinkNavigate(object sender, RequestNavigateEventArgs e) { e.Handled = true; try { Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri) { UseShellExecute = true })?.Dispose(); } catch (Exception exception) when (exception is Win32Exception or InvalidOperationException) { // There is no browser in the system — that does not get in the way of the // update, which is downloaded by the button next to it anyway } } }