2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using System . Windows ;
5
- using System . Windows . Forms ;
5
+ using System . Windows . Controls ;
6
+ using static FSClient . Broker ;
6
7
using WF = System . Windows . Forms ;
7
8
8
9
namespace FSClient {
@@ -78,19 +79,11 @@ private void load_devices(bool from_settings) {
78
79
txtRecordingPath . Text = broker . recordings_folder ;
79
80
chkDirectSip . IsChecked = broker . DirectSipDial ;
80
81
chkAlwaysOnTopDuringCall . IsChecked = broker . AlwaysOnTopDuringCall ;
81
- chkGlobalAlt . IsChecked = broker . global_hotkey . modifiers . HasFlag ( UnManaged . KeyModifier . Alt ) ;
82
- chkGlobalShift . IsChecked = broker . global_hotkey . modifiers . HasFlag ( UnManaged . KeyModifier . Shift ) ;
83
- chkGlobalCntrl . IsChecked = broker . global_hotkey . modifiers . HasFlag ( UnManaged . KeyModifier . Ctrl ) ;
84
- chkGlobalWin . IsChecked = broker . global_hotkey . modifiers . HasFlag ( UnManaged . KeyModifier . Win ) ;
85
- var key_char = broker . global_hotkey . key . ToString ( ) ;
86
- if ( broker . global_hotkey . key == System . Windows . Input . Key . None )
87
- key_char = "" ;
88
- key_char = key_char . Replace ( "NumPad" , "" ) . Replace ( "Oem" , "" ) ;
89
- if ( key_char . Length == 2 )
90
- key_char = key_char . Replace ( "D" , "" ) ;
91
- if ( key_char . Length > 1 )
92
- key_char = "" ;
93
- txtHotKey . Text = key_char ;
82
+ SetHotKeyFormFromSetting ( GLOBAL_HOT_KEY_TYPE . Focus , chkGlobalAlt , chkGlobalCntrl , chkGlobalShift , chkGlobalWin , txtHotKey ) ;
83
+ SetHotKeyFormFromSetting ( GLOBAL_HOT_KEY_TYPE . End , chkGlobalEndAlt , chkGlobalEndCntrl , chkGlobalEndShift , chkGlobalEndWin , txtHotKeyEnd ) ;
84
+ SetHotKeyFormFromSetting ( GLOBAL_HOT_KEY_TYPE . Answer , chkGlobalAnsAlt , chkGlobalAnsCntrl , chkGlobalAnsShift , chkGlobalAnsWin , txtHotKeyAns ) ;
85
+ SetHotKeyFormFromSetting ( GLOBAL_HOT_KEY_TYPE . Mute , chkGlobalMuteAlt , chkGlobalMuteCntrl , chkGlobalMuteShift , chkGlobalMuteWin , txtHotKeyMute ) ;
86
+
94
87
comboGUIStartup . SelectedItem = ( from g in GuiOptions where g . key == broker . GUIStartup select g ) . FirstOrDefault ( ) ;
95
88
if ( comboGUIStartup . SelectedIndex == - 1 )
96
89
comboGUIStartup . SelectedIndex = 0 ;
@@ -102,6 +95,22 @@ private void load_devices(bool from_settings) {
102
95
comboHeadsetDevice . SelectedIndex = 0 ;
103
96
}
104
97
}
98
+ private void SetHotKeyFormFromSetting ( GLOBAL_HOT_KEY_TYPE type , CheckBox alt_box , CheckBox cntrl_box , CheckBox shift_box , CheckBox win_box , TextBox txt_box ) {
99
+ var setting = broker . GetHotKeySetting ( type ) ;
100
+ alt_box . IsChecked = setting . modifiers . HasFlag ( UnManaged . KeyModifier . Alt ) ;
101
+ shift_box . IsChecked = setting . modifiers . HasFlag ( UnManaged . KeyModifier . Shift ) ;
102
+ cntrl_box . IsChecked = setting . modifiers . HasFlag ( UnManaged . KeyModifier . Ctrl ) ;
103
+ win_box . IsChecked = setting . modifiers . HasFlag ( UnManaged . KeyModifier . Win ) ;
104
+ var key_char = setting . key . ToString ( ) ;
105
+ if ( setting . key == System . Windows . Input . Key . None )
106
+ key_char = "" ;
107
+ key_char = key_char . Replace ( "NumPad" , "" ) . Replace ( "Oem" , "" ) ;
108
+ if ( key_char . Length == 2 )
109
+ key_char = key_char . Replace ( "D" , "" ) ;
110
+ if ( key_char . Length > 1 )
111
+ key_char = "" ;
112
+ txt_box . Text = key_char ;
113
+ }
105
114
private void SaveSettings ( ) {
106
115
PortAudio . AudioDevice indev = comboHeadsetInput . SelectedItem as PortAudio . AudioDevice ;
107
116
PortAudio . AudioDevice outdev = comboHeadsetOutput . SelectedItem as PortAudio . AudioDevice ;
@@ -129,26 +138,33 @@ private void SaveSettings() {
129
138
broker . CheckForUpdates = chkUpdatesOnStart . IsChecked == true ? "OnStart" : "Never" ;
130
139
broker . GUIStartup = ( comboGUIStartup . SelectedItem as ComboOption ) . key ;
131
140
broker . theme = ( comboTheme . SelectedItem as ComboOption ) . key ;
132
- System . Windows . Input . Key hot_key = System . Windows . Input . Key . None ;
141
+ SetHotKeyFromWindow ( GLOBAL_HOT_KEY_TYPE . Focus , chkGlobalAlt , chkGlobalCntrl , chkGlobalShift , chkGlobalWin , txtHotKey ) ;
142
+ SetHotKeyFromWindow ( GLOBAL_HOT_KEY_TYPE . End , chkGlobalEndAlt , chkGlobalEndCntrl , chkGlobalEndShift , chkGlobalEndWin , txtHotKeyEnd ) ;
143
+ SetHotKeyFromWindow ( GLOBAL_HOT_KEY_TYPE . Answer , chkGlobalAnsAlt , chkGlobalAnsCntrl , chkGlobalAnsShift , chkGlobalAnsWin , txtHotKeyAns ) ;
144
+ SetHotKeyFromWindow ( GLOBAL_HOT_KEY_TYPE . Mute , chkGlobalMuteAlt , chkGlobalMuteCntrl , chkGlobalMuteShift , chkGlobalMuteWin , txtHotKeyMute ) ;
145
+
146
+ broker . SetActiveHeadset ( comboHeadsetDevice . SelectedItem as string ) ;
147
+ broker . SaveSettings ( ) ;
148
+
149
+ }
150
+ private void SetHotKeyFromWindow ( GLOBAL_HOT_KEY_TYPE type , CheckBox alt_box , CheckBox cntrl_box , CheckBox shift_box , CheckBox win_box , TextBox txt_box ) {
151
+ System . Windows . Input . Key hot_key = System . Windows . Input . Key . None ;
133
152
var hot_key_modifier = UnManaged . KeyModifier . None ;
134
- if ( chkGlobalAlt . IsChecked == true )
153
+ if ( alt_box . IsChecked == true )
135
154
hot_key_modifier |= UnManaged . KeyModifier . Alt ;
136
- if ( chkGlobalCntrl . IsChecked == true )
155
+ if ( cntrl_box . IsChecked == true )
137
156
hot_key_modifier |= UnManaged . KeyModifier . Ctrl ;
138
- if ( chkGlobalShift . IsChecked == true )
157
+ if ( shift_box . IsChecked == true )
139
158
hot_key_modifier |= UnManaged . KeyModifier . Shift ;
140
- if ( chkGlobalWin . IsChecked == true )
159
+ if ( win_box . IsChecked == true )
141
160
hot_key_modifier |= UnManaged . KeyModifier . Win ;
142
- if ( ! String . IsNullOrWhiteSpace ( txtHotKey . Text ) ) {
143
- var key = txtHotKey . Text . ToUpper ( ) ;
161
+ if ( ! String . IsNullOrWhiteSpace ( txt_box . Text ) ) {
162
+ var key = txt_box . Text . ToUpper ( ) ;
144
163
if ( key [ 0 ] >= 0 && key [ 0 ] <= 9 )
145
164
key = "D" + key ;
146
- Enum . TryParse < System . Windows . Input . Key > ( key , out hot_key ) ;
165
+ Enum . TryParse < System . Windows . Input . Key > ( key , out hot_key ) ;
147
166
}
148
- broker . SetHotKey ( new Broker . HotKeySetting { modifiers = hot_key_modifier , key = hot_key } ) ;
149
- broker . SetActiveHeadset ( comboHeadsetDevice . SelectedItem as string ) ;
150
- broker . SaveSettings ( ) ;
151
-
167
+ broker . SetHotKey ( type , new Broker . HotKeySetting { modifiers = hot_key_modifier , key = hot_key } ) ;
152
168
}
153
169
private void Window_Closing ( object sender , System . ComponentModel . CancelEventArgs e ) {
154
170
@@ -187,7 +203,7 @@ private void btnPluginSettings_Click(object sender, RoutedEventArgs e){
187
203
private void btnPathBrowse_Click ( object sender , RoutedEventArgs e ) {
188
204
WF . FolderBrowserDialog dlg = new WF . FolderBrowserDialog ( ) ;
189
205
dlg . SelectedPath = txtRecordingPath . Text ;
190
- DialogResult res = dlg . ShowDialog ( ) ;
206
+ WF . DialogResult res = dlg . ShowDialog ( ) ;
191
207
if ( res != System . Windows . Forms . DialogResult . OK )
192
208
return ;
193
209
txtRecordingPath . Text = dlg . SelectedPath ;
0 commit comments