public void CSGOWasRunning() { lock (LockObject) { isActive = false; //disable DispatcherTimer refreshDispatcherTimer.Stop(); #region AquireData //Extract Data from the UI Thread bool isAudioEnabled = false; bool isVibranceEnabled = false; int inGameVibranceLevel = 0; int windowsVibranceLevel = 0; Dispatcher.Invoke(new Action(() => { isAudioEnabled = UseAudioSettingsCheckBox.IsChecked == true; isVibranceEnabled = UseVibranceSettingsCheckBox.IsChecked == true; inGameVibranceLevel = (int)InGameVibranceLevelSlider.Value; windowsVibranceLevel = (int)WindowsVibranceLevelSlider.Value; })); #endregion #region Audio if (isAudioEnabled) { Dispatcher.Invoke(new Action(() => { if (WindowsAudioDeviceComboBox.SelectedItem != null) { int audioDevice = ((AudioDevice)WindowsAudioDeviceComboBox.SelectedItem).DeviceID; AudioDeviceController.SetAudioDevice(audioDevice); } })); } #endregion #region Vibrance //If Vibrance is enabled we want to set the Vibrance when go is running if (isVibranceEnabled && windowsVibranceLevel != inGameVibranceLevel) { if (vibranceProxy != null && vibranceProxy.VibranceInfo.isInitialized) { //vibranceProxy.VibranceInfo.displayHandles.ForEach(handle => VibranceProxy.setDVCLevel(handle, 0)); VibranceProxy.setDVCLevel(csgoHandle, getNVIDIAValue(windowsVibranceLevel)); vibranceProxy.UnloadLibraryEx(); csgoHandle = -1; stillRunning = false; } } #endregion } }
public void CSGOWasRunning() { #region AquireData //Extract Data from the UI Thread bool isAudioEnabled = false; bool extractedValues = false; Dispatcher.BeginInvoke(new Action(() => { isAudioEnabled = UseAudioSettingsCheckBox.IsChecked == true; extractedValues = true; })); while (!extractedValues) { Thread.Sleep(100); } #endregion if (isAudioEnabled) { Dispatcher.BeginInvoke(new Action(() => { if (WindowsAudioDeviceComboBox.SelectedItem != null) { int audioDevice = ((AudioDevice)WindowsAudioDeviceComboBox.SelectedItem).DeviceID; AudioDeviceController.SetAudioDevice(audioDevice); } })); } }
public void CSGOIsRunning() { if (!stillRunning) { stillRunning = true; isActive = true; #region AquireData //Extract Data from the UI Thread bool isAudioEnabled = false; bool isVibranceEnabled = false; int refreshRate = 0; int inGameVibranceLevel = 0; int windowsVibranceLevel = 0; Dispatcher.Invoke(new Action(() => { isAudioEnabled = UseAudioSettingsCheckBox.IsChecked == true; isVibranceEnabled = UseVibranceSettingsCheckBox.IsChecked == true; inGameVibranceLevel = (int)InGameVibranceLevelSlider.Value; windowsVibranceLevel = (int)WindowsVibranceLevelSlider.Value; //Making sure the User doesn't DDOS himself if (int.TryParse(RefreshRateTextBox.Text, out refreshRate)) { refreshRate = refreshRate < 100 ? refreshRate : 100; } })); #endregion #region Audio //If Audio is enabled we want to switch the Audio Device when CSGO is running if (isAudioEnabled) { Dispatcher.Invoke(new Action(() => { if (InGameAudioDeviceComboBox.SelectedItem != null) { int audioDevice = ((AudioDevice)InGameAudioDeviceComboBox.SelectedItem).DeviceID; AudioDeviceController.SetAudioDevice(audioDevice); } })); } #endregion #region Vibrance //If Vibrance is enabled we want to set the Vibrance when go is running if (isVibranceEnabled && windowsVibranceLevel != inGameVibranceLevel) { vibranceProxy = new VibranceProxy(); if (vibranceProxy.VibranceInfo.isInitialized) { csgoHandle = vibranceProxy.GetCsgoDisplayHandle(); while (csgoHandle == -1) { csgoHandle = vibranceProxy.GetCsgoDisplayHandle(); } //vibranceProxy.VibranceInfo.defaultHandle = csgoHandle; VibranceProxy.setDVCLevel(csgoHandle, getNVIDIAValue(inGameVibranceLevel)); refreshDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, refreshRate); refreshDispatcherTimer.Start(); } } #endregion } }
public void CSGOIsRunning() { if (!stillRunning) { stillRunning = true; #region AquireData //Extract Data from the UI Thread bool isVibranceEnabled = false; bool isAudioEnabled = false; int refreshRate = 0; int inGameVibranceLevel = 0; int windowsVibranceLevel = 0; bool extractedValues = false; Dispatcher.BeginInvoke(new Action(() => { isVibranceEnabled = UseVibranceSettingsCheckBox.IsChecked == true; isAudioEnabled = UseAudioSettingsCheckBox.IsChecked == true; //Making sure the user won't accidentally DOS his own PC refreshRate = Convert.ToInt32(RefreshRateTextBox.Text); if (refreshRate < 100) { RefreshRateTextBox.Text = "100"; refreshRate = 100; } inGameVibranceLevel = (int)InGameVibranceLevelSlider.Value; windowsVibranceLevel = (int)WindowsVibranceLevelSlider.Value; extractedValues = true; })); while (!extractedValues) { Thread.Sleep(100); } #endregion #region Audio //If Audio is enabled we want to switch the Audio Device when CSGO is running if (isAudioEnabled) { Dispatcher.BeginInvoke(new Action(() => { if (InGameAudioDeviceComboBox.SelectedItem != null) { int audioDevice = ((AudioDevice)InGameAudioDeviceComboBox.SelectedItem).DeviceID; AudioDeviceController.SetAudioDevice(audioDevice); } })); } #endregion #region Vibrance //If Vibrance is enabled we want to set the Vibrance when go is running if (isVibranceEnabled && windowsVibranceLevel != inGameVibranceLevel) { ThreadStart vibranceThreadStart = () => { //This blocks the Thread until CSGO is closed/minimised //therefore we stick in in another Thread vibranceProxy = new VibranceProxy(); if (vibranceProxy.VibranceInfo.isInitialized) { vibranceProxy.SetShouldRun(true); vibranceProxy.SetKeepActive(false); vibranceProxy.SetVibranceInGameLevel(inGameVibranceLevel); vibranceProxy.SetVibranceWindowsLevel(windowsVibranceLevel); vibranceProxy.SetSleepInterval(refreshRate); vibranceProxy.HandleDvc(); vibranceProxy.UnloadLibraryEx(); stillRunning = false; } }; Thread vibranceThread = new Thread(vibranceThreadStart); vibranceThread.Start(); } #endregion } }