diff --git a/DS4Tool/Properties/AssemblyInfo.cs b/DS4Tool/Properties/AssemblyInfo.cs index 542d75a..1fc7b4e 100644 --- a/DS4Tool/Properties/AssemblyInfo.cs +++ b/DS4Tool/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.0.87")] -[assembly: AssemblyFileVersion("1.4.0.87")] +[assembly: AssemblyVersion("1.4.0.871")] +[assembly: AssemblyFileVersion("1.4.0.871")] diff --git a/DS4Tool/ScpForm.cs b/DS4Tool/ScpForm.cs index c7fa048..9abaca9 100644 --- a/DS4Tool/ScpForm.cs +++ b/DS4Tool/ScpForm.cs @@ -81,7 +81,7 @@ namespace ScpServer [DllImport("psapi.dll")] private static extern uint GetModuleFileNameEx(IntPtr hWnd, IntPtr hModule, StringBuilder lpFileName, int nSize); - public ScpForm(string [] args) + public ScpForm(string[] args) { InitializeComponent(); arguements = args; @@ -92,146 +92,153 @@ namespace ScpServer if (File.Exists(appdatapath + "\\Profiles.xml")) tt.SetToolTip(linkUninstall, Properties.Resources.IfRemovingDS4Windows); tt.SetToolTip(cBSwipeProfiles, Properties.Resources.TwoFingerSwipe); + bool firstrun = false; + if (File.Exists(exepath + "\\Auto Profiles.xml") + && File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool\\Auto Profiles.xml")) + { + firstrun = true; + new SaveWhere(true).ShowDialog(); + } + else if (File.Exists(exepath + "\\Auto Profiles.xml")) + Global.SaveWhere(exepath); + else if (File.Exists(appdatapath + "\\Auto Profiles.xml")) + Global.SaveWhere(appdatapath); + else if (!File.Exists(exepath + "\\Auto Profiles.xml") + && !File.Exists(appdatapath + "\\Auto Profiles.xml")) + { + firstrun = true; + new SaveWhere(false).ShowDialog(); + } + if (firstrun) + CheckDrivers(); + else { - if (File.Exists(exepath + "\\Auto Profiles.xml") - && File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool\\Auto Profiles.xml")) - new SaveWhere(true).ShowDialog(); - else if (File.Exists(exepath + "\\Auto Profiles.xml")) - Global.SaveWhere(exepath); - else if (File.Exists(appdatapath + "\\Auto Profiles.xml")) - Global.SaveWhere(appdatapath); - else if (!File.Exists(exepath + "\\Auto Profiles.xml") - && !File.Exists(appdatapath + "\\Auto Profiles.xml")) - { - new SaveWhere(false).ShowDialog(); - } - var AppCollectionThread = new System.Threading.Thread(() => CheckDrivers()); AppCollectionThread.IsBackground = true; AppCollectionThread.Start(); + } - if (String.IsNullOrEmpty(Global.appdatapath)) + if (String.IsNullOrEmpty(Global.appdatapath)) + { + Close(); + return; + } + Graphics g = this.CreateGraphics(); + try + { + dpix = g.DpiX; + dpiy = g.DpiY; + } + finally + { + g.Dispose(); + } + Icon = Properties.Resources.DS4; + notifyIcon1.Icon = Properties.Resources.DS4; + rootHub = new DS4Control.Control(); + rootHub.Debug += On_Debug; + Log.GuiLog += On_Debug; + Log.TrayIconLog += ShowNotification; + // tmrUpdate.Enabled = true; TODO remove tmrUpdate and leave tick() + + Directory.CreateDirectory(Global.appdatapath); + Global.Load(); + if (!Global.Save()) //if can't write to file + if (MessageBox.Show("Cannot write at current locataion\nCopy Settings to appdata?", "DS4Windows", + MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes) { + try + { + Directory.CreateDirectory(appdatapath); + File.Copy(exepath + "\\Profiles.xml", appdatapath + "\\Profiles.xml"); + File.Copy(exepath + "\\Auto Profiles.xml", appdatapath + "\\Auto Profiles.xml"); + Directory.CreateDirectory(appdatapath + "\\Profiles"); + foreach (string s in Directory.GetFiles(exepath + "\\Profiles")) + { + File.Copy(s, appdatapath + "\\Profiles\\" + Path.GetFileName(s)); + } + } + catch { } + MessageBox.Show("Copy complete, please relaunch DS4Windows and remove settings from Program Directory", "DS4Windows"); + Global.appdatapath = null; Close(); return; } - Graphics g = this.CreateGraphics(); - try - { - dpix = g.DpiX; - dpiy = g.DpiY; - } - finally - { - g.Dispose(); - } - Icon = Properties.Resources.DS4; - notifyIcon1.Icon = Properties.Resources.DS4; - rootHub = new DS4Control.Control(); - rootHub.Debug += On_Debug; - Log.GuiLog += On_Debug; - Log.TrayIconLog += ShowNotification; - // tmrUpdate.Enabled = true; TODO remove tmrUpdate and leave tick() - - Directory.CreateDirectory(Global.appdatapath); - Global.Load(); - if (!Global.Save()) //if can't write to file - if (MessageBox.Show("Cannot write at current locataion\nCopy Settings to appdata?", "DS4Windows", - MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes) - { - try - { - Directory.CreateDirectory(appdatapath); - File.Copy(exepath + "\\Profiles.xml", appdatapath + "\\Profiles.xml"); - File.Copy(exepath + "\\Auto Profiles.xml", appdatapath + "\\Auto Profiles.xml"); - Directory.CreateDirectory(appdatapath + "\\Profiles"); - foreach (string s in Directory.GetFiles(exepath + "\\Profiles")) - { - File.Copy(s, appdatapath + "\\Profiles\\" + Path.GetFileName(s)); - } - } - catch { } - MessageBox.Show("Copy complete, please relaunch DS4Windows and remove settings from Program Directory", "DS4Windows"); - Global.appdatapath = null; - Close(); - return; - } - else - { - MessageBox.Show("DS4Windows cannot edit settings here, This will now close", "DS4Windows"); - Global.appdatapath = null; - Close(); - return; - } - foreach (ToolStripMenuItem t in shortcuts) - t.DropDownItemClicked += Profile_Changed_Menu; - hideDS4CheckBox.CheckedChanged -= hideDS4CheckBox_CheckedChanged; - hideDS4CheckBox.Checked = Global.getUseExclusiveMode(); - hideDS4CheckBox.CheckedChanged += hideDS4CheckBox_CheckedChanged; - cBDisconnectBT.Checked = Global.getDCBTatStop(); - // New settings - this.Width = Global.getFormWidth(); - this.Height = Global.getFormHeight(); - startMinimizedCheckBox.CheckedChanged -= startMinimizedCheckBox_CheckedChanged; - startMinimizedCheckBox.Checked = Global.getStartMinimized(); - startMinimizedCheckBox.CheckedChanged += startMinimizedCheckBox_CheckedChanged; - if (startMinimizedCheckBox.Checked) - this.WindowState = FormWindowState.Minimized; - Form_Resize(null, null); - RefreshProfiles(); - for (int i = 0; i < 4; i++) - { - Global.LoadProfile(i, true, rootHub); - } - LoadP(); - Global.ControllerStatusChange += ControllerStatusChange; - bool start = true; - foreach (string s in arguements) - if (s == "stop") - { - start = false; - break; - } - if (btnStartStop.Enabled && start) - btnStartStop_Clicked(); - startToolStripMenuItem.Text = btnStartStop.Text; - cBNotifications.Checked = Global.getNotifications(); - cBSwipeProfiles.Checked = Global.getSwipeProfiles(); - int checkwhen = Global.getCheckWhen(); - cBUpdate.Checked = checkwhen > 0; - if (checkwhen > 23) - { - cBUpdateTime.SelectedIndex = 1; - nUDUpdateTime.Value = checkwhen / 24; - } else { - cBUpdateTime.SelectedIndex = 0; - nUDUpdateTime.Value = checkwhen; + MessageBox.Show("DS4Windows cannot edit settings here, This will now close", "DS4Windows"); + Global.appdatapath = null; + Close(); + return; } - Uri url = new Uri("http://ds4windows.com/Files/Builds/newest.txt"); //Sorry other devs, gonna have to find your own server - - - if (checkwhen > 0 && DateTime.Now >= Global.getLastChecked() + TimeSpan.FromHours(checkwhen)) - { - wc.DownloadFileAsync(url, Global.appdatapath + "\\version.txt"); - wc.DownloadFileCompleted += Check_Version; - Global.setLastChecked(DateTime.Now); - } - - if (File.Exists(exepath + "\\Updater.exe")) - { - System.Threading.Thread.Sleep(2000); - File.Delete(exepath + "\\Updater.exe"); - } - //test.Start(); - hotkeystimer.Start(); - hotkeystimer.Tick += Hotkeys; - test.Tick += test_Tick; - if (!System.IO.Directory.Exists(Global.appdatapath + "\\Virtual Bus Driver")) - linkUninstall.Visible = false; - StartWindowsCheckBox.Checked = File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\DS4Windows.lnk"); + foreach (ToolStripMenuItem t in shortcuts) + t.DropDownItemClicked += Profile_Changed_Menu; + hideDS4CheckBox.CheckedChanged -= hideDS4CheckBox_CheckedChanged; + hideDS4CheckBox.Checked = Global.getUseExclusiveMode(); + hideDS4CheckBox.CheckedChanged += hideDS4CheckBox_CheckedChanged; + cBDisconnectBT.Checked = Global.getDCBTatStop(); + // New settings + this.Width = Global.getFormWidth(); + this.Height = Global.getFormHeight(); + startMinimizedCheckBox.CheckedChanged -= startMinimizedCheckBox_CheckedChanged; + startMinimizedCheckBox.Checked = Global.getStartMinimized(); + startMinimizedCheckBox.CheckedChanged += startMinimizedCheckBox_CheckedChanged; + if (startMinimizedCheckBox.Checked) + this.WindowState = FormWindowState.Minimized; + Form_Resize(null, null); + RefreshProfiles(); + for (int i = 0; i < 4; i++) + { + Global.LoadProfile(i, true, rootHub); } + LoadP(); + Global.ControllerStatusChange += ControllerStatusChange; + bool start = true; + foreach (string s in arguements) + if (s == "stop") + { + start = false; + break; + } + if (btnStartStop.Enabled && start) + btnStartStop_Clicked(); + startToolStripMenuItem.Text = btnStartStop.Text; + cBNotifications.Checked = Global.getNotifications(); + cBSwipeProfiles.Checked = Global.getSwipeProfiles(); + int checkwhen = Global.getCheckWhen(); + cBUpdate.Checked = checkwhen > 0; + if (checkwhen > 23) + { + cBUpdateTime.SelectedIndex = 1; + nUDUpdateTime.Value = checkwhen / 24; + } + else + { + cBUpdateTime.SelectedIndex = 0; + nUDUpdateTime.Value = checkwhen; + } + Uri url = new Uri("http://ds4windows.com/Files/Builds/newest.txt"); //Sorry other devs, gonna have to find your own server + + + if (checkwhen > 0 && DateTime.Now >= Global.getLastChecked() + TimeSpan.FromHours(checkwhen)) + { + wc.DownloadFileAsync(url, Global.appdatapath + "\\version.txt"); + wc.DownloadFileCompleted += Check_Version; + Global.setLastChecked(DateTime.Now); + } + + if (File.Exists(exepath + "\\Updater.exe")) + { + System.Threading.Thread.Sleep(2000); + File.Delete(exepath + "\\Updater.exe"); + } + //test.Start(); + hotkeystimer.Start(); + hotkeystimer.Tick += Hotkeys; + test.Tick += test_Tick; + if (!System.IO.Directory.Exists(Global.appdatapath + "\\Virtual Bus Driver")) + linkUninstall.Visible = false; + StartWindowsCheckBox.Checked = File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\DS4Windows.lnk"); } public static string GetTopWindowName() @@ -375,9 +382,10 @@ namespace ScpServer if (!deriverinstalled) { + //Console.WriteLine("yo"); WelcomeDialog wd = new WelcomeDialog(); wd.ShowDialog(); - wd.FormClosing += delegate { btnStartStop_Click(null, null); btnStartStop_Click(null, null); }; + wd.FormClosed += delegate { btnStartStop_Clicked(false); btnStartStop_Clicked(false); }; } } catch