wabbajack/Wabbajack.App.Blazor/Utility/UIUtils.cs

40 lines
1.1 KiB
C#
Raw Normal View History

2022-01-21 22:20:47 +00:00
using System;
using System.Diagnostics;
using System.Windows.Forms;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
2022-01-28 11:58:28 +00:00
namespace Wabbajack.App.Blazor.Utility
2022-01-21 22:20:47 +00:00
{
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,
});
}
2022-01-28 11:58:28 +00:00
public static AbsolutePath OpenFileDialog(string filter, string? initialDirectory = null)
2022-01-21 22:20:47 +00:00
{
2022-01-28 11:58:28 +00:00
var ofd = new OpenFileDialog();
2022-01-21 22:20:47 +00:00
ofd.Filter = filter;
2022-01-28 11:58:28 +00:00
ofd.InitialDirectory = initialDirectory ?? string.Empty;
2022-01-21 22:20:47 +00:00
if (ofd.ShowDialog() == DialogResult.OK)
return (AbsolutePath)ofd.FileName;
return default;
}
}
}