diff --git a/DS4Control/ScpUtil.cs b/DS4Control/ScpUtil.cs index 1027458..4521729 100644 --- a/DS4Control/ScpUtil.cs +++ b/DS4Control/ScpUtil.cs @@ -194,6 +194,15 @@ namespace DS4Control return m_Config.version; } + public static void setLastChecked(DateTime data) + { + m_Config.lastChecked = data; + } + + public static DateTime getLastChecked() + { + return m_Config.lastChecked; + } // New settings public static void saveLowColor(int device, byte red, byte green, byte blue) { @@ -421,6 +430,7 @@ namespace DS4Control public Int32 formHeight = 550; public Boolean startMinimized = false; public double version; + public DateTime lastChecked; public Dictionary[] customMapKeyTypes = {null, null, null, null}; public Dictionary[] customMapKeys = { null, null, null, null }; public Dictionary[] customMapButtons = { null, null, null, null }; @@ -933,6 +943,8 @@ namespace DS4Control catch { missingSetting = true; } try { Item = m_Xdoc.SelectSingleNode("/Profile/DS4Version"); Double.TryParse(Item.InnerText, out version); } catch { missingSetting = true; } + try { Item = m_Xdoc.SelectSingleNode("/Profile/LastChecked"); DateTime.TryParse(Item.InnerText, out lastChecked); } + catch { missingSetting = true; } } } catch { } @@ -973,6 +985,7 @@ namespace DS4Control XmlNode xmlController4 = m_Xdoc.CreateNode(XmlNodeType.Element, "Controller4", null); xmlController4.InnerText = profilePath[3]; Node.AppendChild(xmlController4); XmlNode xmlVersion = m_Xdoc.CreateNode(XmlNodeType.Element, "DS4Version", null); xmlVersion.InnerText = version.ToString(); Node.AppendChild(xmlVersion); + XmlNode xmlLastChecked = m_Xdoc.CreateNode(XmlNodeType.Element, "LastChecked", null); xmlLastChecked.InnerText = lastChecked.ToString(); Node.AppendChild(xmlLastChecked); m_Xdoc.AppendChild(Node); m_Xdoc.Save(m_Profile); diff --git a/DS4Tool/ScpForm.Designer.cs b/DS4Tool/ScpForm.Designer.cs index 9ef303d..aa3c047 100644 --- a/DS4Tool/ScpForm.Designer.cs +++ b/DS4Tool/ScpForm.Designer.cs @@ -57,6 +57,7 @@ this.bnEditC4 = new System.Windows.Forms.Button(); this.bnEditC3 = new System.Windows.Forms.Button(); this.bnEditC2 = new System.Windows.Forms.Button(); + this.StartWindowsCheckBox = new System.Windows.Forms.CheckBox(); this.bnDeleteC4 = new System.Windows.Forms.Button(); this.bnDeleteC3 = new System.Windows.Forms.Button(); this.bnDeleteC2 = new System.Windows.Forms.Button(); @@ -258,6 +259,7 @@ this.gpPads.Controls.Add(this.bnEditC3); this.gpPads.Controls.Add(this.hideDS4CheckBox); this.gpPads.Controls.Add(this.bnEditC2); + this.gpPads.Controls.Add(this.StartWindowsCheckBox); this.gpPads.Controls.Add(this.startMinimizedCheckBox); this.gpPads.Controls.Add(this.bnDeleteC4); this.gpPads.Controls.Add(this.bnDeleteC3); @@ -395,6 +397,18 @@ this.bnEditC2.UseVisualStyleBackColor = true; this.bnEditC2.Click += new System.EventHandler(this.editButtons_Click); // + // StartWindowsCheckBox + // + this.StartWindowsCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.StartWindowsCheckBox.AutoSize = true; + this.StartWindowsCheckBox.Location = new System.Drawing.Point(452, 109); + this.StartWindowsCheckBox.Name = "StartWindowsCheckBox"; + this.StartWindowsCheckBox.Size = new System.Drawing.Size(117, 17); + this.StartWindowsCheckBox.TabIndex = 40; + this.StartWindowsCheckBox.Text = "Start with Windows"; + this.StartWindowsCheckBox.UseVisualStyleBackColor = true; + this.StartWindowsCheckBox.CheckedChanged += new System.EventHandler(this.StartWindowsCheckBox_CheckedChanged); + // // bnDeleteC4 // this.bnDeleteC4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -671,6 +685,7 @@ private System.Windows.Forms.OpenFileDialog openProfiles; private System.Windows.Forms.LinkLabel llbHelp; private System.Windows.Forms.Button btnImportProfiles; + private System.Windows.Forms.CheckBox StartWindowsCheckBox; //private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; } } diff --git a/DS4Tool/ScpForm.cs b/DS4Tool/ScpForm.cs index 5748c1f..c3865d6 100644 --- a/DS4Tool/ScpForm.cs +++ b/DS4Tool/ScpForm.cs @@ -8,13 +8,14 @@ using System.Reflection; using System.Collections.Generic; using System.Net; using System.Management; +using Microsoft.Win32; namespace ScpServer { public partial class ScpForm : Form { private DS4Control.Control rootHub; delegate void LogDebugDelegate(DateTime Time, String Data); - double version = 7.011; + double version = 7.1; protected Label[] Pads; protected ComboBox[] cbs; @@ -42,17 +43,6 @@ namespace ScpServer foreach (ToolStripMenuItem t in shortcuts) t.DropDownItemClicked += Profile_Changed_Menu; CheckDrivers(); - Uri url = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/newest%20version.txt"); //Sorry other devs, gonna have to find your own server - Directory.CreateDirectory(Global.appdatapath); - wc.DownloadFileAsync(url, Global.appdatapath + "\\version.txt"); - wc.DownloadFileCompleted += Check_Version; - - if (!File.Exists("Updater.exe")) - { - Uri url2 = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/Updater.exe"); - WebClient wc2 = new WebClient(); - wc2.DownloadFileAsync(url2, "Updater.exe"); - } } private void CheckDrivers() @@ -88,6 +78,12 @@ namespace ScpServer if (newversion > version) if (MessageBox.Show("Download now?", "New Version Available!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { + if (!File.Exists("Updater.exe")) + { + Uri url2 = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/Updater.exe"); + WebClient wc2 = new WebClient(); + wc2.DownloadFile(url2, "Updater.exe"); + } System.Diagnostics.Process.Start("Updater.exe"); this.Close(); } @@ -99,10 +95,7 @@ namespace ScpServer else File.Delete(Global.appdatapath + "\\version.txt"); } - catch - { - - } + catch { }; } protected void Form_Load(object sender, EventArgs e) @@ -128,6 +121,9 @@ namespace ScpServer startMinimizedCheckBox.Checked = Global.getStartMinimized(); startMinimizedCheckBox.CheckedChanged += startMinimizedCheckBox_CheckedChanged; + RegistryKey KeyLoc = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false); + StartWindowsCheckBox.Checked = (KeyLoc.GetValue("DS4Tool") != null); + if (startMinimizedCheckBox.Checked) { this.WindowState = FormWindowState.Minimized; @@ -135,13 +131,19 @@ namespace ScpServer } RefreshProfiles(); for (int i = 0; i < 4; i++) - { Global.LoadProfile(i); - } Global.ControllerStatusChange += ControllerStatusChange; ControllerStatusChanged(); if (btnStartStop.Enabled) btnStartStop_Clicked(); + Uri url = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/newest%20version.txt"); //Sorry other devs, gonna have to find your own server + Directory.CreateDirectory(Global.appdatapath); + if (DateTime.Now >= Global.getLastChecked() + TimeSpan.FromHours(1)) + { + wc.DownloadFileAsync(url, Global.appdatapath + "\\version.txt"); + wc.DownloadFileCompleted += Check_Version; + Global.setLastChecked(DateTime.Now); + } } public void RefreshProfiles() { @@ -253,6 +255,7 @@ namespace ScpServer protexts[i].Visible = true; else protexts[i].Visible = false; + StartWindowsCheckBox.Visible = (this.Width > 665); } protected void btnStartStop_Click(object sender, EventArgs e) @@ -574,6 +577,15 @@ namespace ScpServer } + private void StartWindowsCheckBox_CheckedChanged(object sender, EventArgs e) + { + RegistryKey KeyLoc = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); + if (StartWindowsCheckBox.Checked) + KeyLoc.SetValue("DS4Tool", "\"" + Application.ExecutablePath.ToString() + "\""); + else + KeyLoc.DeleteValue("DS4Tool", false); + } + } public class ThemeUtil diff --git a/DS4Tool/WelcomeDialog.Designer.cs b/DS4Tool/WelcomeDialog.Designer.cs index cc3b1a7..1cf6b80 100644 --- a/DS4Tool/WelcomeDialog.Designer.cs +++ b/DS4Tool/WelcomeDialog.Designer.cs @@ -138,7 +138,7 @@ this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(315, 22); this.label2.TabIndex = 3; - this.label2.Text = "You do not have to do this if you have before"; + this.label2.Text = "If you\'ve used a 360 Controller on this PC, you can skip this"; this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // WelcomeDialog diff --git a/DS4Tool/WelcomeDialog.cs b/DS4Tool/WelcomeDialog.cs index a0c0246..b27ba8f 100644 --- a/DS4Tool/WelcomeDialog.cs +++ b/DS4Tool/WelcomeDialog.cs @@ -24,12 +24,6 @@ namespace ScpServer { InitializeComponent(); this.Icon = Properties.Resources.DS4; - if (!File.Exists("Updater.exe")) - { - Uri url2 = new Uri("https://dl.dropboxusercontent.com/u/16364552/DS4Tool/Updater.exe"); - WebClient wc2 = new WebClient(); - wc2.DownloadFileAsync(url2, "Updater.exe"); - } } private void bnFinish_Click(object sender, EventArgs e)