mirror of
https://github.com/sp-tarkov/launcher.git
synced 2025-02-13 05:30:43 -05:00
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using SPT.Launcher.Controllers;
|
|
using SPT.Launcher.Helpers;
|
|
using SPT.Launcher.Models.Launcher;
|
|
using SPT.Launcher.ViewModels.Dialogs;
|
|
using ReactiveUI;
|
|
|
|
namespace SPT.Launcher.ViewModels;
|
|
|
|
public class ModInfoViewModel : ViewModelBase
|
|
{
|
|
public ModInfoCollection ModsCollection { get; set; }
|
|
public ModInfoViewModel(IScreen Host, ModInfoCollection mods) : base(Host)
|
|
{
|
|
ModsCollection = mods;
|
|
}
|
|
|
|
public async Task OpenUrlCommand(string url)
|
|
{
|
|
if (!url.StartsWith("https://") && !url.StartsWith("https://"))
|
|
{
|
|
LogManager.Instance.Warning($"url does not start with http/s \n -URL-> '{url}'");
|
|
return;
|
|
}
|
|
|
|
var question = String.Format(LocalizationProvider.Instance.open_link_question_format_1, url);
|
|
var confirmText = LocalizationProvider.Instance.open_link;
|
|
var cancelText = LocalizationProvider.Instance.cancel;
|
|
|
|
var confirm = await ShowDialog(new ConfirmationDialogViewModel(HostScreen, question, confirmText, cancelText));
|
|
|
|
if (confirm is not (bool and true))
|
|
return;
|
|
|
|
Process.Start(new ProcessStartInfo
|
|
{
|
|
FileName = "cmd.exe",
|
|
UseShellExecute = true,
|
|
WindowStyle = ProcessWindowStyle.Hidden,
|
|
ArgumentList = { "/C", "start", url }
|
|
});
|
|
}
|
|
} |