private void OnCloseAction(CancelEventArgs e) { // Disable force feedback effect before closing application. if (UpdateTimer != null) { UpdateTimer.Stop(); } lock (Controller.XInputLock) { for (var i = 0; i < 4; i++) { //if (PadControls[i].LeftMotorTestTrackBar.Value > 0 || PadControls[i].RightMotorTestTrackBar.Value > 0) //{ var gamePad = Global.DHelper.LiveXiControllers[i]; var isConected = Global.DHelper.LiveXiConnected[i]; if (Controller.IsLoaded && isConected) { // Stop vibration. gamePad.SetVibration(new Vibration()); } //} } //BeginInvoke((Action)delegate() //{ // XInput.FreeLibrary(); //}); } // Logical delay without blocking the current thread. System.Threading.Tasks.Task.Delay(100).Wait(); SettingsManager.SaveAll(); AppHelper.UnInitializeHidGuardian(); }
private void OnCloseAction(CancelEventArgs e) { // Disable force feedback effect before closing application. if (UpdateTimer != null) { UpdateTimer.Stop(); } lock (Controller.XInputLock) { for (var i = 0; i < 4; i++) { //if (PadControls[i].LeftMotorTestTrackBar.Value > 0 || PadControls[i].RightMotorTestTrackBar.Value > 0) //{ var gamePad = Global.DHelper.LiveXiControllers[i]; var isConected = Global.DHelper.LiveXiConnected[i]; if (Controller.IsLoaded && isConected) { // Stop vibration. gamePad.SetVibration(new Vibration()); } //} } //BeginInvoke((Action)delegate() //{ // XInput.FreeLibrary(); //}); } // Logical delay without blocking the current thread. System.Threading.Tasks.Task.Delay(100).Wait(); var tmp = new FileInfo(SettingsManager.TmpFileName); var ini = new FileInfo(SettingsManager.IniFileName); if (tmp.Exists && ini.Exists) { // Before renaming file check for changes. var changed = false; if (tmp.Length != ini.Length) { changed = true; } else { var tmpChecksum = EngineHelper.GetFileChecksum(tmp.FullName); var iniChecksum = EngineHelper.GetFileChecksum(ini.FullName); changed = !tmpChecksum.Equals(iniChecksum); } if (changed) { var form = new MessageBoxWindow(); var result = form.ShowDialog( "Do you want to save changes you made to configuration?", "Save Changes?", System.Windows.MessageBoxButton.YesNoCancel, System.Windows.MessageBoxImage.Exclamation, System.Windows.MessageBoxResult.Yes); if (result == System.Windows.MessageBoxResult.Yes) { // Do nothing since INI contains latest updates. } else if (result == System.Windows.MessageBoxResult.No) { // Rename temp to INI. tmp.CopyTo(SettingsManager.IniFileName, true); } else if (result == System.Windows.MessageBoxResult.Cancel) { e.Cancel = true; return; } } // delete temp. tmp.Delete(); } SettingsManager.SaveAll(); AppHelper.UnInitializeHidGuardian(); }