@@ -16,7 +16,7 @@ public class ShortcutDialog : SmartForm
16
16
{
17
17
const string ViewConflictsKey = "?" ; // TODO: Change the type to char after #969 is merged
18
18
const string ViewCustomKey = "*" ; // TODO: Change the type to char after #969 is merged
19
-
19
+
20
20
Timer updateTimer ;
21
21
ToolStripMenuItem removeShortcut ;
22
22
ToolStripMenuItem revertToDefault ;
@@ -203,7 +203,7 @@ private void InitializeComponent()
203
203
this . ResumeLayout ( false ) ;
204
204
this . PerformLayout ( ) ;
205
205
}
206
-
206
+
207
207
#endregion
208
208
209
209
#region Methods And Event Handlers
@@ -262,7 +262,7 @@ void ApplyScaling()
262
262
this . idHeader . Width = ScaleHelper . Scale ( this . idHeader . Width ) ;
263
263
this . keyHeader . Width = ScaleHelper . Scale ( this . keyHeader . Width ) ;
264
264
}
265
-
265
+
266
266
/// <summary>
267
267
/// Updates the font highlight of the item.
268
268
/// </summary>
@@ -331,7 +331,7 @@ void PopulateListView(string filter)
331
331
{
332
332
var item = this . shortcutListItems [ i ] ;
333
333
if ( string . IsNullOrEmpty ( filter ) ||
334
- item . Id . IndexOf ( filter , StringComparison . OrdinalIgnoreCase ) >= 0 ||
334
+ item . Id . IndexOf ( filter , StringComparison . OrdinalIgnoreCase ) >= 0 ||
335
335
item . KeysString . IndexOf ( filter , StringComparison . OrdinalIgnoreCase ) >= 0 )
336
336
{
337
337
if ( viewCustom && ! item . IsModified ) continue ;
@@ -413,10 +413,11 @@ void AssignNewShortcut(ShortcutListItem item, Keys shortcut)
413
413
else if ( ! ToolStripManager . IsValidShortcut ( shortcut ) ) return ;
414
414
415
415
if ( item . Custom == shortcut ) return ;
416
+ this . listView . BeginUpdate ( ) ;
416
417
item . Custom = shortcut ;
417
418
item . Selected = true ;
418
- ResetConflicts ( item ) ;
419
419
this . GetConflictItems ( item ) ;
420
+ this . listView . EndUpdate ( ) ;
420
421
if ( item . HasConflicts )
421
422
{
422
423
ErrorManager . ShowWarning ( TextHelper . GetString ( "Info.ShortcutIsAlreadyUsed" ) , null ) ;
@@ -425,7 +426,7 @@ void AssignNewShortcut(ShortcutListItem item, Keys shortcut)
425
426
this . filterTextBox . SelectAll ( ) ;
426
427
}
427
428
}
428
-
429
+
429
430
/// <summary>
430
431
/// Resets the conflicts status of an item.
431
432
/// </summary>
@@ -443,7 +444,7 @@ static void ResetConflicts(ShortcutListItem item)
443
444
item . Conflicts = null ; // empty conflicts list will be garbage collected
444
445
}
445
446
}
446
-
447
+
447
448
/// <summary>
448
449
/// Gets a list of all conflicting entries.
449
450
/// </summary>
@@ -452,21 +453,19 @@ void GetConflictItems(ShortcutListItem target)
452
453
var keys = target . Custom ;
453
454
if ( keys == 0 ) return ;
454
455
455
- var conflicts = new List < ShortcutListItem > { target } ;
456
+ List < ShortcutListItem > conflicts = null ;
456
457
457
458
for ( int i = 0 ; i < this . shortcutListItems . Length ; i ++ )
458
459
{
459
460
var item = this . shortcutListItems [ i ] ;
460
461
461
- if ( item == target ) continue ;
462
- if ( item . Custom == keys )
463
- {
464
- conflicts . Add ( item ) ;
465
- item . Conflicts = conflicts ;
466
- }
462
+ if ( item . Custom != keys || item == target ) continue ;
463
+ if ( conflicts == null ) conflicts = new List < ShortcutListItem > { target } ;
464
+ conflicts . Add ( item ) ;
465
+ item . Conflicts = conflicts ;
467
466
}
468
467
469
- if ( conflicts . Count > 1 ) target . Conflicts = conflicts ;
468
+ target . Conflicts = conflicts ;
470
469
}
471
470
472
471
/// <summary>
@@ -634,7 +633,7 @@ void DialogClosed(object sender, FormClosedEventArgs e)
634
633
635
634
#endregion
636
635
637
-
636
+
638
637
#region ListViewComparer
639
638
640
639
/// <summary>
@@ -720,6 +719,7 @@ public Keys Custom
720
719
this . custom = value ;
721
720
this . KeysString = DataConverter . KeysToString ( this . custom ) ;
722
721
this . SubItems [ 1 ] . Text = this . KeysString ;
722
+ ResetConflicts ( this ) ;
723
723
UpdateItemHighlightFont ( this ) ;
724
724
}
725
725
}
@@ -746,11 +746,13 @@ public bool IsModified
746
746
/// </summary>
747
747
public ShortcutListItem ( ShortcutItem shortcutItem )
748
748
{
749
- this . SubItems . Add ( string . Empty ) ;
750
- this . Name = this . Text = shortcutItem . Id ;
751
749
this . item = shortcutItem ;
752
750
this . conflicts = null ;
753
- this . Custom = shortcutItem . Custom ;
751
+ this . custom = this . Item . Custom ;
752
+ this . KeysString = DataConverter . KeysToString ( this . Custom ) ;
753
+ this . Name = this . Text = this . Id ;
754
+ this . SubItems . Add ( this . KeysString ) ;
755
+ UpdateItemHighlightFont ( this ) ;
754
756
}
755
757
756
758
/// <summary>
0 commit comments