@@ -29,7 +29,8 @@ public partial class Form1 : Form
2929 private readonly Color CLR_NORMAL = Color . DarkSeaGreen ;
3030 private readonly XMapLibWrapper mapper ;
3131 private XMapLibStickMap currentXMapLibStick = XMapLibStickMap . RIGHT ;
32- private Button ? currentSelectedPresetButton = null ;
32+ //private Button? currentSelectedPresetButton = null;
33+ private List < KeymapPreset > presets = new ( ) ;
3334 public Form1 ( )
3435 {
3536 InitializeComponent ( ) ;
@@ -47,11 +48,12 @@ public Form1()
4748 }
4849 private void InitPresetButtons ( )
4950 {
50- var but = KeymapPresetOperations . BuildPresetButtons ( ) ;
51+ presets = KeymapPresetOperations . BuildPresetButtons ( ) ;
5152 //assumes at least one preset is built
52- foreach ( KeymapPreset pr in but )
53+ foreach ( KeymapPreset pr in presets )
5354 {
5455 this . flwPresetButtons . Controls . Add ( pr . ButtonForPresetSection ) ;
56+ pr . ButtonForPresetSection . Click += ButtonForPresetSection_Click ;
5557 }
5658 if ( this . flwPresetButtons . Controls [ 0 ] is Button btn )
5759 {
@@ -151,13 +153,20 @@ static void ShowErrorMessage(string msg)
151153 ShowErrorMessage ( "e.Argument is null!" ) ;
152154 }
153155 }
154-
155156 private void trackBar1_ValueChanged ( object sender , EventArgs e )
156157 {
157158 int val = trackBar1 . Value ;
158159 mapper . SetMouseSensitivity ( val ) ;
159160 UpdateMouseSensitivityButton ( ) ;
160161 UpdateIsMouseRunning ( ) ;
161162 }
163+ private void ButtonForPresetSection_Click ( object ? sender , EventArgs e )
164+ {
165+ if ( sender is Button b )
166+ {
167+ bool unselect = KeymapPresetOperations . IsButtonTextSelected ( b ) ;
168+ KeymapPresetOperations . ChangeButtonTextForSelected ( b , ! unselect ) ;
169+ }
170+ }
162171 }
163172}
0 commit comments