@@ -128,17 +128,8 @@ private void Form1_Load(object sender, EventArgs e)
128
128
checkBox1 . Checked = Configuration1 . ExitAfterStartup ;
129
129
130
130
//Update Display favourites
131
- foreach ( var variable in Favourites1 . Patches )
132
- {
133
- var index = listBox1 . FindStringExact ( variable ) ;
134
- listBox1 . Items [ index ] += " ★" ;
135
- }
136
-
137
- foreach ( var variable in Favourites1 . Games )
138
- {
139
- var index = listBox2 . FindStringExact ( variable ) ;
140
- listBox2 . Items [ index ] += " ★" ;
141
- }
131
+ AddStars ( listBox1 , Favourites1 . Patches ) ;
132
+ AddStars ( listBox2 , Favourites1 . Games ) ;
142
133
143
134
#endregion
144
135
@@ -165,8 +156,15 @@ private void Form1_Load(object sender, EventArgs e)
165
156
if ( Configuration1 . IsDescending [ i ] == "false" )
166
157
{
167
158
if ( i == 0 )
159
+ {
168
160
SortListBoxItems ( ref listBox1 ) ;
169
- else SortListBoxItems ( ref listBox2 ) ;
161
+ sort_az_button1 . BackgroundImage = _sortDescending ;
162
+ }
163
+ else
164
+ {
165
+ SortListBoxItems ( ref listBox2 ) ;
166
+ sort_az_button2 . BackgroundImage = _sortDescending ;
167
+ }
170
168
}
171
169
else if ( i == 0 )
172
170
{
@@ -182,6 +180,7 @@ private void Form1_Load(object sender, EventArgs e)
182
180
//Default favourite button state
183
181
for ( var i = 0 ; i < 2 ; i ++ )
184
182
if ( Configuration1 . OnlyFavourites [ i ] == "true" )
183
+ {
185
184
if ( i == 0 )
186
185
{
187
186
star_button1 . BackgroundImage = _starHollow ;
@@ -202,6 +201,12 @@ private void Form1_Load(object sender, EventArgs e)
202
201
listBox2 . Items . RemoveAt ( n ) ;
203
202
}
204
203
}
204
+ }
205
+ else
206
+ {
207
+ if ( i == 0 ) star_button1 . BackgroundImage = _star ;
208
+ else star_button2 . BackgroundImage = _star ;
209
+ }
205
210
206
211
//Default exe type button state
207
212
filterByType_button . BackgroundImage = _gameAndCustom ;
@@ -329,7 +334,7 @@ private void StartThcrap()
329
334
/// <summary>
330
335
/// Handles starting thcrap with enter and favouring when pressing f
331
336
/// </summary>
332
- private new void KeyPress ( object sender , KeyPressEventArgs e )
337
+ private void KeyPress ( object sender , KeyPressEventArgs e )
333
338
{
334
339
switch ( e . KeyChar )
335
340
{
@@ -435,14 +440,23 @@ private void sort_az_button2_Click(object sender, EventArgs e)
435
440
ReadConfig ( ) ;
436
441
}
437
442
443
+ private static void AddStars ( ListBox listBox , IEnumerable < string > list )
444
+ {
445
+ foreach ( var variable in list )
446
+ {
447
+ var index = listBox . FindStringExact ( variable ) ;
448
+ if ( index != - 1 ) listBox . Items [ index ] += " ★" ;
449
+ }
450
+ }
451
+
438
452
private void star_button1_Click ( object sender , EventArgs e )
439
453
{
440
454
if ( ! star_button1 . BackgroundImage . Equals ( _starHollow ) )
441
455
{
442
456
star_button1 . BackgroundImage = _starHollow ;
443
457
for ( var n = listBox1 . Items . Count - 1 ; n >= 0 ; -- n )
444
458
{
445
- var filterItem = "★" ;
459
+ const char filterItem = '★' ;
446
460
if ( ! listBox1 . Items [ n ] . ToString ( ) . Contains ( filterItem ) )
447
461
listBox1 . Items . RemoveAt ( n ) ;
448
462
}
@@ -455,11 +469,7 @@ private void star_button1_Click(object sender, EventArgs e)
455
469
listBox1 . Items . Clear ( ) ;
456
470
foreach ( var s in _jsFiles ) listBox1 . Items . Add ( s ) ;
457
471
458
- foreach ( var variable in Favourites1 . Patches )
459
- {
460
- var index = listBox1 . FindStringExact ( variable ) ;
461
- listBox1 . Items [ index ] += " ★" ;
462
- }
472
+ AddStars ( listBox1 , Favourites1 . Patches ) ;
463
473
464
474
Configuration1 . OnlyFavourites [ 0 ] = "false" ;
465
475
ReadConfig ( ) ;
@@ -486,11 +496,7 @@ private void star_button2_Click(object sender, EventArgs e)
486
496
listBox2 . Items . Clear ( ) ;
487
497
foreach ( var s in _gamesList ) listBox2 . Items . Add ( s ) ;
488
498
489
- foreach ( var variable in Favourites1 . Games )
490
- {
491
- var index = listBox2 . FindStringExact ( variable ) ;
492
- listBox2 . Items [ index ] += " ★" ;
493
- }
499
+ AddStars ( listBox2 , Favourites1 . Games ) ;
494
500
495
501
Configuration1 . OnlyFavourites [ 1 ] = "false" ;
496
502
ReadConfig ( ) ;
@@ -538,6 +544,7 @@ private void filterByType_button_Click(object sender, EventArgs e)
538
544
foreach ( var item in _gamesList )
539
545
if ( ! item . Contains ( "_custom" ) )
540
546
listBox2 . Items . Add ( item ) ;
547
+ AddStars ( listBox2 , Favourites1 . Games ) ;
541
548
return ;
542
549
}
543
550
@@ -548,6 +555,7 @@ private void filterByType_button_Click(object sender, EventArgs e)
548
555
foreach ( var item in _gamesList )
549
556
if ( item . Contains ( "_custom" ) )
550
557
listBox2 . Items . Add ( item ) ;
558
+ AddStars ( listBox2 , Favourites1 . Games ) ;
551
559
return ;
552
560
}
553
561
@@ -556,6 +564,7 @@ private void filterByType_button_Click(object sender, EventArgs e)
556
564
filterByType_button . BackgroundImage = _gameAndCustom ;
557
565
listBox2 . Items . Clear ( ) ;
558
566
foreach ( var item in _gamesList ) listBox2 . Items . Add ( item ) ;
567
+ AddStars ( listBox2 , Favourites1 . Games ) ;
559
568
}
560
569
}
561
570
}
0 commit comments