From 872cb5e34c754f5daae2cb9023b0c4c3564fb37b Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Fri, 21 Jan 2022 15:20:47 -0700 Subject: [PATCH] Add UIUtils, link links on the sidebar --- Wabbajack.App.Blazor/Components/SideBar.razor | 13 ++++-- Wabbajack.App.Blazor/Utility/UIUtils.cs | 45 +++++++++++++++++++ 2 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 Wabbajack.App.Blazor/Utility/UIUtils.cs diff --git a/Wabbajack.App.Blazor/Components/SideBar.razor b/Wabbajack.App.Blazor/Components/SideBar.razor index 73bdb9ca..be9cfb37 100644 --- a/Wabbajack.App.Blazor/Components/SideBar.razor +++ b/Wabbajack.App.Blazor/Components/SideBar.razor @@ -1,12 +1,17 @@ -@namespace Wabbajack.App.Blazor.Components +@code { + private void OpenPatreonPage() => UIUtils.OpenWebsite(new Uri("https://www.patreon.com/user?u=11907933")); + private void OpenGithubPage() => UIUtils.OpenWebsite(new Uri("https://github.com/wabbajack-tools/wabbajack")); + private void OpenDiscord() => UIUtils.OpenWebsite(new Uri("https://discord.gg/wabbajack")); +} +@namespace Wabbajack.App.Blazor.Components diff --git a/Wabbajack.App.Blazor/Utility/UIUtils.cs b/Wabbajack.App.Blazor/Utility/UIUtils.cs new file mode 100644 index 00000000..652cb2b6 --- /dev/null +++ b/Wabbajack.App.Blazor/Utility/UIUtils.cs @@ -0,0 +1,45 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Media.Imaging; +using Wabbajack.Hashing.xxHash64; +using Wabbajack.Paths; +using Wabbajack.Paths.IO; + +namespace Wabbajack +{ + public static class UIUtils + { + public static void OpenWebsite(Uri url) + { + Process.Start(new ProcessStartInfo("cmd.exe", $"/c start {url}") + { + CreateNoWindow = true, + }); + } + + public static void OpenFolder(AbsolutePath path) + { + Process.Start(new ProcessStartInfo(KnownFolders.Windows.Combine("explorer.exe").ToString(), path.ToString()) + { + CreateNoWindow = true, + }); + } + + + public static AbsolutePath OpenFileDialog(string filter, string initialDirectory = null) + { + OpenFileDialog ofd = new OpenFileDialog(); + ofd.Filter = filter; + ofd.InitialDirectory = initialDirectory; + if (ofd.ShowDialog() == DialogResult.OK) + return (AbsolutePath)ofd.FileName; + return default; + } + + } +}