2014-05-21 07:36:05 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Net;
|
2015-02-08 22:51:52 +01:00
|
|
|
|
|
2014-05-21 07:36:05 +02:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.IO.Compression;
|
|
|
|
|
using System.Diagnostics;
|
2018-01-31 07:04:56 +01:00
|
|
|
|
//using NonFormTimer = System.Threading.Timer;
|
|
|
|
|
using NonFormTimer = System.Timers.Timer;
|
2018-01-31 05:20:46 +01:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using static DS4Windows.Global;
|
2014-05-21 07:36:05 +02:00
|
|
|
|
|
2019-04-30 21:29:50 +02:00
|
|
|
|
namespace DS4Windows.Forms
|
2014-05-21 07:36:05 +02:00
|
|
|
|
{
|
|
|
|
|
public partial class WelcomeDialog : Form
|
|
|
|
|
{
|
2019-04-23 00:26:51 +02:00
|
|
|
|
private const string InstallerDL =
|
2019-05-17 05:02:03 +02:00
|
|
|
|
"https://github.com/ViGEm/ViGEmBus/releases/download/v1.16.112/ViGEmBus_Setup_1.16.115.exe";
|
|
|
|
|
private const string InstFileName = "ViGEmBus_Setup_1.16.115.exe";
|
2019-04-23 00:26:51 +02:00
|
|
|
|
|
2019-05-28 07:50:50 +02:00
|
|
|
|
Process monitorProc;
|
|
|
|
|
|
2018-01-31 05:20:46 +01:00
|
|
|
|
public WelcomeDialog(bool loadConfig=false)
|
2014-05-21 07:36:05 +02:00
|
|
|
|
{
|
2018-01-31 05:20:46 +01:00
|
|
|
|
if (loadConfig)
|
|
|
|
|
{
|
|
|
|
|
Global.FindConfigLocation();
|
|
|
|
|
Global.Load();
|
|
|
|
|
Global.SetCulture(Global.UseLang);
|
|
|
|
|
}
|
2018-02-06 23:44:18 +01:00
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Icon = Properties.Resources.DS4;
|
2014-05-21 07:36:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bnFinish_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void linkBluetoothSettings_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Process.Start("control", "bthprops.cpl");
|
|
|
|
|
}
|
2019-03-19 06:47:26 +01:00
|
|
|
|
|
2014-05-21 07:36:05 +02:00
|
|
|
|
private void bnStep1_Click(object sender, EventArgs e)
|
2014-12-02 01:07:29 +01:00
|
|
|
|
{
|
2019-04-23 00:26:51 +02:00
|
|
|
|
if (File.Exists(exepath + $"\\{InstFileName}"))
|
|
|
|
|
{
|
|
|
|
|
File.Delete(exepath + $"\\{InstFileName}");
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-21 07:36:05 +02:00
|
|
|
|
WebClient wb = new WebClient();
|
2019-04-23 00:26:51 +02:00
|
|
|
|
wb.DownloadFileAsync(new Uri(InstallerDL), exepath + $"\\{InstFileName}");
|
|
|
|
|
|
2019-03-19 06:47:26 +01:00
|
|
|
|
wb.DownloadProgressChanged += wb_DownloadProgressChanged;
|
|
|
|
|
wb.DownloadFileCompleted += wb_DownloadFileCompleted;
|
2014-05-21 07:36:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void wb_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
|
|
|
|
|
{
|
2014-08-17 00:09:15 +02:00
|
|
|
|
bnStep1.Text = Properties.Resources.Downloading.Replace("*number*", e.ProgressPercentage.ToString());
|
2014-05-21 07:36:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void wb_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
|
|
|
|
|
{
|
2019-03-19 06:47:26 +01:00
|
|
|
|
if (Directory.Exists(exepath + "\\ViGEmBusInstaller"))
|
2014-05-21 07:36:05 +02:00
|
|
|
|
{
|
2019-03-19 06:47:26 +01:00
|
|
|
|
Directory.Delete(exepath + "\\ViGEmBusInstaller", true);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-23 00:26:51 +02:00
|
|
|
|
if (File.Exists(exepath + $"\\{InstFileName}"))
|
2019-03-19 06:47:26 +01:00
|
|
|
|
{
|
|
|
|
|
bnStep1.Text = Properties.Resources.OpeningInstaller;
|
2019-10-11 14:29:04 +02:00
|
|
|
|
monitorProc = Process.Start(exepath + $"\\{InstFileName}", "/exenoupdates");
|
2019-03-19 06:47:26 +01:00
|
|
|
|
bnStep1.Text = Properties.Resources.Installing;
|
2014-12-02 01:07:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-31 07:04:56 +01:00
|
|
|
|
NonFormTimer timer = new NonFormTimer();
|
|
|
|
|
timer.Elapsed += timer_Tick;
|
|
|
|
|
timer.Start();
|
2014-05-21 07:36:05 +02:00
|
|
|
|
}
|
2018-01-31 07:04:56 +01:00
|
|
|
|
|
2014-05-21 07:36:05 +02:00
|
|
|
|
private void timer_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
2019-05-28 07:50:50 +02:00
|
|
|
|
if (monitorProc != null && monitorProc.HasExited)
|
2014-05-21 07:36:05 +02:00
|
|
|
|
{
|
2019-03-19 07:33:41 +01:00
|
|
|
|
if (Global.IsViGEmBusInstalled())
|
2015-12-05 09:55:11 +01:00
|
|
|
|
{
|
2018-01-31 07:04:56 +01:00
|
|
|
|
this.BeginInvoke((Action)(() => { bnStep1.Text = Properties.Resources.InstallComplete; }));
|
2014-05-21 07:36:05 +02:00
|
|
|
|
}
|
2019-03-19 06:47:26 +01:00
|
|
|
|
else
|
2014-12-02 01:07:29 +01:00
|
|
|
|
{
|
2019-03-19 06:47:26 +01:00
|
|
|
|
this.BeginInvoke((Action)(() => { bnStep1.Text = Properties.Resources.InstallFailed; }), null);
|
2014-12-02 01:07:29 +01:00
|
|
|
|
}
|
2018-01-31 07:04:56 +01:00
|
|
|
|
|
2019-04-23 00:26:51 +02:00
|
|
|
|
File.Delete(exepath + $"\\{InstFileName}");
|
2018-02-04 21:18:49 +01:00
|
|
|
|
((NonFormTimer)sender).Stop();
|
2014-05-21 07:36:05 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-03-20 00:50:01 +01:00
|
|
|
|
Process.Start("http://www.microsoft.com/accessories/en-gb/d/xbox-360-controller-for-windows");
|
2014-05-21 07:36:05 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|