77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Markup.Xaml;
|
|
using Avalonia.Threading;
|
|
using FluentAvalonia.UI.Controls;
|
|
using Microsoft.Win32;
|
|
|
|
namespace VaultSmpInstaller.Views;
|
|
|
|
public partial class RemoveOverwolfWindow : Window
|
|
{
|
|
public RemoveOverwolfWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Continue(object? sender, RoutedEventArgs e)
|
|
{
|
|
Dispatcher.UIThread.Invoke(Close);
|
|
}
|
|
|
|
private void UninstallOldVersion(object? sender, RoutedEventArgs e)
|
|
{
|
|
string keyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwolf";
|
|
string valueName = "UninstallString";
|
|
String? uninstallPath = (string?)Registry.GetValue(keyPath, valueName, null);
|
|
|
|
|
|
if (uninstallPath != null)
|
|
{
|
|
Process proc = new Process();
|
|
proc.StartInfo.FileName = uninstallPath[..uninstallPath.LastIndexOf('/')].Replace('"', ' ').Trim();
|
|
proc.StartInfo.UseShellExecute = true;
|
|
proc.StartInfo.Verb = "runas";
|
|
proc.Start();
|
|
}
|
|
}
|
|
|
|
private void DownloadNewLaucher(object? sender, RoutedEventArgs e)
|
|
{
|
|
OpenUrl("https://download.overwolf.com/install/Download?ExtensionId=cfiahnpaolfnlgaihhmobmnjdafknjnjdpdabpcm");
|
|
}
|
|
|
|
private void OpenUrl(string url)
|
|
{
|
|
try
|
|
{
|
|
Process.Start(url);
|
|
}
|
|
catch
|
|
{
|
|
// hack because of this: https://github.com/dotnet/corefx/issues/10361
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
{
|
|
url = url.Replace("&", "^&");
|
|
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
|
}
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
{
|
|
Process.Start("xdg-open", url);
|
|
}
|
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
{
|
|
Process.Start("open", url);
|
|
}
|
|
else
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
} |