Change old url to updater. Minor tweaks.

This commit is contained in:
Travis Nickles 2017-08-29 21:57:31 -05:00
parent 506ab59894
commit acb15eb7f8

View File

@ -17,6 +17,7 @@ using System.Security.Principal;
using System.Threading; using System.Threading;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using TaskRunner = System.Threading.Tasks.Task; using TaskRunner = System.Threading.Tasks.Task;
using NonFormTimer = System.Timers.Timer;
using static DS4Windows.Global; using static DS4Windows.Global;
namespace DS4Windows namespace DS4Windows
@ -28,28 +29,27 @@ namespace DS4Windows
delegate void NotificationDelegate(object sender, DebugEventArgs args); delegate void NotificationDelegate(object sender, DebugEventArgs args);
delegate void DeviceStatusChangedDelegate(object sender, DeviceStatusChangeEventArgs args); delegate void DeviceStatusChangedDelegate(object sender, DeviceStatusChangeEventArgs args);
delegate void DeviceSerialChangedDelegate(object sender, SerialChangeArgs args); delegate void DeviceSerialChangedDelegate(object sender, SerialChangeArgs args);
protected Label[] Pads, Batteries; private Label[] Pads, Batteries;
protected ComboBox[] cbs; private ComboBox[] cbs;
protected Button[] ebns; private Button[] ebns;
protected Button[] lights; private Button[] lights;
protected PictureBox[] statPB; private PictureBox[] statPB;
protected ToolStripMenuItem[] shortcuts; private ToolStripMenuItem[] shortcuts;
WebClient wc = new WebClient(); WebClient wc = new WebClient();
System.Timers.Timer hotkeysTimer = new System.Timers.Timer(); NonFormTimer hotkeysTimer = new NonFormTimer();
System.Timers.Timer autoProfilesTimer = new System.Timers.Timer(); NonFormTimer autoProfilesTimer = new NonFormTimer();
string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName; string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
string appDataPpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows"; string appDataPpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows";
string oldappdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool"; string oldappdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool";
string tempProfileProgram = string.Empty; string tempProfileProgram = string.Empty;
float dpix, dpiy; double dpix, dpiy;
List<string> profilenames = new List<string>(); List<string> profilenames = new List<string>();
List<string> programpaths = new List<string>(); List<string> programpaths = new List<string>();
List<string>[] proprofiles; List<string>[] proprofiles;
List<bool> turnOffTempProfiles; List<bool> turnOffTempProfiles;
private static int WM_QUERYENDSESSION = 0x11;
private static bool systemShutdown = false; private bool systemShutdown = false;
private bool wasrunning = false; private bool wasrunning = false;
delegate void HotKeysDelegate(object sender, EventArgs e);
Options opt; Options opt;
public Size oldsize; public Size oldsize;
public bool mAllowVisible; public bool mAllowVisible;
@ -59,11 +59,12 @@ namespace DS4Windows
bool runningBat; bool runningBat;
Dictionary<Control, string> hoverTextDict = new Dictionary<Control, string>(); Dictionary<Control, string> hoverTextDict = new Dictionary<Control, string>();
// 0 index is used for application version text. 1 - 4 indices are used for controller status // 0 index is used for application version text. 1 - 4 indices are used for controller status
string[] notifyText = new string[5] { "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion, string[] notifyText = new string[5]
{ "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion,
string.Empty, string.Empty, string.Empty, string.Empty }; string.Empty, string.Empty, string.Empty, string.Empty };
internal const int BCM_FIRST = 0x1600; // Normal button internal const string UPDATER_VERSION = "1.1.404.0";
internal const int BCM_SETSHIELD = (BCM_FIRST + 0x000C); // Elevated button internal static int WM_QUERYENDSESSION = 0x11;
[DllImport("user32.dll")] [DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow(); private static extern IntPtr GetForegroundWindow();
@ -77,9 +78,6 @@ namespace DS4Windows
[DllImport("kernel32.dll")] [DllImport("kernel32.dll")]
private static extern bool CloseHandle(IntPtr handle); private static extern bool CloseHandle(IntPtr handle);
[DllImport("psapi.dll")]
private static extern uint GetModuleBaseName(IntPtr hWnd, IntPtr hModule, StringBuilder lpFileName, int nSize);
[DllImport("psapi.dll")] [DllImport("psapi.dll")]
private static extern uint GetModuleFileNameEx(IntPtr hWnd, IntPtr hModule, StringBuilder lpFileName, int nSize); private static extern uint GetModuleFileNameEx(IntPtr hWnd, IntPtr hModule, StringBuilder lpFileName, int nSize);
@ -93,7 +91,7 @@ namespace DS4Windows
bnEditC3.Tag = 2; bnEditC3.Tag = 2;
bnEditC4.Tag = 3; bnEditC4.Tag = 3;
this.StartWindowsCheckBox.CheckedChanged -= this.StartWindowsCheckBox_CheckedChanged; StartWindowsCheckBox.CheckedChanged -= StartWindowsCheckBox_CheckedChanged;
saveProfiles.Filter = Properties.Resources.XMLFiles + "|*.xml"; saveProfiles.Filter = Properties.Resources.XMLFiles + "|*.xml";
openProfiles.Filter = Properties.Resources.XMLFiles + "|*.xml"; openProfiles.Filter = Properties.Resources.XMLFiles + "|*.xml";
@ -156,7 +154,7 @@ namespace DS4Windows
return; return;
} }
Graphics g = this.CreateGraphics(); Graphics g = CreateGraphics();
try try
{ {
dpix = g.DpiX / 100f * 1.041666666667f; dpix = g.DpiX / 100f * 1.041666666667f;
@ -376,7 +374,7 @@ namespace DS4Windows
if (!Directory.Exists(appdatapath + "\\Virtual Bus Driver")) if (!Directory.Exists(appdatapath + "\\Virtual Bus Driver"))
linkUninstall.Visible = false; linkUninstall.Visible = false;
bool isElevated = Global.IsAdministrator(); bool isElevated = IsAdministrator();
if (!isElevated) if (!isElevated)
{ {
Image tempImg = new Bitmap(uacPictureBox.Width, uacPictureBox.Height); Image tempImg = new Bitmap(uacPictureBox.Width, uacPictureBox.Height);
@ -417,7 +415,7 @@ namespace DS4Windows
TaskRunner.Run(() => { UpdateTheUpdater(); }); TaskRunner.Run(() => { UpdateTheUpdater(); });
this.StartWindowsCheckBox.CheckedChanged += new EventHandler(this.StartWindowsCheckBox_CheckedChanged); StartWindowsCheckBox.CheckedChanged += new EventHandler(StartWindowsCheckBox_CheckedChanged);
new ToolTip().SetToolTip(StartWindowsCheckBox, Properties.Resources.RunAtStartup); new ToolTip().SetToolTip(StartWindowsCheckBox, Properties.Resources.RunAtStartup);
populateHoverTextDict(); populateHoverTextDict();
@ -501,7 +499,7 @@ namespace DS4Windows
if (!mAllowVisible) if (!mAllowVisible)
{ {
value = false; value = false;
if (!this.IsHandleCreated) CreateHandle(); if (!IsHandleCreated) CreateHandle();
} }
base.SetVisibleCore(value); base.SetVisibleCore(value);
@ -739,7 +737,7 @@ namespace DS4Windows
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
string version = fvi.FileVersion; string version = fvi.FileVersion;
string newversion = File.ReadAllText(appdatapath + "\\version.txt").Trim(); string newversion = File.ReadAllText(appdatapath + "\\version.txt").Trim();
if (version.Replace(',', '.').CompareTo(newversion) == -1)//CompareVersions(); if (version.Replace(',', '.').CompareTo(newversion) == -1)
{ {
if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion), if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion),
Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
@ -949,7 +947,7 @@ namespace DS4Windows
{ {
//Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; //Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
Program.rootHub.Start(uiContext, log); Program.rootHub.Start(uiContext, log);
this.Invoke((System.Action)(() => { serviceStartupFinish(); })); Invoke((System.Action)(() => { serviceStartupFinish(); }));
}); });
} }
@ -973,7 +971,7 @@ namespace DS4Windows
TaskRunner.Run(() => TaskRunner.Run(() =>
{ {
Program.rootHub.Stop(log); Program.rootHub.Stop(log);
this.Invoke((System.Action)(() => { serviceShutdownFinish(); })); Invoke((System.Action)(() => { serviceShutdownFinish(); }));
}); });
} }
@ -1503,7 +1501,7 @@ namespace DS4Windows
private void editMenu_Click(object sender, EventArgs e) private void editMenu_Click(object sender, EventArgs e)
{ {
mAllowVisible = true; mAllowVisible = true;
this.Show(); Show();
WindowState = FormWindowState.Normal; WindowState = FormWindowState.Normal;
ToolStripMenuItem em = (ToolStripMenuItem)sender; ToolStripMenuItem em = (ToolStripMenuItem)sender;
int i = Convert.ToInt32(em.Tag); int i = Convert.ToInt32(em.Tag);
@ -1611,13 +1609,13 @@ namespace DS4Windows
private void exitToolStripMenuItem_Click(object sender, EventArgs e) private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{ {
contextclose = true; contextclose = true;
this.Close(); Close();
} }
private void openToolStripMenuItem_Click(object sender, EventArgs e) private void openToolStripMenuItem_Click(object sender, EventArgs e)
{ {
mAllowVisible = true; mAllowVisible = true;
this.Show(); Show();
Focus(); Focus();
WindowState = FormWindowState.Normal; WindowState = FormWindowState.Normal;
} }
@ -1632,13 +1630,13 @@ namespace DS4Windows
if (e.Button == MouseButtons.Middle) if (e.Button == MouseButtons.Middle)
{ {
contextclose = true; contextclose = true;
this.Close(); Close();
} }
} }
private void notifyIcon1_BalloonTipClicked(object sender, EventArgs e) private void notifyIcon1_BalloonTipClicked(object sender, EventArgs e)
{ {
this.Show(); Show();
WindowState = FormWindowState.Normal; WindowState = FormWindowState.Normal;
} }
@ -1958,22 +1956,22 @@ namespace DS4Windows
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
string version2 = fvi.FileVersion; string version2 = fvi.FileVersion;
string newversion2 = File.ReadAllText(appdatapath + "\\version.txt").Trim(); string newversion2 = File.ReadAllText(appdatapath + "\\version.txt").Trim();
if (version2.Replace(',', '.').CompareTo(newversion2) == -1)//CompareVersions(); if (version2.Replace(',', '.').CompareTo(newversion2) == -1)
{ {
if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion2), if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion2),
Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
if (!File.Exists(exepath + "\\DS4Updater.exe") || (File.Exists(exepath + "\\DS4Updater.exe") if (!File.Exists(exepath + "\\DS4Updater.exe") || (File.Exists(exepath + "\\DS4Updater.exe")
&& (FileVersionInfo.GetVersionInfo(exepath + "\\DS4Updater.exe").FileVersion.CompareTo("1.1.0.0") == -1))) && (FileVersionInfo.GetVersionInfo(exepath + "\\DS4Updater.exe").FileVersion.CompareTo(UPDATER_VERSION) == -1)))
{ {
Uri url2 = new Uri("http://ds4windows.com/Files/DS4Updater.exe"); Uri url2 = new Uri("http://23.239.26.40/ds4windows/files/DS4Updater.exe");
WebClient wc2 = new WebClient(); WebClient wc2 = new WebClient();
if (appdatapath == exepath) if (appdatapath == exepath)
wc2.DownloadFile(url2, exepath + "\\DS4Updater.exe"); wc2.DownloadFile(url2, exepath + "\\DS4Updater.exe");
else else
{ {
MessageBox.Show(Properties.Resources.PleaseDownloadUpdater); MessageBox.Show(Properties.Resources.PleaseDownloadUpdater);
Process.Start("http://ds4windows.com/Files/DS4Updater.exe"); Process.Start("http://23.239.26.40/ds4windows/files/DS4Updater.exe");
} }
} }
@ -2067,7 +2065,7 @@ namespace DS4Windows
} }
else if (userClosing && closeMini && !contextclose) else if (userClosing && closeMini && !contextclose)
{ {
this.WindowState = FormWindowState.Minimized; WindowState = FormWindowState.Minimized;
e.Cancel = true; e.Cancel = true;
return; return;
} }