Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions DesktopClock/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@ public MainWindow()
/// Copies the current time string to the clipboard.
/// </summary>
[RelayCommand]
public void CopyToClipboard() => Clipboard.SetText(CurrentTimeOrCountdownString);
public void CopyToClipboard()
{
try
{
Clipboard.SetText(CurrentTimeOrCountdownString);
}
catch
{
_trayIcon?.ShowNotification("Copy failed", "ouldn't update the clipboard. Try again.");
}
}

/// <summary>
/// Minimizes the window.
Expand Down Expand Up @@ -239,7 +249,7 @@ private void TryPlaySound()
}
catch
{
// Ignore errors because we don't want a sound issue to crash the app.
_trayIcon?.ShowNotification("Alert sound unavailable", "The WAV file couldn't be played.");
}
}

Expand Down Expand Up @@ -403,8 +413,15 @@ private void Window_KeyDown(object sender, KeyEventArgs e)
}
}

private static void OpenUrl(string url)
private void OpenUrl(string url)
{
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
try
{
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
catch
{
_trayIcon?.ShowNotification("Couldn't open link", url);
}
}
}
15 changes: 12 additions & 3 deletions DesktopClock/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private void PickColor(Action<Color> applyColor, Color currentColor)

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri) { UseShellExecute = true });
OpenUrl(e.Uri.AbsoluteUri);
e.Handled = true;
}

Expand Down Expand Up @@ -221,9 +221,18 @@ private void SettingsWindow_Closing(object sender, CancelEventArgs e)
ViewModel.Settings.SettingsScrollPosition = SettingsScrollViewer.VerticalOffset;
}

private static void OpenUrl(string url)
private void OpenUrl(string url)
{
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
try
{
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
catch
{
MessageBox.Show(this,
$"Couldn't open {url}.",
Title, MessageBoxButton.OK, MessageBoxImage.Error);
}
}

private static void OpenSettingsPath(string filePath)
Expand Down