Code clean up

This commit is contained in:
Travis Nickles 2017-05-12 22:54:29 -07:00
parent 959966b15c
commit 7a1b382c5a
3 changed files with 1669 additions and 2292 deletions

View File

@ -33,7 +33,6 @@
this.lvDebug = new System.Windows.Forms.ListView();
this.chTime = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chData = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tmrUpdate = new System.Windows.Forms.Timer(this.components);
this.pnlButton = new System.Windows.Forms.Panel();
this.llbHelp = new System.Windows.Forms.LinkLabel();
this.lbTest = new System.Windows.Forms.Label();
@ -207,11 +206,6 @@
//
resources.ApplyResources(this.chData, "chData");
//
// tmrUpdate
//
this.tmrUpdate.Interval = 1;
this.tmrUpdate.Tick += new System.EventHandler(this.ControllerStatusChange);
//
// pnlButton
//
this.pnlButton.BackColor = System.Drawing.SystemColors.Control;
@ -442,7 +436,7 @@
//
resources.ApplyResources(this.bnEditC3, "bnEditC3");
this.bnEditC3.Name = "bnEditC3";
this.bnEditC3.Tag = "2";
this.bnEditC3.Tag = "";
this.bnEditC3.UseVisualStyleBackColor = true;
this.bnEditC3.Click += new System.EventHandler(this.editButtons_Click);
//
@ -450,7 +444,7 @@
//
resources.ApplyResources(this.bnEditC4, "bnEditC4");
this.bnEditC4.Name = "bnEditC4";
this.bnEditC4.Tag = "3";
this.bnEditC4.Tag = "";
this.bnEditC4.UseVisualStyleBackColor = true;
this.bnEditC4.Click += new System.EventHandler(this.editButtons_Click);
//
@ -483,7 +477,7 @@
//
resources.ApplyResources(this.bnEditC2, "bnEditC2");
this.bnEditC2.Name = "bnEditC2";
this.bnEditC2.Tag = "1";
this.bnEditC2.Tag = "";
this.bnEditC2.UseVisualStyleBackColor = true;
this.bnEditC2.Click += new System.EventHandler(this.editButtons_Click);
//
@ -509,7 +503,7 @@
//
resources.ApplyResources(this.bnEditC1, "bnEditC1");
this.bnEditC1.Name = "bnEditC1";
this.bnEditC1.Tag = "0";
this.bnEditC1.Tag = "";
this.bnEditC1.UseVisualStyleBackColor = true;
this.bnEditC1.Click += new System.EventHandler(this.editButtons_Click);
//
@ -1265,7 +1259,6 @@
private System.Windows.Forms.ListView lvDebug;
private System.Windows.Forms.ColumnHeader chTime;
private System.Windows.Forms.ColumnHeader chData;
private System.Windows.Forms.Timer tmrUpdate;
private System.Windows.Forms.Panel pnlButton;
private System.Windows.Forms.Button btnStartStop;
private System.Windows.Forms.Button btnClear;

View File

@ -91,6 +91,11 @@ namespace DS4Windows
{
InitializeComponent();
bnEditC1.Tag = 0;
bnEditC2.Tag = 1;
bnEditC3.Tag = 2;
bnEditC4.Tag = 3;
this.StartWindowsCheckBox.CheckedChanged -= this.StartWindowsCheckBox_CheckedChanged;
saveProfiles.Filter = Properties.Resources.XMLFiles + "|*.xml";
@ -322,7 +327,7 @@ namespace DS4Windows
autoProfilesTimer.Interval = 1000;
LoadP();
Global.ControllerStatusChange += ControllerStatusChange;
//Global.ControllerStatusChange += ControllerStatusChange;
Global.BatteryStatusChange += BatteryStatusUpdate;
Global.ControllerRemoved += ControllerRemovedChange;
Global.DeviceStatusChange += DeviceStatusChanged;
@ -420,10 +425,21 @@ namespace DS4Windows
UpdateTheUpdater();
this.StartWindowsCheckBox.CheckedChanged += new System.EventHandler(this.StartWindowsCheckBox_CheckedChanged);
this.StartWindowsCheckBox.CheckedChanged += new EventHandler(this.StartWindowsCheckBox_CheckedChanged);
new ToolTip().SetToolTip(StartWindowsCheckBox, Properties.Resources.RunAtStartup);
populateHoverTextDict();
foreach (Control control in fLPSettings.Controls)
{
if (control.HasChildren)
{
foreach (Control ctrl in control.Controls)
ctrl.MouseHover += Items_MouseHover;
}
control.MouseHover += Items_MouseHover;
}
}
private void populateHoverTextDict()
@ -786,9 +802,11 @@ namespace DS4Windows
{
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
string version = fvi.FileVersion;
string newversion = File.ReadAllText(appdatapath + "\\version.txt");
string newversion = File.ReadAllText(appdatapath + "\\version.txt").Trim();
if (version.Replace(',', '.').CompareTo(newversion) == -1)//CompareVersions();
if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion), Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion),
Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
if (!File.Exists(exepath + "\\DS4Updater.exe") || (File.Exists(exepath + "\\DS4Updater.exe")
&& (FileVersionInfo.GetVersionInfo(exepath + "\\DS4Updater.exe").FileVersion.CompareTo("1.1.0.0") == -1)))
@ -803,17 +821,20 @@ namespace DS4Windows
Process.Start("http://23.239.26.40/ds4windows/files/DS4Updater.exe");
}
}
Process p = new Process();
p.StartInfo.FileName = exepath + "\\DS4Updater.exe";
if (!cBDownloadLangauge.Checked)
p.StartInfo.Arguments = "-skipLang";
if (AdminNeeded())
p.StartInfo.Verb = "runas";
try { p.Start(); Close(); }
catch { }
}
else
File.Delete(appdatapath + "\\version.txt");
}
else
File.Delete(appdatapath + "\\version.txt");
}
@ -825,8 +846,11 @@ namespace DS4Windows
profilenames.Clear();
string[] profiles = Directory.GetFiles(appdatapath + @"\Profiles\");
foreach (String s in profiles)
{
if (s.EndsWith(".xml"))
profilenames.Add(Path.GetFileNameWithoutExtension(s));
}
lBProfiles.Items.Clear();
lBProfiles.Items.AddRange(profilenames.ToArray());
if (lBProfiles.Items.Count == 0)
@ -843,7 +867,9 @@ namespace DS4Windows
cbs[i].Items.AddRange(profilenames.ToArray());
foreach (string s in profilenames)
shortcuts[i].DropDownItems.Add(s);
for (int j = 0; j < cbs[i].Items.Count; j++)
for (int j = 0, itemCount = cbs[i].Items.Count; j < itemCount; j++)
{
if (cbs[i].Items[j].ToString() == Path.GetFileNameWithoutExtension(ProfilePath[i]))
{
cbs[i].SelectedIndex = j;
@ -861,6 +887,7 @@ namespace DS4Windows
}
}
}
}
catch (DirectoryNotFoundException)
{
Directory.CreateDirectory(appdatapath + @"\Profiles\");
@ -890,7 +917,7 @@ namespace DS4Windows
tabAutoProfiles.Controls.Clear();
WP = new WinProgs(profilenames.ToArray(), this);
WP.TopLevel = false;
WP.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
WP.FormBorderStyle = FormBorderStyle.None;
WP.Visible = true;
WP.Dock = DockStyle.Fill;
tabAutoProfiles.Controls.Add(WP);
@ -1205,15 +1232,16 @@ namespace DS4Windows
}
}
protected void ControllerStatusChange(object sender, EventArgs e)
/*protected void ControllerStatusChange(object sender, EventArgs e)
{
if (InvokeRequired)
Invoke(new ControllerStatusChangedDelegate(ControllerStatusChange), new object[] { sender, e });
else
ControllerStatusChanged();
}
*/
protected void ControllerStatusChanged()
/*protected void ControllerStatusChanged()
{
String tooltip = "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
bool nocontrollers = true;
@ -1270,15 +1298,23 @@ namespace DS4Windows
else
notifyIcon1.Text = tooltip;
}
*/
private void pBStatus_MouseClick(object sender, MouseEventArgs e)
{
int i = Int32.Parse(((PictureBox)sender).Tag.ToString());
if (e.Button == System.Windows.Forms.MouseButtons.Right && Program.rootHub.getDS4Status(i) == "BT" && !Program.rootHub.DS4Controllers[i].Charging)
Program.rootHub.DS4Controllers[i].DisconnectBT();
else if (e.Button == System.Windows.Forms.MouseButtons.Right && Program.rootHub.getDS4Status(i) == "SONYWA" && !Program.rootHub.DS4Controllers[i].Charging)
DS4Device d = Program.rootHub.DS4Controllers[i];
if (d != null)
{
Program.rootHub.DS4Controllers[i].DisconnectDongle();
if (e.Button == MouseButtons.Right && Program.rootHub.getDS4Status(i) == "BT" && !d.Charging)
{
d.DisconnectBT();
}
else if (e.Button == MouseButtons.Right &&
Program.rootHub.getDS4Status(i) == "SONYWA" && !d.Charging)
{
d.DisconnectDongle();
}
}
}
@ -1321,12 +1357,11 @@ namespace DS4Windows
{
if (e.KeyValue == 13)
ShowOptions(4, lBProfiles.SelectedItem.ToString());
if (e.KeyValue == 46)
else if (e.KeyValue == 46)
tsBDeleteProfle_Click(this, e);
if (e.KeyValue == 68 && e.Modifiers == Keys.Control)
else if (e.KeyValue == 68 && e.Modifiers == Keys.Control)
tSBDupProfile_Click(this, e);
}
}
private void assignToController1ToolStripMenuItem_Click(object sender, EventArgs e)
@ -1354,7 +1389,6 @@ namespace DS4Windows
ShowOptions(4, "");
}
private void tsBNEditProfile_Click(object sender, EventArgs e)
{
if (lBProfiles.SelectedIndex >= 0)
@ -1366,9 +1400,11 @@ namespace DS4Windows
if (lBProfiles.SelectedIndex >= 0)
{
string filename = lBProfiles.SelectedItem.ToString();
if (MessageBox.Show(Properties.Resources.ProfileCannotRestore.Replace("*Profile name*", "\"" + filename + "\""), Properties.Resources.DeleteProfile, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
if (MessageBox.Show(Properties.Resources.ProfileCannotRestore.Replace("*Profile name*", "\"" + filename + "\""),
Properties.Resources.DeleteProfile,
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
System.IO.File.Delete(appdatapath + @"\Profiles\" + filename + ".xml");
File.Delete(appdatapath + @"\Profiles\" + filename + ".xml");
RefreshProfiles();
}
}
@ -1384,7 +1420,7 @@ namespace DS4Windows
MTB.TopLevel = false;
MTB.Dock = DockStyle.Top;
MTB.Visible = true;
MTB.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
MTB.FormBorderStyle = FormBorderStyle.None;
tabProfiles.Controls.Add(MTB);
lBProfiles.SendToBack();
toolStrip1.SendToBack();
@ -1394,19 +1430,19 @@ namespace DS4Windows
}
}
private void tSBImportProfile_Click(object sender, EventArgs e)
{
if (appdatapath == Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName)
openProfiles.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool" + @"\Profiles\";
else
openProfiles.InitialDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\";
if (openProfiles.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (openProfiles.ShowDialog() == DialogResult.OK)
{
string[] files = openProfiles.FileNames;
for (int i = 0; i < files.Length; i++)
for (int i = 0, arlen = files.Length; i < arlen; i++)
File.Copy(openProfiles.FileNames[i], appdatapath + "\\Profiles\\" + Path.GetFileName(files[i]), true);
RefreshProfiles();
}
}
@ -1417,7 +1453,7 @@ namespace DS4Windows
{
Stream stream;
Stream profile = new StreamReader(appdatapath + "\\Profiles\\" + lBProfiles.SelectedItem.ToString() + ".xml").BaseStream;
if (saveProfiles.ShowDialog() == System.Windows.Forms.DialogResult.OK)
if (saveProfiles.ShowDialog() == DialogResult.OK)
{
if ((stream = saveProfiles.OpenFile()) != null)
{
@ -1432,6 +1468,7 @@ namespace DS4Windows
private void ShowOptions(int devID, string profile)
{
Show();
tabMain.SelectedIndex = 1;
WindowState = FormWindowState.Normal;
toolStrip1.Enabled = false;
tSOptions.Visible = true;
@ -1448,12 +1485,12 @@ namespace DS4Windows
oldsize = Size;
{
if (Size.Height < (int)(90 * dpiy) + Options.mSize.Height)
Size = new System.Drawing.Size(Size.Width, (int)(90 * dpiy) + Options.mSize.Height);
Size = new Size(Size.Width, (int)(90 * dpiy) + Options.mSize.Height);
if (Size.Width < (int)(20 * dpix) + Options.mSize.Width)
Size = new System.Drawing.Size((int)(20 * dpix) + Options.mSize.Width, Size.Height);
Size = new Size((int)(20 * dpix) + Options.mSize.Width, Size.Height);
}
tabMain.SelectedIndex = 1;
opt.Reload(devID, profile);
opt.inputtimer.Start();
opt.Visible = true;
@ -1487,11 +1524,13 @@ namespace DS4Windows
private void editButtons_Click(object sender, EventArgs e)
{
Button bn = (Button)sender;
int i = Int32.Parse(bn.Tag.ToString());
if (cbs[i].Text == "(" + Properties.Resources.NoProfileLoaded + ")")
ShowOptions(i, "");
//int i = Int32.Parse(bn.Tag.ToString());
int i = Convert.ToInt32(bn.Tag);
string profileText = cbs[i].Text;
if (profileText != "(" + Properties.Resources.NoProfileLoaded + ")")
ShowOptions(i, profileText);
else
ShowOptions(i, cbs[i].Text);
ShowOptions(i, "");
}
private void editMenu_Click(object sender, EventArgs e)
@ -1505,7 +1544,7 @@ namespace DS4Windows
ShowOptions(i, "");
else
{
for (int t = 0; t < em.DropDownItems.Count - 2; t++)
for (int t = 0, itemCount = em.DropDownItems.Count - 2; t < itemCount; t++)
{
if (((ToolStripMenuItem)em.DropDownItems[t]).Checked)
ShowOptions(i, ((ToolStripMenuItem)em.DropDownItems[t]).Text);
@ -1515,16 +1554,16 @@ namespace DS4Windows
private void lnkControllers_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("control", "joy.cpl");
Process.Start("control", "joy.cpl");
}
private void hideDS4CheckBox_CheckedChanged(object sender, EventArgs e)
{
// Prevent the Game Controllers window from throwing an error when controllers are un/hidden
System.Diagnostics.Process[] rundll64 = System.Diagnostics.Process.GetProcessesByName("rundll64");
foreach (System.Diagnostics.Process rundll64Instance in rundll64)
Process[] rundll64 = Process.GetProcessesByName("rundll64");
foreach (Process rundll64Instance in rundll64)
{
foreach (System.Diagnostics.ProcessModule module in rundll64Instance.Modules)
foreach (ProcessModule module in rundll64Instance.Modules)
{
if (module.FileName.Contains("joy.cpl"))
module.Dispose();
@ -1583,7 +1622,6 @@ namespace DS4Windows
}
OnDeviceStatusChanged(this, tdevice); //to update profile name in notify icon
//ControllerStatusChanged(); //to update profile name in notify icon
}
private void Profile_Changed_Menu(object sender, ToolStripItemClickedEventArgs e)
@ -1620,7 +1658,7 @@ namespace DS4Windows
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Middle)
if (e.Button == MouseButtons.Middle)
{
contextclose = true;
this.Close();
@ -1709,23 +1747,18 @@ namespace DS4Windows
private void tabMain_SelectedIndexChanged(object sender, EventArgs e)
{
lbLastMessage.Visible = tabMain.SelectedTab != tabLog;
if (tabMain.SelectedTab == tabLog)
TabPage currentTab = tabMain.SelectedTab;
lbLastMessage.Visible = currentTab != tabLog;
if (currentTab == tabLog)
chData.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
if (tabMain.SelectedTab == tabSettings)
if (currentTab == tabSettings)
{
lbLastMessage.ForeColor = SystemColors.GrayText;
lbLastMessage.Text = Properties.Resources.HoverOverItems;
foreach (System.Windows.Forms.Control control in fLPSettings.Controls)
{
if (control.HasChildren)
foreach (System.Windows.Forms.Control ctrl in control.Controls)
ctrl.MouseHover += Items_MouseHover;
control.MouseHover += Items_MouseHover;
}
}
else if (lvDebug.Items.Count > 0)
lbLastMessage.Text = lbLastMessage.Text = lvDebug.Items[lvDebug.Items.Count - 1].SubItems[1].Text;
lbLastMessage.Text = lvDebug.Items[lvDebug.Items.Count - 1].SubItems[1].Text;
else
lbLastMessage.Text = "";
@ -1772,7 +1805,7 @@ namespace DS4Windows
private void lBProfiles_MouseDown(object sender, MouseEventArgs e)
{
lBProfiles.SelectedIndex = lBProfiles.IndexFromPoint(e.X, e.Y);
if (e.Button == System.Windows.Forms.MouseButtons.Right)
if (e.Button == MouseButtons.Right)
{
if (lBProfiles.SelectedIndex < 0)
{
@ -1797,6 +1830,7 @@ namespace DS4Windows
assignToController2ToolStripMenuItem,
assignToController3ToolStripMenuItem,
assignToController4ToolStripMenuItem };
for (int i = 0; i < 4; i++)
{
if (lBProfiles.SelectedIndex == cbs[i].SelectedIndex)
@ -1804,6 +1838,7 @@ namespace DS4Windows
else
assigns[i].Checked = false;
}
deleteToolStripMenuItem.Visible = true;
editToolStripMenuItem.Visible = true;
duplicateToolStripMenuItem.Visible = true;
@ -1837,14 +1872,17 @@ namespace DS4Windows
e.Effect = DragDropEffects.None; // Unknown data, ignore it
}
private void tBProfile_TextChanged(object sender, EventArgs e)
{
if (tSTBProfile.Text != null && tSTBProfile.Text != "" && !tSTBProfile.Text.Contains("\\") && !tSTBProfile.Text.Contains("/") && !tSTBProfile.Text.Contains(":") && !tSTBProfile.Text.Contains("*") && !tSTBProfile.Text.Contains("?") && !tSTBProfile.Text.Contains("\"") && !tSTBProfile.Text.Contains("<") && !tSTBProfile.Text.Contains(">") && !tSTBProfile.Text.Contains("|"))
tSTBProfile.ForeColor = System.Drawing.SystemColors.WindowText;
if (tSTBProfile.Text != null && tSTBProfile.Text != "" &&
!tSTBProfile.Text.Contains("\\") && !tSTBProfile.Text.Contains("/") &&
!tSTBProfile.Text.Contains(":") && !tSTBProfile.Text.Contains("*") &&
!tSTBProfile.Text.Contains("?") && !tSTBProfile.Text.Contains("\"") &&
!tSTBProfile.Text.Contains("<") && !tSTBProfile.Text.Contains(">") &&
!tSTBProfile.Text.Contains("|"))
tSTBProfile.ForeColor = SystemColors.WindowText;
else
tSTBProfile.ForeColor = System.Drawing.SystemColors.GrayText;
tSTBProfile.ForeColor = SystemColors.GrayText;
}
private void tBProfile_Enter(object sender, EventArgs e)
@ -1872,7 +1910,12 @@ namespace DS4Windows
opt.saving = true;
opt.Set();
if (tSTBProfile.Text != null && tSTBProfile.Text != "" && !tSTBProfile.Text.Contains("\\") && !tSTBProfile.Text.Contains("/") && !tSTBProfile.Text.Contains(":") && !tSTBProfile.Text.Contains("*") && !tSTBProfile.Text.Contains("?") && !tSTBProfile.Text.Contains("\"") && !tSTBProfile.Text.Contains("<") && !tSTBProfile.Text.Contains(">") && !tSTBProfile.Text.Contains("|"))
if (tSTBProfile.Text != null && tSTBProfile.Text != "" &&
!tSTBProfile.Text.Contains("\\") && !tSTBProfile.Text.Contains("/") &&
!tSTBProfile.Text.Contains(":") && !tSTBProfile.Text.Contains("*") &&
!tSTBProfile.Text.Contains("?") && !tSTBProfile.Text.Contains("\"") &&
!tSTBProfile.Text.Contains("<") && !tSTBProfile.Text.Contains(">") &&
!tSTBProfile.Text.Contains("|"))
{
File.Delete(appdatapath + @"\Profiles\" + opt.filename + ".xml");
ProfilePath[opt.device] = tSTBProfile.Text;
@ -1911,15 +1954,18 @@ namespace DS4Windows
private void nUDUpdateTime_ValueChanged(object sender, EventArgs e)
{
if (cBUpdateTime.SelectedIndex == 0)
int currentIndex = cBUpdateTime.SelectedIndex;
if (currentIndex == 0)
CheckWhen = (int)nUDUpdateTime.Value;
else if (cBUpdateTime.SelectedIndex == 1)
else if (currentIndex == 1)
CheckWhen = (int)nUDUpdateTime.Value * 24;
if (nUDUpdateTime.Value < 1)
cBUpdate.Checked = false;
if (nUDUpdateTime.Value == 1)
{
int index = cBUpdateTime.SelectedIndex;
int index = currentIndex;
cBUpdateTime.Items.Clear();
cBUpdateTime.Items.Add(Properties.Resources.Hour);
cBUpdateTime.Items.Add(Properties.Resources.Day);
@ -1927,7 +1973,7 @@ namespace DS4Windows
}
else if (cBUpdateTime.Items[0].ToString() == Properties.Resources.Hour)
{
int index = cBUpdateTime.SelectedIndex;
int index = currentIndex;
cBUpdateTime.Items.Clear();
cBUpdateTime.Items.Add(Properties.Resources.Hours);
cBUpdateTime.Items.Add(Properties.Resources.Days);
@ -1937,15 +1983,17 @@ namespace DS4Windows
private void cBUpdateTime_SelectedIndexChanged(object sender, EventArgs e)
{
if (cBUpdateTime.SelectedIndex == 0)
int index = cBUpdateTime.SelectedIndex;
if (index == 0)
CheckWhen = (int)nUDUpdateTime.Value;
else if (cBUpdateTime.SelectedIndex == 1)
else if (index == 1)
CheckWhen = (int)nUDUpdateTime.Value * 24;
}
private void lLBUpdate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Uri url = new Uri("http://23.236.26.40/ds4windows/files/builds/newest.txt"); //Sorry other devs, gonna have to find your own server
// Sorry other devs, gonna have to find your own server
Uri url = new Uri("http://23.236.26.40/ds4windows/files/builds/newest.txt");
WebClient wct = new WebClient();
wct.DownloadFileAsync(url, appdatapath + "\\version.txt");
wct.DownloadFileCompleted += wct_DownloadFileCompleted;
@ -1963,7 +2011,9 @@ namespace DS4Windows
string version2 = fvi.FileVersion;
string newversion2 = File.ReadAllText(appdatapath + "\\version.txt");
if (version2.Replace(',', '.').CompareTo(File.ReadAllText(appdatapath + "\\version.txt")) == -1)//CompareVersions();
if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion2), Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
if (MessageBox.Show(Properties.Resources.DownloadVersion.Replace("*number*", newversion2),
Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
if (!File.Exists(exepath + "\\DS4Updater.exe") || (File.Exists(exepath + "\\DS4Updater.exe")
&& (FileVersionInfo.GetVersionInfo(exepath + "\\DS4Updater.exe").FileVersion.CompareTo("1.1.0.0") == -1)))
@ -1978,17 +2028,21 @@ namespace DS4Windows
Process.Start("http://ds4windows.com/Files/DS4Updater.exe");
}
}
Process p = new Process();
p.StartInfo.FileName = exepath + "\\DS4Updater.exe";
if (!cBDownloadLangauge.Checked)
p.StartInfo.Arguments = "-skipLang";
if (AdminNeeded())
p.StartInfo.Verb = "runas";
try { p.Start(); Close(); }
catch { }
}
else
File.Delete(appdatapath + "\\version.txt");
}
else
{
File.Delete(appdatapath + "\\version.txt");
@ -1998,19 +2052,16 @@ namespace DS4Windows
private void linkProfiles_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(appdatapath + "\\Profiles");
Process.Start(appdatapath + "\\Profiles");
}
private void linkUninstall_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (File.Exists(appdatapath + "\\Virtual Bus Driver\\ScpDriver.exe"))
try { System.Diagnostics.Process.Start(appdatapath + "\\Virtual Bus Driver\\ScpDriver.exe"); }
catch { System.Diagnostics.Process.Start(appdatapath + "\\Virtual Bus Driver"); }
}
private void cBNotifications_CheckedChanged(object sender, EventArgs e)
{
//Notifications = cBNotifications.Checked;
try { Process.Start(appdatapath + "\\Virtual Bus Driver\\ScpDriver.exe"); }
catch { Process.Start(appdatapath + "\\Virtual Bus Driver"); }
}
}
private void cBoxNotifications_SelectedIndexChanged(object sender, EventArgs e)
@ -2056,7 +2107,7 @@ namespace DS4Windows
DS4LightBar.shuttingdown = true;
}
if (oldsize == new System.Drawing.Size(0, 0))
if (oldsize == new Size(0, 0))
{
FormWidth = this.Width;
FormHeight = this.Height;
@ -2067,7 +2118,7 @@ namespace DS4Windows
FormHeight = oldsize.Height;
}
if (!String.IsNullOrEmpty(appdatapath))
if (!string.IsNullOrEmpty(appdatapath))
{
Save();
blankControllerTab();
@ -2109,6 +2160,7 @@ namespace DS4Windows
{
//oldxiport = (int)Math.Round(nUDXIPorts.Value,0);
}
int oldxiport;
private void pnlXIPorts_MouseLeave(object sender, EventArgs e)
{
@ -2146,9 +2198,10 @@ namespace DS4Windows
{
Label lb = (Label)sender;
int i = Int32.Parse(lb.Tag.ToString());
if (Program.rootHub.DS4Controllers[i] != null && Program.rootHub.DS4Controllers[i].ConnectionType == ConnectionType.BT)
DS4Device d = Program.rootHub.DS4Controllers[i];
if (d != null && d.ConnectionType == ConnectionType.BT)
{
double latency = Program.rootHub.DS4Controllers[i].Latency;
double latency = d.Latency;
toolTip1.Hide(Pads[i]);
toolTip1.Show(Properties.Resources.InputDelay.Replace("*number*", latency.ToString()), lb, lb.Size.Width, 0);
}

File diff suppressed because it is too large Load Diff