@@ -13,6 +13,7 @@ public partial class MainWindow : Form {
1313 private const string ControllerExePath = @"EndPointController.exe" ;
1414 private readonly List < string > _voicemeeterOutputDevices = new List < string > ( ) ;
1515 private static readonly Dictionary < int , string > OutputDevices = new Dictionary < int , string > ( ) ;
16+ private bool _ignoreUpdating = false ;
1617
1718 public MainWindow ( ) {
1819 if ( ! File . Exists ( @"settings.json" ) )
@@ -41,6 +42,12 @@ private void MainWindow_Resize(object sender, EventArgs e) {
4142 }
4243
4344 private void UpdateOptions ( object sender , EventArgs e ) {
45+ if ( _ignoreUpdating ) return ;
46+ if ( _settings . Interval != decimal . ToInt32 ( intervalField . Value ) ) {
47+ _settings . Interval = decimal . ToInt32 ( intervalField . Value ) ;
48+ CheckVoicemeeterProcessRunning ( _settings , defaultNonVoicemeeterOutputDevice , defaultVoicemeeterOutputDevice ) ;
49+ }
50+
4451 _settings . VoicemeeterVersion =
4552 voicemeeterVersionComboBox . Items [ voicemeeterVersionComboBox . SelectedIndex ] . ToString ( ) ;
4653 if ( defaultVoicemeeterOutputDevice . SelectedIndex != - 1 ) _settings . DefaultVoicemeeterOutputDevice = defaultVoicemeeterOutputDevice . Items [ defaultVoicemeeterOutputDevice . SelectedIndex ] . ToString ( ) ;
@@ -50,23 +57,26 @@ private void UpdateOptions(object sender, EventArgs e) {
5057 }
5158
5259 private void MainWindow_Load ( object sender , EventArgs e ) {
60+ intervalField . Maximum = int . MaxValue ;
5361 minimizeMessage . Checked = ! _settings . NotShowMinimizeMessage ;
62+
63+ _ignoreUpdating = true ;
64+ intervalField . Value = _settings . Interval ;
65+ _ignoreUpdating = false ;
66+
5467 voicemeeterVersionComboBox . SelectedIndex =
5568 voicemeeterVersionComboBox . FindStringExact ( _settings . VoicemeeterVersion ) ;
56-
69+
5770 UpdateNonVoiceMeeterOutputDevice_Click ( sender , e ) ;
71+
5872 UpdateVoicemeeterVersionDeviceInputs ( ) ;
5973 defaultVoicemeeterOutputDevice . SelectedIndex =
6074 defaultVoicemeeterOutputDevice . FindStringExact ( _settings . DefaultVoicemeeterOutputDevice ) ;
6175 defaultNonVoicemeeterOutputDevice . SelectedIndex =
6276 defaultNonVoicemeeterOutputDevice . FindStringExact ( _settings . DefaultNonVoicemeeterOutputDevice ) ;
6377
64- var processlist = Process . GetProcesses ( ) ;
65- Process voicemeeterProcess = null ;
66- foreach ( var process in processlist )
67- if ( process . ProcessName . ToLower ( ) . StartsWith ( @"voicemeeter" ) )
68- voicemeeterProcess = process ;
69- CheckVoicemeeterProcessRunning ( 100 , voicemeeterProcess , defaultNonVoicemeeterOutputDevice , defaultVoicemeeterOutputDevice ) ;
78+
79+ CheckVoicemeeterProcessRunning ( _settings , defaultNonVoicemeeterOutputDevice , defaultVoicemeeterOutputDevice ) ;
7080 }
7181
7282 private void VoicemeeterVersionComboBox_SelectedIndexChanged ( object sender , EventArgs e ) {
@@ -135,7 +145,13 @@ private void UpdateNonVoiceMeeterOutputDevice_Click(object sender, EventArgs e)
135145 }
136146 }
137147
138- private static async void CheckVoicemeeterProcessRunning ( int interval , Process voicemeeterProcess , ComboBox nonVoicemeeterOutputDevice , ComboBox defaultVoiceMeeterOutputDevice ) {
148+ private static async void CheckVoicemeeterProcessRunning ( Settings settings , ComboBox nonVoicemeeterOutputDevice , ComboBox defaultVoiceMeeterOutputDevice ) {
149+ var processlist = Process . GetProcesses ( ) ;
150+ Process voicemeeterProcess = null ;
151+ foreach ( var process in processlist )
152+ if ( process . ProcessName . ToLower ( ) . StartsWith ( @"voicemeeter" ) )
153+ voicemeeterProcess = process ;
154+
139155 var lastState = voicemeeterProcess == null ? 0 : Process . GetProcessesByName ( voicemeeterProcess . ProcessName ) . Length ;
140156 while ( true ) {
141157 var newState = voicemeeterProcess == null ? 0 : Process . GetProcessesByName ( voicemeeterProcess . ProcessName ) . Length ;
@@ -147,7 +163,7 @@ private static async void CheckVoicemeeterProcessRunning(int interval, Process v
147163 }
148164
149165 lastState = newState ;
150- await Task . Delay ( interval ) ;
166+ await Task . Delay ( settings . Interval ) ;
151167 }
152168 }
153169
@@ -202,5 +218,9 @@ private void RestoreWindow() {
202218 Show ( ) ;
203219 WindowState = FormWindowState . Normal ;
204220 }
221+
222+ private void NotifyMenuQuit_Click ( object sender , EventArgs e ) {
223+ Application . Exit ( ) ;
224+ }
205225 }
206226}
0 commit comments